metasploit-framework/modules/auxiliary/scanner/http/mod_negotiation_scanner.rb

69 lines
1.8 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
2016-03-07 08:56:58 +00:00
class Metasploit < Msf::Auxiliary
2013-08-30 21:28:54 +00:00
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Scanner
2013-08-30 21:28:54 +00:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Apache HTTPD mod_negotiation Scanner',
'Description' => %q{
This module scans the webserver of the given host(s) for the existence of mod_negotiate.
If the webserver has mod_negotiation enabled, the IP address will be displayed.
},
'Author' => [ 'diablohorn [at] gmail.com' ],
'License' => MSF_LICENSE))
2013-08-30 21:28:54 +00:00
register_options(
[
OptString.new('PATH', [ true, "The path to detect mod_negotiation", '/']),
OptString.new('FILENAME',[true, "Filename to use as a test",'index'])
], self.class)
end
2013-08-30 21:28:54 +00:00
def run_host(ip)
ecode = nil
emesg = nil
2013-08-30 21:28:54 +00:00
tpath = datastore['PATH']
tfile = datastore['FILENAME']
2013-08-30 21:28:54 +00:00
if tpath[-1,1] != '/'
tpath += '/'
end
2013-08-30 21:28:54 +00:00
vhost = datastore['VHOST'] || ip
prot = datastore['SSL'] ? 'https' : 'http'
2013-08-30 21:28:54 +00:00
#
# Send the request and parse the response headers for an alternates header
#
begin
# Send the request the accept header is key here
res = send_request_cgi({
'uri' => tpath+tfile,
'method' => 'GET',
'ctype' => 'text/html',
'headers' => {'Accept' => 'a/b'}
}, 20)
2013-08-30 21:28:54 +00:00
return if not res
2013-08-30 21:28:54 +00:00
# Sheck for alternates header
if(res.code == 406)
print_status(ip.to_s)
end
2013-08-30 21:28:54 +00:00
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
rescue ::Timeout::Error, ::Errno::EPIPE
end
2013-08-30 21:28:54 +00:00
end
end