2009-12-30 22:24:22 +00:00
|
|
|
##
|
2012-03-01 22:54:04 +00:00
|
|
|
# $Id$
|
2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
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
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'rex/proto/http'
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
#
|
|
|
|
# May I reuse some methods?
|
|
|
|
#
|
|
|
|
require 'cgi'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2012-02-03 21:43:21 +00:00
|
|
|
include Msf::Auxiliary::WmapScanServer
|
2009-12-30 22:24:22 +00:00
|
|
|
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,
|
2012-03-01 22:59:54 +00:00
|
|
|
'Version' => '$Revision$'))
|
2010-02-08 13:53:50 +00:00
|
|
|
|
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,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'tcp',
|
2012-02-18 04:59:48 +00:00
|
|
|
:sname => (ssl ? 'https' : 'http'),
|
2009-12-30 22:24:22 +00:00
|
|
|
:port => rport,
|
|
|
|
:type => 'VHOST',
|
2012-02-21 20:13:12 +00:00
|
|
|
:data => "#{thost}",
|
|
|
|
:update => :unique_data
|
2009-12-30 22:24:22 +00:00
|
|
|
)
|
2010-02-08 13:53:50 +00:00
|
|
|
|
|
|
|
else
|
2011-07-15 15:33:35 +00:00
|
|
|
vprint_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
|
|
|
|