Skip to content

Commit e298866

Browse files
author
jvazquez-r7
committed
Merge branch 'bug/unmerge-1444-and-1476' of https://github.com/todb-r7/metasploit-framework into todb-r7-bug/unmerge-1444-and-1476
2 parents 44d984d + 8ddc19e commit e298866

25 files changed

+650
-557
lines changed

lib/anemone/rex_http.rb

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

196194
conn.set_config(

lib/msf/core/auxiliary/crawler.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ 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]),
26-
OptString.new('USERNAME', [false, 'The HTTP username to specify for authentication']),
27-
OptString.new('PASSWORD', [false, 'The HTTP password to specify for authentication'])
25+
OptInt.new('MAX_THREADS', [ true, 'The maximum number of concurrent requests', 4])
2826
], self.class
2927
)
3028

@@ -36,6 +34,8 @@ def initialize(info = {})
3634
OptString.new('UserAgent', [true, 'The User-Agent header to use for all requests',
3735
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
3836
]),
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,9 +118,8 @@ def run
118118
:info => ""
119119
})
120120

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

126125
if datastore['HTTPCookie']
@@ -279,8 +278,9 @@ def crawler_options(t)
279278
opts[:cookies] = t[:cookies]
280279
end
281280

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

285285
opts
286286
end

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

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

13-
1413
class Request
1514
attr_accessor :url
1615
attr_reader :opts
@@ -70,7 +69,6 @@ def timed_out
7069
attr_reader :framework
7170

7271
attr_accessor :redirect_limit
73-
attr_accessor :username , :password
7472

7573
def initialize( opts = {} )
7674
@opts = opts.dup
@@ -86,8 +84,8 @@ def initialize( opts = {} )
8684

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

9391
self.redirect_limit = opts[:redirect_limit] || 20
@@ -107,9 +105,7 @@ def connect
107105
opts[:target].port,
108106
{},
109107
opts[:target].ssl,
110-
'SSLv23',
111-
username,
112-
password
108+
'SSLv23'
113109
)
114110

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

302298
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
307299
Response.from_rex_response c.send_recv( c.request_cgi( opts ), timeout )
308300
rescue ::Timeout::Error
309301
Response.timed_out

0 commit comments

Comments
 (0)