Skip to content

Commit b9360b9

Browse files
author
jvazquez-r7
committed
Land rapid7#2286, @wchen-r7's patch for undefined method errors
2 parents 8e9bcb4 + 85ed916 commit b9360b9

23 files changed

+113
-28
lines changed

modules/auxiliary/admin/edirectory/edirectory_edirutil.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ def run
148148
}
149149
}, 25)
150150

151+
if res.nil?
152+
print_error("Did not get a response from server")
153+
return
154+
end
155+
151156
raw_data = res.body.scan(/#{action.opts['PATTERN']}/).flatten[0]
152157
print_line("\n" + Rex::Text.decode_base64(raw_data))
153158

modules/auxiliary/admin/http/jboss_seam_exec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ def run
6767
'method' => 'GET',
6868
}, 20)
6969

70-
if (res.headers['Location'] =~ %r(java.lang.Runtime.exec\%28java.lang.String\%29))
70+
if (res and res.headers['Location'] =~ %r(java.lang.Runtime.exec\%28java.lang.String\%29))
7171
flag_found_one = index
7272
print_status("Found right index at [" + index.to_s + "] - exec")
73-
elsif (res.headers['Location'] =~ %r(java.lang.Runtime\+java.lang.Runtime.getRuntime))
73+
elsif (res and res.headers['Location'] =~ %r(java.lang.Runtime\+java.lang.Runtime.getRuntime))
7474
print_status("Found right index at [" + index.to_s + "] - getRuntime")
7575
flag_found_two = index
7676
else
@@ -90,7 +90,8 @@ def run
9090
'method' => 'GET',
9191
}, 20)
9292

93-
if (res.headers['Location'] =~ %r(pwned=java.lang.UNIXProcess))
93+
94+
if (res and res.headers['Location'] =~ %r(pwned=java.lang.UNIXProcess))
9495
print_status("Exploited successfully")
9596
else
9697
print_status("Exploit failed.")

modules/auxiliary/admin/http/typo3_sa_2010_020.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,23 @@ def run
9999
},25)
100100

101101
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
102+
return
102103
rescue ::Timeout::Error, ::Errno::EPIPE => e
103104
print_error(e.message)
105+
return
106+
end
107+
108+
if file.nil?
109+
print_error("Connection timed out")
110+
return
104111
end
105112

106113
if ((counter.to_f/queue.length.to_f)*100.0).to_s =~ /\d0.0$/ # Display percentage complete every 10%
107114
percentage = (counter.to_f/queue.length.to_f)*100.0
108115
print_status("Requests #{percentage.to_i}% complete - [#{counter} / #{queue.length}]")
109116
end
110117

118+
# file can be nil
111119
case file.headers['Content-Type']
112120
when 'text/html'
113121
case file.body

modules/auxiliary/admin/oracle/osb_execqr2.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def run
5151
'method' => 'POST',
5252
}, 5)
5353

54-
if (res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/PHPSESSID=(.*);(.*)/i))
54+
if (res and res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/PHPSESSID=(.*);(.*)/i))
5555

5656
sessionid = res.headers['Set-Cookie'].split(';')[0]
5757

modules/auxiliary/admin/oracle/osb_execqr3.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def run
4848
'method' => 'POST',
4949
}, 5)
5050

51-
if (res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/PHPSESSID=(.*);(.*)/i))
51+
if (res and res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/PHPSESSID=(.*);(.*)/i))
5252

5353
sessionid = res.headers['Set-Cookie'].split(';')[0]
5454

modules/auxiliary/gather/external_ip.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def initialize
4242
def run
4343
connect
4444
res = send_request_cgi({'uri' => '/ip', 'method' => 'GET' })
45+
46+
if res.nil?
47+
print_error("Connection timed out")
48+
return
49+
end
50+
4551
our_addr = res.body.strip
4652
if Rex::Socket.is_ipv4?(our_addr) or Rex::Socket.is_ipv6?(our_addr)
4753
print_good("Source ip to #{rhost} is #{our_addr}")

modules/auxiliary/scanner/http/axis_local_file_include.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ def get_credentials(uri)
8484

8585
print_status("#{target_url} - Apache Axis - Dumping administrative credentials")
8686

87-
if (res and res.code == 200)
87+
if res.nil?
88+
print_error("#{target_url} - Connection timed out")
89+
return
90+
end
91+
92+
if (res.code == 200)
8893
if res.body.to_s.match(/axisconfig/)
8994

9095
res.body.scan(/parameter\sname=\"userName\">([^\s]+)</)

modules/auxiliary/scanner/http/barracuda_directory_traversal.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ def run_host(ip)
6363
'uri' => uri + payload,
6464
}, 25)
6565

66-
if (res and res.code == 200 and res.body)
66+
if res.nil?
67+
print_error("#{target_url} - Connection timed out")
68+
return
69+
end
70+
71+
if (res.code == 200 and res.body)
6772
if res.body.match(/\<html\>(.*)\<\/html\>/im)
6873
html = $1
6974

modules/auxiliary/scanner/http/dir_webdav_unicode_bypass.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def run_host(ip)
164164
'data' => webdav_req + "\r\n\r\n",
165165
}, 20)
166166

167-
if (res.code.to_i == 207)
167+
if (res and res.code.to_i == 207)
168168
print_status("\tFound vulnerable WebDAV Unicode bypass target #{wmap_base_url}#{tpath}%c0%af#{testfdir} #{res.code} (#{wmap_target_host})")
169169

170170
# Unable to use report_web_vuln as method is PROPFIND and is not part of allowed

modules/auxiliary/scanner/http/dolibarr_login.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def initialize(info = {})
4141
def get_sid_token
4242
res = send_request_raw({
4343
'method' => 'GET',
44-
'uri' => @uri.path
44+
'uri' => normalize_uri(@uri.path)
4545
})
4646

4747
return [nil, nil] if not (res and res.headers['Set-Cookie'])
@@ -74,7 +74,7 @@ def do_login(user, pass)
7474
begin
7575
res = send_request_cgi({
7676
'method' => 'POST',
77-
'uri' => "#{@uri.path}index.php",
77+
'uri' => normalize_uri("#{@uri.path}index.php"),
7878
'cookie' => sid,
7979
'vars_post' => {
8080
'token' => token,
@@ -92,6 +92,11 @@ def do_login(user, pass)
9292
return :abort
9393
end
9494

95+
if res.nil?
96+
print_error("#{@peer} - Connection timed out")
97+
return :abort
98+
end
99+
95100
location = res.headers['Location']
96101
if res and res.headers and (location = res.headers['Location']) and location =~ /admin\//
97102
print_good("#{@peer} - Successful login: \"#{user}:#{pass}\"")
@@ -112,7 +117,7 @@ def do_login(user, pass)
112117
end
113118

114119
def run
115-
@uri = normalize_uri(target_uri.path)
120+
@uri = target_uri.path
116121
@uri.path << "/" if @uri.path[-1, 1] != "/"
117122
@peer = "#{rhost}:#{rport}"
118123

0 commit comments

Comments
 (0)