Files
metasploit-gs/modules/auxiliary/scanner/http/file_same_name_dir.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

119 lines
2.6 KiB
Ruby
Raw Normal View History

2009-12-30 22:24:22 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2009-12-30 22:24:22 +00:00
##
2021-01-28 10:35:25 +00:00
2009-12-30 22:24:22 +00:00
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
2009-12-30 22:24:22 +00:00
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::WmapScanDir
2009-12-30 22:24:22 +00:00
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
def initialize(info = {})
super(update_info(info,
2009-12-30 22:24:22 +00:00
'Name' => 'HTTP File Same Name Directory Scanner',
'Description' => %q{
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.
2013-08-30 16:28:54 -05:00
2017-08-26 21:01:10 -04:00
Only works if PATH is different than '/'.
2009-12-30 22:24:22 +00:00
},
'Author' => [ 'et [at] metasploit.com' ],
2013-01-03 01:05:45 +01:00
'License' => BSD_LICENSE))
2013-08-30 16:28:54 -05: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']),
2013-08-30 16:28:54 -05:00
])
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
end
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
def run_host(ip)
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',
'.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',
'~',
''
]
2013-08-30 16:28:54 -05:00
2012-11-08 17:42:48 +01:00
tpath = normalize_uri(datastore['PATH'])
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
if tpath.eql? "/"||""
print_error("Blank or default PATH set.");
return
end
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
if tpath[-1,1] != '/'
tpath += '/'
end
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
testf = tpath.split('/').last
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
extensions << datastore['EXT']
2013-08-30 16:28:54 -05: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)
2013-08-30 16:28:54 -05:00
if (res and res.code >= 200 and res.code < 300)
print_good("Found #{wmap_base_url}#{tpath}#{testfext}")
2013-08-30 16:28:54 -05:00
report_web_vuln(
2009-12-30 22:24:22 +00:00
:host => ip,
:port => rport,
: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
)
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
else
vprint_status("NOT Found #{wmap_base_url}#{tpath}#{testfext}")
2009-12-30 22:24:22 +00:00
end
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
rescue ::Timeout::Error, ::Errno::EPIPE
2009-12-30 22:24:22 +00:00
end
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
}
2013-08-30 16:28:54 -05:00
2009-12-30 22:24:22 +00:00
end
end