Skip to content

Commit e5ad74f

Browse files
author
jvazquez-r7
committed
Merge branch 'dmaloney-r7-bug/basic_auth', see also rapid7#1477 and rapid7#1444, rapid7#1477, rapid7#1472
2 parents 6e9232b + d4d41f3 commit e5ad74f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lib/rex/proto/http/client.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ def request_raw(opts={})
209209
req << set_agent_header(c_ag)
210210

211211
if (c_auth.length > 0)
212-
req << set_basic_auth_header(c_auth)
212+
unless c_head['Authorization'] and c_head['Authorization'].include? "Basic"
213+
req << set_basic_auth_header(c_auth)
214+
end
213215
end
214216

215217
req << set_cookie_header(c_cook)
@@ -239,6 +241,7 @@ def request_raw(opts={})
239241
# @return [Request]
240242
def request_cgi(opts={})
241243
c_ag = opts['agent'] || config['agent']
244+
c_auth = opts['basic_auth'] || config['basic_auth'] || ''
242245
c_body = opts['data'] || ''
243246
c_cgi = opts['uri'] || '/'
244247
c_conn = opts['connection']
@@ -313,6 +316,12 @@ def request_cgi(opts={})
313316
req << set_host_header(c_host)
314317
req << set_agent_header(c_ag)
315318

319+
if (c_auth.length > 0)
320+
unless c_head['Authorization'] and c_head['Authorization'].include? "Basic"
321+
req << set_basic_auth_header(c_auth)
322+
end
323+
end
324+
316325
req << set_cookie_header(c_cook)
317326
req << set_connection_header(c_conn)
318327
req << set_extra_headers(c_head)

modules/auxiliary/scanner/http/tomcat_mgr_login.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ def run_host(ip)
8787
vprint_error("http://#{rhost}:#{rport}#{uri} - No response")
8888
return
8989
end
90-
if res.code != 401
91-
vprint_error("http://#{rhost}:#{rport} - Authorization not requested")
92-
return
93-
end
9490

9591
each_user_pass { |user, pass|
9692
do_login(user, pass)
@@ -107,10 +103,8 @@ def do_login(user='tomcat', pass='tomcat')
107103
res = send_request_cgi({
108104
'uri' => uri,
109105
'method' => 'GET',
110-
'headers' =>
111-
{
112-
'Authorization' => "Basic #{user_pass}",
113-
}
106+
'username' => user,
107+
'password' => pass
114108
}, 25)
115109
unless (res.kind_of? Rex::Proto::Http::Response)
116110
vprint_error("http://#{rhost}:#{rport}#{uri} not responding")

0 commit comments

Comments
 (0)