Handle nil for get_once

unstable
sinn3r 2012-06-04 15:31:10 -05:00
parent a071d2805e
commit 0fcc53b0a2
16 changed files with 20 additions and 20 deletions

View File

@ -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)

View File

@ -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('=')

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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",".")

View File

@ -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')

View File

@ -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)

View File

@ -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

View File

@ -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}")

View File

@ -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

View File

@ -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

View File

@ -33,7 +33,7 @@ class Metasploit3 < Msf::Auxiliary
'Author' =>
[
'ramon',
'Adriano Lima <adriano@risesecurity.org>',
'Adriano Lima <adriano[at]risesecurity.org>',
],
'License' => MSF_LICENSE
)

View File

@ -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

View File

@ -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:]]+/, ' ')}")

View File

@ -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?