From ffecd189eeb99b2ff0acb2e0ecc49170f9aceb35 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Thu, 1 Nov 2018 07:23:44 +0000 Subject: [PATCH 1/3] Report rhost, as ip is undefined --- modules/auxiliary/scanner/vmware/vmware_http_login.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auxiliary/scanner/vmware/vmware_http_login.rb b/modules/auxiliary/scanner/vmware/vmware_http_login.rb index be7ec8ee11..9079ace35e 100644 --- a/modules/auxiliary/scanner/vmware/vmware_http_login.rb +++ b/modules/auxiliary/scanner/vmware/vmware_http_login.rb @@ -131,7 +131,7 @@ class MetasploitModule < Msf::Auxiliary if os_match[1] =~ /ESX/ or os_match[1] =~ /vCenter/ # Report a fingerprint match for OS identification report_note( - :host => ip, + :host => rhost, :ntype => 'fingerprint.match', :data => {'os.vendor' => 'VMware', 'os.product' => os_match[1] + " " + ver_match[1], 'os.version' => build_match[1] } ) From ca16e93200ef996f9f94ef9cdcb4eb4237a6cd3b Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Thu, 1 Nov 2018 07:24:28 +0000 Subject: [PATCH 2/3] rescue => e --- modules/auxiliary/scanner/vmware/vmware_http_login.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auxiliary/scanner/vmware/vmware_http_login.rb b/modules/auxiliary/scanner/vmware/vmware_http_login.rb index 9079ace35e..fa1dff1e0d 100644 --- a/modules/auxiliary/scanner/vmware/vmware_http_login.rb +++ b/modules/auxiliary/scanner/vmware/vmware_http_login.rb @@ -104,7 +104,7 @@ class MetasploitModule < Msf::Auxiliary rescue ::Rex::ConnectionError => e vprint_error("#{rhost}:#{rport} Error: could not connect") return false - rescue + rescue => e vprint_error("#{rhost}:#{rport} Error: #{e}") return false end From a80e571355e669b795db7657961b212372f07307 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Thu, 1 Nov 2018 07:26:12 +0000 Subject: [PATCH 3/3] Update style --- .../scanner/vmware/vmware_http_login.rb | 60 +++++++++---------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/modules/auxiliary/scanner/vmware/vmware_http_login.rb b/modules/auxiliary/scanner/vmware/vmware_http_login.rb index fa1dff1e0d..44a5ec1e98 100644 --- a/modules/auxiliary/scanner/vmware/vmware_http_login.rb +++ b/modules/auxiliary/scanner/vmware/vmware_http_login.rb @@ -75,7 +75,6 @@ class MetasploitModule < Msf::Auxiliary } end - # Mostly taken from the Apache Tomcat service validator def is_vmware? soap_data = @@ -87,27 +86,25 @@ class MetasploitModule < Msf::Auxiliary | - begin - res = send_request_cgi({ - 'uri' => normalize_uri(datastore['URI']), - 'method' => 'POST', - 'agent' => 'VMware VI Client', - 'data' => soap_data - }, 25) + res = send_request_cgi({ + 'uri' => normalize_uri(datastore['URI']), + 'method' => 'POST', + 'agent' => 'VMware VI Client', + 'data' => soap_data + }, 25) - if res - fingerprint_vmware(res) - else - vprint_error("#{rhost}:#{rport} Error: no response") - end - - rescue ::Rex::ConnectionError => e - vprint_error("#{rhost}:#{rport} Error: could not connect") - return false - rescue => e - vprint_error("#{rhost}:#{rport} Error: #{e}") + unless res + vprint_error("#{rhost}:#{rport} Error: no response") return false end + + fingerprint_vmware(res) + rescue ::Rex::ConnectionError => e + vprint_error("#{rhost}:#{rport} Error: could not connect") + return false + rescue => e + vprint_error("#{rhost}:#{rport} Error: #{e}") + return false end def fingerprint_vmware(res) @@ -127,22 +124,19 @@ class MetasploitModule < Msf::Auxiliary report_service(:host => rhost, :port => rport, :proto => 'tcp', :sname => 'https', :info => full_match[1]) end - if os_match and ver_match and build_match - if os_match[1] =~ /ESX/ or os_match[1] =~ /vCenter/ - # Report a fingerprint match for OS identification - report_note( - :host => rhost, - :ntype => 'fingerprint.match', - :data => {'os.vendor' => 'VMware', 'os.product' => os_match[1] + " " + ver_match[1], 'os.version' => build_match[1] } - ) - end - return true - else - vprint_error("#{rhost}:#{rport} Error: Could not identify as VMWare") + unless os_match and ver_match and build_match + vprint_error("#{rhost}:#{rport} Error: Could not identify host as VMWare") return false end + if os_match[1].include?('ESX') || os_match[1].include?('vCenter') + # Report a fingerprint match for OS identification + report_note( + :host => rhost, + :ntype => 'fingerprint.match', + :data => {'os.vendor' => 'VMware', 'os.product' => os_match[1] + " " + ver_match[1], 'os.version' => build_match[1] } + ) + return true + end end - - end