2010-09-16 18:23:03 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2010-09-16 18:23:03 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'thread'
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex/proto/proxy/socks4a'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Auxiliary::Report
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Socks4a Proxy Server',
|
2011-04-18 18:17:49 +00:00
|
|
|
'Description' => 'This module provides a socks4a proxy server that uses the builtin Metasploit routing to relay connections.',
|
2010-09-16 18:23:03 +00:00
|
|
|
'Author' => 'sf',
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Actions' =>
|
|
|
|
[
|
2010-09-20 08:06:27 +00:00
|
|
|
[ 'Proxy' ]
|
2010-09-16 18:23:03 +00:00
|
|
|
],
|
|
|
|
'PassiveActions' =>
|
|
|
|
[
|
|
|
|
'Proxy'
|
|
|
|
],
|
|
|
|
'DefaultAction' => 'Proxy'
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new( 'SRVHOST', [ true, "The address to listen on", '0.0.0.0' ] ),
|
|
|
|
OptPort.new( 'SRVPORT', [ true, "The port to listen on.", 1080 ] )
|
|
|
|
], self.class )
|
|
|
|
end
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@mutex = ::Mutex.new
|
|
|
|
@socks4a = nil
|
|
|
|
end
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
def cleanup
|
|
|
|
@mutex.synchronize do
|
|
|
|
if( @socks4a )
|
|
|
|
print_status( "Stopping the socks4a proxy server" )
|
|
|
|
@socks4a.stop
|
|
|
|
@socks4a = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
super
|
|
|
|
end
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
def run
|
|
|
|
opts = {
|
|
|
|
'ServerHost' => datastore['SRVHOST'],
|
2011-04-18 18:17:49 +00:00
|
|
|
'ServerPort' => datastore['SRVPORT'],
|
|
|
|
'Context' => {'Msf' => framework, 'MsfExploit' => self}
|
2010-09-16 18:23:03 +00:00
|
|
|
}
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
@socks4a = Rex::Proto::Proxy::Socks4a.new( opts )
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
print_status( "Starting the socks4a proxy server" )
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
@socks4a.start
|
2010-09-20 08:06:27 +00:00
|
|
|
|
2010-09-16 18:23:03 +00:00
|
|
|
@socks4a.join
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|