From 0fcc53b0a25ddfd1de10b819ecdc16629d23bc4d Mon Sep 17 00:00:00 2001 From: sinn3r Date: Mon, 4 Jun 2012 15:31:10 -0500 Subject: [PATCH] Handle nil for get_once --- modules/auxiliary/admin/cisco/vpn_3000_ftp_bypass.rb | 2 +- .../auxiliary/admin/edirectory/edirectory_dhost_cookie.rb | 2 +- modules/auxiliary/admin/emc/alphastor_devicemanager_exec.rb | 4 ++-- modules/auxiliary/admin/hp/hp_data_protector_cmd.rb | 2 +- modules/auxiliary/admin/maxdb/maxdb_cons_exec.rb | 2 +- modules/auxiliary/admin/oracle/tnscmd.rb | 2 +- modules/auxiliary/admin/zend/java_bridge.rb | 6 +++--- modules/auxiliary/dos/windows/ftp/solarftp_user.rb | 2 +- modules/auxiliary/dos/windows/smtp/ms06_019_exchange.rb | 2 +- modules/auxiliary/gather/checkpoint_hostname.rb | 4 ++-- modules/auxiliary/scanner/finger/finger_users.rb | 2 +- modules/auxiliary/scanner/http/frontpage_login.rb | 2 +- modules/auxiliary/scanner/misc/ib_service_mgr_info.rb | 2 +- modules/auxiliary/scanner/oracle/sid_brute.rb | 2 +- modules/auxiliary/scanner/rservices/rexec_login.rb | 2 +- modules/auxiliary/scanner/rservices/rsh_login.rb | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/auxiliary/admin/cisco/vpn_3000_ftp_bypass.rb b/modules/auxiliary/admin/cisco/vpn_3000_ftp_bypass.rb index 7a6326b1e9..5992230732 100644 --- a/modules/auxiliary/admin/cisco/vpn_3000_ftp_bypass.rb +++ b/modules/auxiliary/admin/cisco/vpn_3000_ftp_bypass.rb @@ -50,7 +50,7 @@ class Metasploit3 < Msf::Auxiliary def run connect res = sock.get_once - if (res =~ /220 Session will be terminated after/) + if (res and res =~ /220 Session will be terminated after/) print_status("Target appears to be a Cisco VPN Concentrator 3000 series.") test = Rex::Text.rand_text_alphanumeric(8) diff --git a/modules/auxiliary/admin/edirectory/edirectory_dhost_cookie.rb b/modules/auxiliary/admin/edirectory/edirectory_dhost_cookie.rb index 0113341ce3..6c3dae81c3 100644 --- a/modules/auxiliary/admin/edirectory/edirectory_dhost_cookie.rb +++ b/modules/auxiliary/admin/edirectory/edirectory_dhost_cookie.rb @@ -57,7 +57,7 @@ class Metasploit3 < Msf::Auxiliary disconnect cookie = nil - if(res =~ /Cookie:\s*([^\s]+)\s*/mi) + if(res and res =~ /Cookie:\s*([^\s]+)\s*/mi) cookie = $1 cookie,junk = cookie.split(';') name,cookie = cookie.split('=') diff --git a/modules/auxiliary/admin/emc/alphastor_devicemanager_exec.rb b/modules/auxiliary/admin/emc/alphastor_devicemanager_exec.rb index 16a2d9e343..895db730f3 100644 --- a/modules/auxiliary/admin/emc/alphastor_devicemanager_exec.rb +++ b/modules/auxiliary/admin/emc/alphastor_devicemanager_exec.rb @@ -56,9 +56,9 @@ class Metasploit3 < Msf::Auxiliary # try to suck it all in. select(nil,nil,nil,5) - res = sock.get_once + res = sock.get_once || '' - res.each do |info| + res.each_line do |info| print_status("#{info.gsub(/[^[:print:]]+/,"")}") # hack. end diff --git a/modules/auxiliary/admin/hp/hp_data_protector_cmd.rb b/modules/auxiliary/admin/hp/hp_data_protector_cmd.rb index 406d13205c..1a83701578 100644 --- a/modules/auxiliary/admin/hp/hp_data_protector_cmd.rb +++ b/modules/auxiliary/admin/hp/hp_data_protector_cmd.rb @@ -88,7 +88,7 @@ class Metasploit3 < Msf::Auxiliary connect sock.put(packet) res = sock.get_once - print_status(res.to_s) if not res.empty? + print_status(res.to_s) if res and not res.empty? rescue print_error("#{rhost}:#{rport} - Unable to connect") ensure diff --git a/modules/auxiliary/admin/maxdb/maxdb_cons_exec.rb b/modules/auxiliary/admin/maxdb/maxdb_cons_exec.rb index 986abd4c95..4a504fd646 100644 --- a/modules/auxiliary/admin/maxdb/maxdb_cons_exec.rb +++ b/modules/auxiliary/admin/maxdb/maxdb_cons_exec.rb @@ -60,7 +60,7 @@ class Metasploit3 < Msf::Auxiliary sock.get_once sock.put(db_version) - ver = sock.get_once + ver = sock.get_once || '' info = ver[27,2000] if (info.length > 0) diff --git a/modules/auxiliary/admin/oracle/tnscmd.rb b/modules/auxiliary/admin/oracle/tnscmd.rb index d6db117e46..191c19afa4 100644 --- a/modules/auxiliary/admin/oracle/tnscmd.rb +++ b/modules/auxiliary/admin/oracle/tnscmd.rb @@ -52,7 +52,7 @@ class Metasploit3 < Msf::Auxiliary select(nil,nil,nil,0.5) print_status("reading") - res = sock.get_once(-1,5) + res = sock.get_once(-1,5) || '' res = res.tr("[\200-\377]","[\000-\177]") res = res.tr("[\000-\027\]",".") res = res.tr("\177",".") diff --git a/modules/auxiliary/admin/zend/java_bridge.rb b/modules/auxiliary/admin/zend/java_bridge.rb index bd76b2bd23..998a60f558 100644 --- a/modules/auxiliary/admin/zend/java_bridge.rb +++ b/modules/auxiliary/admin/zend/java_bridge.rb @@ -57,7 +57,7 @@ class Metasploit3 < Msf::Auxiliary print_status("Creating the Java Object 'java.lang.Runtime'") sock.put(java_object) - res = sock.get_once() + res = sock.get_once() || '' classid = res[5,4] runtime = [0x16000000].pack('V') + classid + [0x0a000000].pack('V') @@ -65,7 +65,7 @@ class Metasploit3 < Msf::Auxiliary print_status("Invoking static method 'getRuntime()'") sock.put(runtime) - res = sock.get_once() + res = sock.get_once() || '' methodid = res[5,4] exec = [0x00].pack('n') + [21 + cmd.length].pack('n') + methodid @@ -74,7 +74,7 @@ class Metasploit3 < Msf::Auxiliary print_status("Invoking method 'exec()' with parameter '#{cmd}'") sock.put(exec) - success = sock.get_once() + success = sock.get_once() || '' if (success =~ /\x00\x00\x00/) print_status("Cleaning up the JVM") rm = [0x11000000].pack('V') + [0xffffffff].pack('V') diff --git a/modules/auxiliary/dos/windows/ftp/solarftp_user.rb b/modules/auxiliary/dos/windows/ftp/solarftp_user.rb index ebb04b1c32..1ce6180d8d 100644 --- a/modules/auxiliary/dos/windows/ftp/solarftp_user.rb +++ b/modules/auxiliary/dos/windows/ftp/solarftp_user.rb @@ -47,7 +47,7 @@ class Metasploit3 < Msf::Auxiliary def run connect - banner = sock.get_once(-1, 10) + banner = sock.get_once(-1, 10) || '' print_status("Banner: #{banner.strip}") buf = Rex::Text.pattern_create(50) diff --git a/modules/auxiliary/dos/windows/smtp/ms06_019_exchange.rb b/modules/auxiliary/dos/windows/smtp/ms06_019_exchange.rb index e749e5f958..e06089e4e3 100644 --- a/modules/auxiliary/dos/windows/smtp/ms06_019_exchange.rb +++ b/modules/auxiliary/dos/windows/smtp/ms06_019_exchange.rb @@ -116,7 +116,7 @@ class Metasploit3 < Msf::Auxiliary print_status("Sending message...") sock.put(mail) sock.put("QUIT\r\n") - print "<< " + sock.get_once + print "<< " + (sock.get_once || '') disconnect end diff --git a/modules/auxiliary/gather/checkpoint_hostname.rb b/modules/auxiliary/gather/checkpoint_hostname.rb index c96aa5a544..c3656ef81d 100644 --- a/modules/auxiliary/gather/checkpoint_hostname.rb +++ b/modules/auxiliary/gather/checkpoint_hostname.rb @@ -55,11 +55,11 @@ class Metasploit3 < Msf::Auxiliary sock.put("\x51\x00\x00\x00") sock.put("\x00\x00\x00\x21") res = sock.get_once(4) - if (res == "Y\x00\x00\x00") + if (res and res == "Y\x00\x00\x00") print_good("Appears to be a CheckPoint Firewall...") sock.put("\x00\x00\x00\x0bsecuremote\x00") res = sock.get_once - if (res =~ /CN=(.+),O=(.+)\./i) + if (res and res =~ /CN=(.+),O=(.+)\./i) fw_hostname = $1 sc_hostname = $2 print_good("Firewall Host: #{fw_hostname}") diff --git a/modules/auxiliary/scanner/finger/finger_users.rb b/modules/auxiliary/scanner/finger/finger_users.rb index 9f85b39120..2b8047a156 100644 --- a/modules/auxiliary/scanner/finger/finger_users.rb +++ b/modules/auxiliary/scanner/finger/finger_users.rb @@ -137,7 +137,7 @@ class Metasploit3 < Msf::Auxiliary def finger_slurp_data buff = "" begin - while(res = sock.get_once(-1, 5)) + while(res = sock.get_once(-1, 5) || '') buff << res break if buff.length > (1024*1024) end diff --git a/modules/auxiliary/scanner/http/frontpage_login.rb b/modules/auxiliary/scanner/http/frontpage_login.rb index c233192ebd..7157650632 100644 --- a/modules/auxiliary/scanner/http/frontpage_login.rb +++ b/modules/auxiliary/scanner/http/frontpage_login.rb @@ -58,7 +58,7 @@ class Metasploit3 < Msf::Auxiliary "Connection: Keep-Alive, TE\r\n" + "Host: #{target_host}\r\n" + "User-Agent: " + datastore['UserAgent'] + "\r\n\r\n") - res = sock.get_once + res = sock.get_once || '' disconnect diff --git a/modules/auxiliary/scanner/misc/ib_service_mgr_info.rb b/modules/auxiliary/scanner/misc/ib_service_mgr_info.rb index 000817f655..5405608600 100644 --- a/modules/auxiliary/scanner/misc/ib_service_mgr_info.rb +++ b/modules/auxiliary/scanner/misc/ib_service_mgr_info.rb @@ -33,7 +33,7 @@ class Metasploit3 < Msf::Auxiliary 'Author' => [ 'ramon', - 'Adriano Lima ', + 'Adriano Lima ', ], 'License' => MSF_LICENSE ) diff --git a/modules/auxiliary/scanner/oracle/sid_brute.rb b/modules/auxiliary/scanner/oracle/sid_brute.rb index 8e5782a8ce..44940aa7af 100644 --- a/modules/auxiliary/scanner/oracle/sid_brute.rb +++ b/modules/auxiliary/scanner/oracle/sid_brute.rb @@ -59,7 +59,7 @@ class Metasploit3 < Msf::Auxiliary def check_sid(sid,ip) pkt = build_sid_request(sid,ip) sock.put(pkt) - data = sock.get_once + data = sock.get_once || '' parse_response(data) end diff --git a/modules/auxiliary/scanner/rservices/rexec_login.rb b/modules/auxiliary/scanner/rservices/rexec_login.rb index 23b7045a59..c0a403051b 100644 --- a/modules/auxiliary/scanner/rservices/rexec_login.rb +++ b/modules/auxiliary/scanner/rservices/rexec_login.rb @@ -100,7 +100,7 @@ class Metasploit3 < Msf::Auxiliary ) # Read the expected nul byte response. - buf = sock.get_once(1) + buf = sock.get_once(1) || '' if buf != "\x00" buf = sock.get_once(-1) || "" vprint_error("Result: #{buf.gsub(/[[:space:]]+/, ' ')}") diff --git a/modules/auxiliary/scanner/rservices/rsh_login.rb b/modules/auxiliary/scanner/rservices/rsh_login.rb index fdb4ec6b2e..78e16992f0 100644 --- a/modules/auxiliary/scanner/rservices/rsh_login.rb +++ b/modules/auxiliary/scanner/rservices/rsh_login.rb @@ -167,7 +167,7 @@ class Metasploit3 < Msf::Auxiliary ) # Read the expected nul byte response. - buf = sock.get_once(1) + buf = sock.get_once(1) || '' if buf != "\x00" buf = sock.get_once(-1) if buf.nil?