Module: Msf::Handler::Reverse
- Includes:
- Bind
- Included in:
- ReverseHttp, ReverseSctp, ReverseSsh, ReverseTcp, ReverseTcpDouble, ReverseTcpDoubleSSL
- Defined in:
- lib/msf/core/handler/reverse.rb,
lib/msf/core/handler/reverse/ssl.rb,
lib/msf/core/handler/reverse/bind.rb,
lib/msf/core/handler/reverse/comm.rb
Overview
Options and methods needed for all handlers that listen for a connection from the payload.
Defined Under Namespace
Instance Method Summary collapse
- #bind_port ⇒ Integer
- #initialize(info = {}) ⇒ Object
-
#setup_handler ⇒ Object
Starts the listener but does not actually attempt to accept a connection.
Methods included from Bind
#bind_addresses, #is_loopback_address?
Instance Method Details
#bind_port ⇒ Integer
30 31 32 33 |
# File 'lib/msf/core/handler/reverse.rb', line 30 def bind_port port = datastore['ReverseListenerBindPort'].to_i (port > 0) ? port : datastore['LPORT'].to_i end |
#initialize(info = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/msf/core/handler/reverse.rb', line 12 def initialize(info = {}) super ( [ Msf::OptAddressOrHostname.new('LHOST', [true, 'The listen address (an interface may be specified)']), Opt::LPORT(4444) ], Msf::Handler::Reverse) ( [ OptPort.new('ReverseListenerBindPort', [false, 'The port to bind to on the local system if different from LPORT']), OptBool.new('ReverseAllowProxy', [ true, 'Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST', false]), ], Msf::Handler::Reverse ) end |
#setup_handler ⇒ Object
Starts the listener but does not actually attempt to accept a connection. Throws socket exceptions if it fails to start the listener.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/msf/core/handler/reverse.rb', line 40 def setup_handler if !datastore['Proxies'].blank? && !datastore['ReverseAllowProxy'] raise RuntimeError, "TCP connect-back payloads cannot be used with Proxies. Use 'set ReverseAllowProxy true' to override this behaviour." end ex = false comm = select_comm local_port = bind_port bind_addresses.each do |ip| begin self.listener_sock = Rex::Socket::TcpServer.create( 'LocalHost' => ip, 'LocalPort' => local_port, 'Comm' => comm, 'Context' => { 'Msf' => framework, 'MsfPayload' => self, 'MsfExploit' => assoc_exploit }) rescue ex = $! print_error("Handler failed to bind to #{ip}:#{local_port}:- #{comm} -") else ex = false via = via_string(self.listener_sock.client) if self.listener_sock.respond_to?(:client) print_status("Started #{human_name} handler on #{ip}:#{local_port} #{via}") break end end raise ex if (ex) end |