Skip to content

Commit d6f4c02

Browse files
committed
Land rapid7#3979, @wchen-r7 fixes rapid7#3976, http_login not using TARGETURI, neither uri normalization
2 parents f886ab6 + d366cdc commit d6f4c02

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

modules/auxiliary/scanner/http/http_login.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@ def initialize
5454
register_autofilter_ports([ 80, 443, 8080, 8081, 8000, 8008, 8443, 8444, 8880, 8888 ])
5555
end
5656

57-
def find_auth_uri
57+
def to_uri(uri)
58+
begin
59+
# In case TARGETURI is empty, at least we default to '/'
60+
uri = "/" if uri.blank?
61+
URI(uri)
62+
rescue ::URI::InvalidURIError
63+
raise RuntimeError, "Invalid URI: #{uri}"
64+
end
65+
end
5866

67+
def find_auth_uri
5968
if datastore['AUTH_URI'].present?
6069
paths = [datastore['AUTH_URI']]
6170
else
@@ -69,8 +78,20 @@ def find_auth_uri
6978
end
7079

7180
paths.each do |path|
81+
uri = ''
82+
83+
begin
84+
uri = to_uri(path)
85+
rescue RuntimeError => e
86+
# Bad URI so we will not try to request it
87+
print_error(e.message)
88+
next
89+
end
90+
91+
uri = normalize_uri(uri.path)
92+
7293
res = send_request_cgi({
73-
'uri' => path,
94+
'uri' => uri,
7495
'method' => datastore['REQUESTTYPE'],
7596
'username' => '',
7697
'password' => ''

0 commit comments

Comments
 (0)