2010-04-30 08:40:19 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
2008-11-22 04:34:59 +00:00
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-11-22 04:34:59 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2008-11-22 04:34:59 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
# Exploit mixins should be called first
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::WMAPScanServer
|
|
|
|
# Scanner mixin should be near last
|
|
|
|
include Msf::Auxiliary::Scanner
|
2009-11-26 20:39:15 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2008-11-22 04:34:59 +00:00
|
|
|
'Name' => 'HTTP Verb Authentication Bypass Scanner',
|
|
|
|
'Description' => %q{
|
|
|
|
This module test for authentication bypass using different HTTP verbs.
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'et [at] metasploit.com' ],
|
|
|
|
'License' => BSD_LICENSE,
|
2010-04-30 08:40:19 +00:00
|
|
|
'Version' => '$Revision$'))
|
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "The path to test", '/'])
|
2010-04-30 08:40:19 +00:00
|
|
|
], self.class)
|
2008-11-22 04:34:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Fingerprint a single host
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
verbs = [
|
|
|
|
'HEAD',
|
|
|
|
'TRACE',
|
|
|
|
'TRACK',
|
2010-04-30 08:40:19 +00:00
|
|
|
'WMAP'
|
2008-11-22 04:34:59 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
res = send_request_raw({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'method' => 'GET'
|
|
|
|
}, 10)
|
|
|
|
|
|
|
|
if res
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
auth_code = res.code
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
if res.headers['WWW-Authenticate']
|
|
|
|
print_status("#{ip} requires authentication: #{res.headers['WWW-Authenticate']} [#{auth_code}]")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-11-25 06:08:28 +00:00
|
|
|
report_note(
|
2009-11-26 20:39:15 +00:00
|
|
|
:host => ip,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'tcp',
|
|
|
|
:sname => 'HTTP',
|
2009-11-25 06:08:28 +00:00
|
|
|
:port => rport,
|
|
|
|
:type => 'WWW_AUTHENTICATE',
|
|
|
|
:data => "#{datastore['PATH']} Realm: #{res.headers['WWW-Authenticate']}"
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-11-22 04:34:59 +00:00
|
|
|
verbs.each do |tv|
|
|
|
|
resauth = send_request_raw({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'method' => tv
|
|
|
|
}, 10)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
if resauth
|
2008-11-22 04:34:59 +00:00
|
|
|
print_status("Testing verb #{tv} resp code: [#{resauth.code}]")
|
|
|
|
if resauth.code != auth_code and resauth.code <= 302
|
|
|
|
print_status("Possible authentication bypass with verb #{tv} code #{resauth.code}")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-11-25 06:08:28 +00:00
|
|
|
report_note(
|
2009-11-26 20:39:15 +00:00
|
|
|
:host => ip,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'tcp',
|
|
|
|
:sname => 'HTTP',
|
2009-11-25 06:08:28 +00:00
|
|
|
:port => rport,
|
|
|
|
:type => 'AUTH_BYPASS_VERB',
|
|
|
|
:data => "#{datastore['PATH']} Verb: #{tv}"
|
|
|
|
)
|
2008-11-22 04:34:59 +00:00
|
|
|
end
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
2008-11-22 04:34:59 +00:00
|
|
|
else
|
2009-10-18 20:39:40 +00:00
|
|
|
print_status("[#{ip}] Authentication not required. #{datastore['PATH']} #{res.code}")
|
2008-11-22 04:34:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|