2009-12-30 22:24:22 +00:00
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# 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 Directory Listing Scanner',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module identifies directory listing vulnerabilities
|
|
|
|
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(
|
|
|
|
[
|
2011-02-04 05:57:26 +00:00
|
|
|
OptString.new('PATH', [ true, "The path to identify directoy listing", '/']),
|
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
|
|
|
|
|
|
|
tpath = datastore['PATH']
|
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
|
|
|
|
|
|
|
begin
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => tpath,
|
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/plain'
|
|
|
|
}, 20)
|
|
|
|
|
|
|
|
if (res and res.code >= 200 and res.code < 300)
|
|
|
|
if res.to_s.include? "<title>Index of /" and res.to_s.include? "<h1>Index of /"
|
2010-09-20 08:06:27 +00:00
|
|
|
print_status("Found Directory Listing #{wmap_base_url}#{tpath}")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'tcp',
|
2011-02-22 20:49:44 +00:00
|
|
|
:sname => 'HTTP',
|
2009-12-30 22:24:22 +00:00
|
|
|
:port => rport,
|
|
|
|
:type => 'DIR_LISTING',
|
|
|
|
:data => "#{tpath}"
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if res.to_s.include? "[To Parent Directory]</A>" and res.to_s.include? "#{tpath}</H1><hr>"
|
2010-09-20 08:06:27 +00:00
|
|
|
print_status("Found Directory Listing #{wmap_base_url}#{tpath}")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'tcp',
|
2011-02-22 20:49:44 +00:00
|
|
|
:sname => 'HTTP',
|
2009-12-30 22:24:22 +00:00
|
|
|
:port => rport,
|
|
|
|
:type => 'DIR_LISTING',
|
|
|
|
:data => "#{tpath}"
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
else
|
2011-07-15 15:33:35 +00:00
|
|
|
vprint_status("NOT Vulnerable to directory listing #{wmap_base_url}#{tpath}")
|
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
|
|
|
|
end
|
|
|
|
end
|