2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +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'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::WMAPScanDir
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2009-12-30 22:24:22 +00:00
|
|
|
'Name' => 'HTTP Interesting File Scanner',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module identifies the existence of interesting files
|
|
|
|
in a given directory path.
|
2009-12-30 22:24:22 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'et' ],
|
|
|
|
'License' => BSD_LICENSE,
|
2010-04-30 08:40:19 +00:00
|
|
|
'Version' => '$Revision$'))
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "The path to identify files", '/']),
|
|
|
|
OptString.new('EXT', [ false, "Append file extension to use", '']),
|
2010-04-30 08:40:19 +00:00
|
|
|
OptPath.new('DICTIONARY', [ false, "Path of word dictionary to use",
|
2009-12-30 22:24:22 +00:00
|
|
|
File.join(Msf::Config.install_root, "data", "wmap", "wmap_files.txt")
|
|
|
|
]
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
], self.class)
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
register_advanced_options(
|
|
|
|
[
|
|
|
|
OptInt.new('ErrorCode', [ true, "The expected http code for non existant files", 404]),
|
2010-04-30 08:40:19 +00:00
|
|
|
OptPath.new('HTTP404Sigs', [ false, "Path of 404 signatures to use",
|
2009-12-30 22:24:22 +00:00
|
|
|
File.join(Msf::Config.install_root, "data", "wmap", "wmap_404s.txt")
|
|
|
|
]
|
|
|
|
),
|
|
|
|
OptBool.new('NoDetailMessages', [ false, "Do not display detailed test messages", true ]),
|
|
|
|
OptInt.new('TestThreads', [ true, "Number of test threads", 25])
|
2010-04-30 08:40:19 +00:00
|
|
|
], self.class)
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
conn = false
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
tpath = datastore['PATH']
|
2009-12-30 22:24:22 +00:00
|
|
|
if tpath[-1,1] != '/'
|
|
|
|
tpath += '/'
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
nt = datastore['TestThreads'].to_i
|
|
|
|
nt = 1 if nt == 0
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
dm = datastore['NoDetailMessages']
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
queue = []
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
File.open(datastore['DICTIONARY']).each do |testf|
|
|
|
|
queue << testf.strip
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
#
|
|
|
|
# Detect error code
|
2010-04-30 08:40:19 +00:00
|
|
|
#
|
|
|
|
ecode = datastore['ErrorCode'].to_i
|
2009-12-30 22:24:22 +00:00
|
|
|
begin
|
|
|
|
randfile = Rex::Text.rand_text_alpha(5).chomp
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => tpath+randfile+ datastore['EXT'],
|
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/html'
|
|
|
|
}, 20)
|
|
|
|
|
|
|
|
return if not res
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
tcode = res.code.to_i
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
# Look for a string we can signature on as well
|
|
|
|
if(tcode >= 200 and tcode <= 299)
|
|
|
|
File.open(datastore['HTTP404Sigs']).each do |str|
|
|
|
|
if(res.body.index(str))
|
|
|
|
emesg = str
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if(not emesg)
|
|
|
|
print_status("Using first 256 bytes of the response as 404 string")
|
|
|
|
emesg = res.body[0,256]
|
|
|
|
else
|
|
|
|
print_status("Using custom 404 string of '#{emesg}'")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
ecode = tcode
|
|
|
|
print_status("Using code '#{ecode}' as not found.")
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
2010-04-30 08:40:19 +00:00
|
|
|
conn = false
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
while(not queue.empty?)
|
|
|
|
t = []
|
2010-04-30 08:40:19 +00:00
|
|
|
1.upto(nt) do
|
2009-12-30 22:24:22 +00:00
|
|
|
t << Thread.new(queue.shift) do |testf|
|
|
|
|
Thread.current.kill if not testf
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
testfext = testf.chomp + datastore['EXT']
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => tpath+testfext,
|
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/plain'
|
|
|
|
}, 20)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if(not res or ((res.code.to_i == ecode) or (emesg and res.body.index(emesg))))
|
|
|
|
if dm == false
|
2010-04-30 08:40:19 +00:00
|
|
|
print_status("NOT Found #{wmap_base_url}#{tpath}#{testfext} #{res.code.to_i}")
|
2009-12-30 22:24:22 +00:00
|
|
|
#blah
|
|
|
|
end
|
|
|
|
else
|
2010-04-30 08:40:19 +00:00
|
|
|
if res.code.to_i == 400 and ecode != 400
|
|
|
|
print_error("Server returned an error code. #{wmap_base_url}#{tpath}#{testfext} #{res.code.to_i}")
|
2009-12-30 22:24:22 +00:00
|
|
|
else
|
|
|
|
print_status("Found #{wmap_base_url}#{tpath}#{testfext} #{res.code.to_i}")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'HTTP',
|
|
|
|
:port => rport,
|
|
|
|
:type => 'FILE',
|
|
|
|
:data => "#{tpath}#{testfext} Code: #{res.code}"
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
end
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
t.map{|x| x.join }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|