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

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

75 lines
2.1 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Report
include Msf::Exploit::Remote::SocketServer
def initialize
super(
2020-09-22 10:28:58 -04:00
'Name' => 'SOCKS Proxy Server',
'Description' => %q{
This module provides a SOCKS proxy server that uses the builtin Metasploit routing to relay connections.
},
2020-09-22 10:28:58 -04:00
'Author' => [ 'sf', 'Spencer McIntyre', 'surefire' ],
'License' => MSF_LICENSE,
2021-08-27 17:15:33 +01:00
'Actions' => [
[ 'Proxy', { 'Description' => 'Run a SOCKS proxy server' } ]
],
'PassiveActions' => [
'Proxy'
],
2020-09-22 10:28:58 -04:00
'DefaultAction' => 'Proxy'
)
register_options([
2020-09-22 10:28:58 -04:00
OptPort.new('SRVPORT', [true, 'The port to listen on', 1080]),
OptEnum.new('VERSION', [ true, 'The SOCKS version to use', '5', %w[4a 5] ]),
OptString.new('USERNAME', [false, 'Proxy username for SOCKS5 listener'], conditions: %w[VERSION == 5]),
OptString.new('PASSWORD', [false, 'Proxy password for SOCKS5 listener'], conditions: %w[VERSION == 5]),
])
end
def setup
super
@mutex = ::Mutex.new
@socks_proxy = nil
end
def cleanup
@mutex.synchronize do
if @socks_proxy
print_status('Stopping the SOCKS proxy server')
@socks_proxy.stop
@socks_proxy = nil
end
end
super
end
def run
opts = {
'ServerHost' => bindhost,
'ServerPort' => bindport,
'Comm' => _determine_server_comm(bindhost),
2020-09-22 10:28:58 -04:00
'Context' => { 'Msf' => framework, 'MsfExploit' => self }
}
if datastore['VERSION'] == '5'
opts.merge!({
'ServerUsername' => datastore['USERNAME'],
'ServerPassword' => datastore['PASSWORD']
})
@socks_proxy = Rex::Proto::Proxy::Socks5::Server.new(opts)
elsif datastore['VERSION'] == '4a'
@socks_proxy = Rex::Proto::Proxy::Socks4a.new(opts)
end
print_status('Starting the SOCKS proxy server')
@socks_proxy.start
@socks_proxy.join
end
end