2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-02-08 13:53:50 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-12-30 22:24:22 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'rex/proto/http'
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
#
|
|
|
|
# May I reuse some methods?
|
|
|
|
#
|
|
|
|
require 'cgi'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::WMAPScanServer
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-02-08 13:53:50 +00:00
|
|
|
super(update_info(info,
|
2009-12-30 22:24:22 +00:00
|
|
|
'Name' => 'HTTP Virtual Host Brute Force Scanner',
|
|
|
|
'Description' => %q{
|
2010-02-09 01:10:29 +00:00
|
|
|
This module tries to identify unique virtual hosts
|
2010-02-08 13:53:50 +00:00
|
|
|
hosted by the target web server.
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'et [at] cyberspace.org' ],
|
|
|
|
'License' => BSD_LICENSE,
|
2010-02-08 13:53:50 +00:00
|
|
|
'Version' => '$Revision$'))
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "The PATH to use while testing", '/']),
|
|
|
|
OptString.new('QUERY', [ false, "HTTP URI Query", '']),
|
|
|
|
OptString.new('DOMAIN', [ true, "Domain name", '']),
|
|
|
|
OptString.new('HEADERS', [ false, "HTTP Headers", '']),
|
2010-02-08 13:53:50 +00:00
|
|
|
], self.class)
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
2010-02-08 13:53:50 +00:00
|
|
|
def run_host(ip)
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
valstr = [
|
|
|
|
"admin",
|
|
|
|
"services",
|
|
|
|
"webmail",
|
|
|
|
"console",
|
|
|
|
"apps",
|
|
|
|
"mail",
|
|
|
|
"intranet",
|
|
|
|
"intra",
|
|
|
|
"spool",
|
|
|
|
"corporate",
|
|
|
|
"www",
|
|
|
|
"web"
|
|
|
|
]
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
datastore['QUERY'] ? tquery = queryparse(datastore['QUERY']): nil
|
|
|
|
datastore['HEADERS'] ? thead = headersparse(datastore['HEADERS']) : nil
|
|
|
|
|
|
|
|
noexistsres = nil
|
|
|
|
resparr = []
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
2.times do |n|
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
randhost = Rex::Text.rand_text_alpha(5)+"."+datastore['DOMAIN']
|
|
|
|
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
begin
|
|
|
|
noexistsres = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'vars_get' => tquery,
|
|
|
|
'headers' => thead,
|
2010-02-08 13:53:50 +00:00
|
|
|
'vhost' => randhost,
|
2009-12-30 22:24:22 +00:00
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/plain'
|
|
|
|
}, 20)
|
|
|
|
|
|
|
|
print_status("[#{ip}] Sending request with random domain #{randhost} ")
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if noexistsres
|
|
|
|
resparr[n] = noexistsres.body
|
|
|
|
end
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
2010-02-08 13:53:50 +00:00
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
end
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if resparr[0] != resparr[1]
|
|
|
|
print_error("[#{ip}] Unable to identify error response")
|
|
|
|
return
|
|
|
|
end
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
valstr.each do |astr|
|
|
|
|
thost = astr+"."+datastore['DOMAIN']
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
begin
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'vars_get' => tquery,
|
2010-02-08 13:53:50 +00:00
|
|
|
'headers' => thead,
|
|
|
|
'vhost' => thost,
|
2009-12-30 22:24:22 +00:00
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/plain'
|
|
|
|
}, 20)
|
2010-02-08 13:53:50 +00:00
|
|
|
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if res and noexistsres
|
|
|
|
|
2010-02-08 13:53:50 +00:00
|
|
|
if res.body != noexistsres.body
|
2009-12-30 22:24:22 +00:00
|
|
|
print_status("[#{ip}] Vhost found #{thost} ")
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'HTTP',
|
|
|
|
:port => rport,
|
|
|
|
:type => 'VHOST',
|
|
|
|
:data => "#{thost}"
|
|
|
|
)
|
2010-02-08 13:53:50 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
print_status("NOT Found #{thost}")
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
else
|
2010-02-08 13:53:50 +00:00
|
|
|
print_status("[#{ip}] NO Response")
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
2010-02-08 13:53:50 +00:00
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
2010-02-08 13:53:50 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
end
|
2010-02-08 13:53:50 +00:00
|
|
|
|