Skip to content

Commit 5b3b0a8

Browse files
committed
Merge branch 'dmaloney-r7-http/auth_methods' into rapid7
2 parents 2b3c8a6 + a158893 commit 5b3b0a8

File tree

24 files changed

+548
-644
lines changed

24 files changed

+548
-644
lines changed

lib/anemone/rex_http.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ def connection(url)
188188
context,
189189
url.scheme == "https",
190190
'SSLv23',
191-
@opts[:proxies]
191+
@opts[:proxies],
192+
@opts[:username],
193+
@opts[:password]
192194
)
193195

194196
conn.set_config(

lib/msf/core/auxiliary/crawler.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def initialize(info = {})
2222
Opt::Proxies,
2323
OptInt.new('MAX_PAGES', [ true, 'The maximum number of pages to crawl per URL', 500]),
2424
OptInt.new('MAX_MINUTES', [ true, 'The maximum number of minutes to spend on each URL', 5]),
25-
OptInt.new('MAX_THREADS', [ true, 'The maximum number of concurrent requests', 4])
25+
OptInt.new('MAX_THREADS', [ true, 'The maximum number of concurrent requests', 4]),
26+
OptString.new('USERNAME', [false, 'The HTTP username to specify for authentication']),
27+
OptString.new('PASSWORD', [false, 'The HTTP password to specify for authentication'])
2628
], self.class
2729
)
2830

@@ -34,8 +36,6 @@ def initialize(info = {})
3436
OptString.new('UserAgent', [true, 'The User-Agent header to use for all requests',
3537
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
3638
]),
37-
OptString.new('BasicAuthUser', [false, 'The HTTP username to specify for basic authentication']),
38-
OptString.new('BasicAuthPass', [false, 'The HTTP password to specify for basic authentication']),
3939
OptString.new('HTTPAdditionalHeaders', [false, "A list of additional headers to send (separated by \\x01)"]),
4040
OptString.new('HTTPCookie', [false, "A HTTP cookie header to send with each request"]),
4141
OptBool.new('SSL', [ false, 'Negotiate SSL for outgoing connections', false]),
@@ -118,8 +118,9 @@ def run
118118
:info => ""
119119
})
120120

121-
if datastore['BasicAuthUser']
122-
t[:http_basic_auth] = [ "#{datastore['BasicAuthUser']}:#{datastore['BasicAuthPass']}" ].pack("m*").gsub(/\s+/, '')
121+
if datastore['USERNAME'] and datastore['USERNAME'] != ''
122+
t[:username] = datastore['USERNAME'].to_s
123+
t[:password] = datastore['PASSWORD'].to_s
123124
end
124125

125126
if datastore['HTTPCookie']
@@ -278,9 +279,8 @@ def crawler_options(t)
278279
opts[:cookies] = t[:cookies]
279280
end
280281

281-
if t[:http_basic_auth]
282-
opts[:http_basic_auth] = t[:http_basic_auth]
283-
end
282+
opts[:username] = t[:username] || ''
283+
opts[:password] =t[:password] || ''
284284

285285
opts
286286
end

lib/msf/core/auxiliary/web/http.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
module Msf
1111
class Auxiliary::Web::HTTP
1212

13+
1314
class Request
1415
attr_accessor :url
1516
attr_reader :opts
@@ -69,6 +70,7 @@ def timed_out
6970
attr_reader :framework
7071

7172
attr_accessor :redirect_limit
73+
attr_accessor :username , :password
7274

7375
def initialize( opts = {} )
7476
@opts = opts.dup
@@ -84,8 +86,8 @@ def initialize( opts = {} )
8486

8587
@request_opts = {}
8688
if opts[:auth].is_a? Hash
87-
@request_opts['basic_auth'] = [ opts[:auth][:user].to_s + ':' +
88-
opts[:auth][:password] ]. pack( 'm*' ).gsub( /\s+/, '' )
89+
@username = opts[:auth][:user].to_s
90+
@password = opts[:auth][:password].to_s
8991
end
9092

9193
self.redirect_limit = opts[:redirect_limit] || 20
@@ -105,7 +107,9 @@ def connect
105107
opts[:target].port,
106108
{},
107109
opts[:target].ssl,
108-
'SSLv23'
110+
'SSLv23',
111+
username,
112+
password
109113
)
110114

111115
c.set_config({
@@ -296,6 +300,10 @@ def _request( url, opts = {} )
296300
opts['data'] = body if body
297301

298302
c = connect
303+
if opts['username'] and opts['username'] != ''
304+
c.username = opts['username'].to_s
305+
c.password = opts['password'].to_s
306+
end
299307
Response.from_rex_response c.send_recv( c.request_cgi( opts ), timeout )
300308
rescue ::Timeout::Error
301309
Response.timed_out

0 commit comments

Comments
 (0)