2011-01-21 22:26:33 +00:00
|
|
|
##
|
2013-10-15 18:50:46 +00:00
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-01-21 22:26:33 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# mod_negotiation bruter
|
|
|
|
# http://httpd.apache.org/docs/1.3/content-negotiation.html
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Scanner
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Apache HTTPD mod_negotiation Filename Bruter',
|
|
|
|
'Description' => %q{
|
|
|
|
This module performs a brute force attack in order to discover existing files on a
|
|
|
|
server which uses mod_negotiation. If the filename is found, the IP address and the
|
|
|
|
files found will be displayed.
|
|
|
|
},
|
|
|
|
'Author' => [ 'diablohorn [at] gmail.com' ],
|
|
|
|
'License' => MSF_LICENSE))
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "The path to detect mod_negotiation", '/']),
|
|
|
|
OptPath.new('FILEPATH',[true, "path to file with file names",
|
2013-09-26 19:34:48 +00:00
|
|
|
File.join(Msf::Config.data_directory, "wmap", "wmap_files.txt")])
|
2013-08-30 21:28:54 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run_host(ip)
|
|
|
|
ecode = nil
|
|
|
|
emesg = nil
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
tpath = normalize_uri(datastore['PATH'])
|
|
|
|
tfile = datastore['FILEPATH']
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
if tpath[-1,1] != '/'
|
|
|
|
tpath += '/'
|
|
|
|
end
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
#load the file with filenames into memory
|
|
|
|
queue = []
|
|
|
|
File.open(datastore['FILEPATH'], 'rb').each_line do |fn|
|
|
|
|
queue << fn.strip
|
|
|
|
end
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
vhost = datastore['VHOST'] || ip
|
|
|
|
prot = datastore['SSL'] ? 'https' : 'http'
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
#
|
|
|
|
# Send the request and parse the response headers for an alternates header
|
|
|
|
#
|
|
|
|
begin
|
|
|
|
queue.each do |dirname|
|
|
|
|
reqpath = tpath+dirname
|
|
|
|
# Send the request the accept header is key here
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => reqpath,
|
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/html',
|
|
|
|
'headers' => {'Accept' => 'a/b'}
|
|
|
|
}, 20)
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
return if not res
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Check for alternates header and parse them
|
|
|
|
if(res.code == 406)
|
|
|
|
chunks = res.headers.to_s.scan(/"(.*?)"/i).flatten
|
|
|
|
chunks.each do |chunk|
|
|
|
|
chunk = chunk.to_s
|
|
|
|
print_status("#{ip} #{tpath}#{chunk}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
2011-01-21 22:26:33 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2011-01-21 22:26:33 +00:00
|
|
|
end
|