2010-04-30 08:40:19 +00:00
|
|
|
##
|
2012-03-01 22:54:04 +00:00
|
|
|
# $Id$
|
2010-04-30 08:40:19 +00:00
|
|
|
##
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
##
|
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
|
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'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2012-02-03 21:43:21 +00:00
|
|
|
include Msf::Auxiliary::WmapScanDir
|
2009-12-30 22:24:22 +00:00
|
|
|
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 File Same Name Directory Scanner',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module identifies the existence of files
|
|
|
|
in a given directory path named as the same name of the
|
2009-12-30 22:24:22 +00:00
|
|
|
directory.
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
Only works if PATH is differenet than '/'.
|
2009-12-30 22:24:22 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'et [at] metasploit.com' ],
|
|
|
|
'License' => BSD_LICENSE,
|
2012-03-01 22:59:54 +00:00
|
|
|
'Version' => '$Revision$'))
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "The directory path to identify files", '/']),
|
2011-02-04 05:57:26 +00:00
|
|
|
OptString.new('EXT', [ true, "File extension to use", '.aspx']),
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
], self.class)
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
2010-04-30 08:40:19 +00:00
|
|
|
extensions = [
|
|
|
|
'.null',
|
2009-12-30 22:24:22 +00:00
|
|
|
'.backup',
|
|
|
|
'.bak',
|
|
|
|
'.c',
|
2011-02-04 05:57:26 +00:00
|
|
|
'.cfg',
|
2009-12-30 22:24:22 +00:00
|
|
|
'.class',
|
|
|
|
'.copy',
|
|
|
|
'.conf',
|
|
|
|
'.exe',
|
|
|
|
'.html',
|
|
|
|
'.htm',
|
|
|
|
'.log',
|
2010-04-30 08:40:19 +00:00
|
|
|
'.old',
|
2009-12-30 22:24:22 +00:00
|
|
|
'.orig',
|
2011-02-04 05:57:26 +00:00
|
|
|
'.php',
|
2009-12-30 22:24:22 +00:00
|
|
|
'.tar',
|
|
|
|
'.tar.gz',
|
|
|
|
'.tgz',
|
2011-02-04 05:57:26 +00:00
|
|
|
'.tmp',
|
2009-12-30 22:24:22 +00:00
|
|
|
'.temp',
|
|
|
|
'.txt',
|
|
|
|
'.zip',
|
|
|
|
'~',
|
|
|
|
''
|
|
|
|
]
|
|
|
|
|
|
|
|
tpath = datastore['PATH']
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if tpath.eql? "/"||""
|
|
|
|
print_error("Blank or default PATH set.");
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if tpath[-1,1] != '/'
|
|
|
|
tpath += '/'
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
testf = tpath.split('/').last
|
|
|
|
|
|
|
|
extensions << datastore['EXT']
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
extensions.each { |ext|
|
|
|
|
begin
|
|
|
|
testfext = testf.chomp + ext
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => tpath+testfext,
|
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/plain'
|
|
|
|
}, 20)
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
if (res and res.code >= 200 and res.code < 300)
|
2009-12-30 22:24:22 +00:00
|
|
|
print_status("Found #{wmap_base_url}#{tpath}#{testfext}")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2012-02-21 20:13:12 +00:00
|
|
|
report_web_vuln(
|
2009-12-30 22:24:22 +00:00
|
|
|
:host => ip,
|
|
|
|
:port => rport,
|
2012-02-21 20:13:12 +00:00
|
|
|
:vhost => vhost,
|
|
|
|
:ssl => ssl,
|
|
|
|
:path => "#{tpath}#{testfext}",
|
|
|
|
:method => 'GET',
|
|
|
|
:pname => "",
|
|
|
|
:proof => "Res code: #{res.code.to_s}",
|
|
|
|
:risk => 0,
|
|
|
|
:confidence => 100,
|
|
|
|
:category => 'file',
|
|
|
|
:description => 'File found.',
|
|
|
|
:name => 'file'
|
2009-12-30 22:24:22 +00:00
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
else
|
2011-07-15 15:33:35 +00:00
|
|
|
vprint_status("NOT Found #{wmap_base_url}#{tpath}#{testfext}")
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
2010-04-30 08:40:19 +00:00
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
}
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
end
|