2008-11-22 04:34:59 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2008-11-22 04:34:59 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Exploit mixins should be called first
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::WmapScanDir
|
|
|
|
include Msf::Auxiliary::WmapScanFile
|
|
|
|
# Scanner mixin should be near last
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'HTTP Verb Authentication Bypass Scanner',
|
|
|
|
'Description' => %q{
|
|
|
|
This module test for authentication bypass using different HTTP verbs.
|
|
|
|
},
|
2015-10-01 03:37:03 +00:00
|
|
|
'Author' => ['et [at] metasploit.com'],
|
2013-08-30 21:28:54 +00:00
|
|
|
'License' => BSD_LICENSE))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
2015-10-01 03:37:03 +00:00
|
|
|
OptString.new('TARGETURI', [true, "The path to test", '/'])
|
2013-08-30 21:28:54 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
begin
|
|
|
|
test_verbs(ip)
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_verbs(ip)
|
|
|
|
verbs = [ 'HEAD', 'TRACE', 'TRACK', 'Wmap', 'get', 'trace' ]
|
|
|
|
|
|
|
|
res = send_request_raw({
|
2015-10-01 03:37:03 +00:00
|
|
|
'uri' => normalize_uri(target_uri.path),
|
2013-08-30 21:28:54 +00:00
|
|
|
'method' => 'GET'
|
|
|
|
}, 10)
|
|
|
|
|
|
|
|
return if not res
|
|
|
|
|
|
|
|
if not res.headers['WWW-Authenticate']
|
2015-10-01 03:37:03 +00:00
|
|
|
print_status("#{full_uri} - Authentication not required [#{res.code}]")
|
2013-08-30 21:28:54 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
auth_code = res.code
|
|
|
|
|
2015-10-01 03:37:03 +00:00
|
|
|
print_status("#{full_uri} - Authentication required: #{res.headers['WWW-Authenticate']} [#{auth_code}]")
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'tcp',
|
|
|
|
:sname => (ssl ? 'https' : 'http'),
|
|
|
|
:port => rport,
|
|
|
|
:type => 'WWW_AUTHENTICATE',
|
2015-10-01 03:37:03 +00:00
|
|
|
:data => "#{target_uri.path} Realm: #{res.headers['WWW-Authenticate']}",
|
2013-08-30 21:28:54 +00:00
|
|
|
:update => :unique_data
|
|
|
|
)
|
|
|
|
|
|
|
|
verbs.each do |tv|
|
|
|
|
resauth = send_request_raw({
|
2015-10-01 03:37:03 +00:00
|
|
|
'uri' => normalize_uri(target_uri.path),
|
2013-08-30 21:28:54 +00:00
|
|
|
'method' => tv
|
|
|
|
}, 10)
|
|
|
|
|
|
|
|
next if not resauth
|
|
|
|
|
2015-10-01 03:37:03 +00:00
|
|
|
print_status("#{full_uri} - Testing verb #{tv} [#{resauth.code}]")
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
if resauth.code != auth_code and resauth.code <= 302
|
2015-10-01 03:37:03 +00:00
|
|
|
print_good("#{full_uri} - Possible authentication bypass with verb #{tv} [#{resauth.code}]")
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
# Unable to use report_web_vuln as method is not in list of allowed methods.
|
|
|
|
|
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'tcp',
|
|
|
|
:sname => (ssl ? 'https' : 'http'),
|
|
|
|
:port => rport,
|
|
|
|
:type => 'AUTH_BYPASS_VERB',
|
2015-10-01 03:37:03 +00:00
|
|
|
:data => "#{target_uri.path} Verb: #{tv}",
|
2013-08-30 21:28:54 +00:00
|
|
|
:update => :unique_data
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-01-15 20:36:41 +00:00
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
end
|