metasploit-framework/modules/auxiliary/server/socks4a.rb

70 lines
1.5 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'thread'
require 'rex/proto/proxy/socks4a'
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Auxiliary
2013-08-30 21:28:54 +00:00
include Msf::Auxiliary::Report
2013-08-30 21:28:54 +00:00
def initialize
super(
'Name' => 'Socks4a Proxy Server',
'Description' => 'This module provides a socks4a proxy server that uses the builtin Metasploit routing to relay connections.',
'Author' => 'sf',
'License' => MSF_LICENSE,
'Actions' =>
[
[ 'Proxy' ]
],
'PassiveActions' =>
[
'Proxy'
],
'DefaultAction' => 'Proxy'
)
2013-08-30 21:28:54 +00:00
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 ] )
])
2013-08-30 21:28:54 +00:00
end
2013-08-30 21:28:54 +00:00
def setup
super
@mutex = ::Mutex.new
@socks4a = nil
end
2013-08-30 21:28:54 +00:00
def cleanup
@mutex.synchronize do
if( @socks4a )
print_status( "Stopping the socks4a proxy server" )
@socks4a.stop
@socks4a = nil
end
end
super
end
2013-08-30 21:28:54 +00:00
def run
opts = {
'ServerHost' => datastore['SRVHOST'],
'ServerPort' => datastore['SRVPORT'],
'Context' => {'Msf' => framework, 'MsfExploit' => self}
}
2013-08-30 21:28:54 +00:00
@socks4a = Rex::Proto::Proxy::Socks4a.new( opts )
2013-08-30 21:28:54 +00:00
print_status( "Starting the socks4a proxy server" )
2013-08-30 21:28:54 +00:00
@socks4a.start
2013-08-30 21:28:54 +00:00
@socks4a.join
end
end