Module: Msf::Handler::ReverseTcpSsl

Includes:
Msf::Handler::Reverse::SSL, ReverseTcp
Defined in:
lib/msf/core/handler/reverse_tcp_ssl.rb

Overview

This module implements the reverse TCP handler. This means that it listens on a port waiting for a connection until either one is established or it is told to abort.

This handler depends on having a local host and port to listen on.

Constant Summary

Constants included from Msf::Handler

Claimed, Unused

Instance Attribute Summary

Attributes included from ReverseTcp

#conn_threads, #handler_thread, #listener_sock, #listener_thread

Attributes included from Msf::Handler

#exploit_config, #parent_payload, #pending_connections, #session_waiter_event, #sessions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Msf::Handler::Reverse::SSL

#initialize

Methods included from ReverseTcp

#cleanup_handler, #human_name, #initialize, #listener_uri, #payload_uri, #start_handler, #stop_handler, #wrap_aes_socket

Methods included from Msf::Handler::Reverse::Comm

#initialize, #select_comm, #via_string_for_ip

Methods included from Reverse

#bind_addresses, #bind_port, #initialize, #is_loopback_address?

Methods included from Msf::Handler

#add_handler, #cleanup_handler, #create_session, #handle_connection, #handler, #handler_name, #initialize, #interrupt_wait_for_session, #register_session, #start_handler, #stop_handler, #wait_for_session, #wfs_delay

Class Method Details

.general_handler_typeObject

Returns the connection-described general handler type, in this case 'reverse'.


36
37
38
# File 'lib/msf/core/handler/reverse_tcp_ssl.rb', line 36

def self.general_handler_type
  "reverse"
end

.handler_typeObject

Returns the string representation of the handler type, in this case 'reverse_tcp_ssl'.


28
29
30
# File 'lib/msf/core/handler/reverse_tcp_ssl.rb', line 28

def self.handler_type
  return "reverse_tcp_ssl"
end

Instance Method Details

#setup_handlerObject

Starts the listener but does not actually attempt to accept a connection. Throws socket exceptions if it fails to start the listener.


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
74
75
76
77
78
79
80
# File 'lib/msf/core/handler/reverse_tcp_ssl.rb', line 45

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 { |ip|
    begin

      self.listener_sock = Rex::Socket::SslTcpServer.create(
        'LocalHost' => ip,
        'LocalPort' => local_port,
        'Comm'      => comm,
        'SSLCert'   => datastore['HandlerSSLCert'],
        'Context'   =>
          {
            'Msf'        => framework,
            'MsfPayload' => self,
            'MsfExploit' => assoc_exploit
          })

      ex = false

      via = via_string_for_ip(ip, comm)
      print_status("Started reverse SSL handler on #{ip}:#{local_port} #{via}")
      break
    rescue
      ex = $!
      print_error("Handler failed to bind to #{ip}:#{local_port}")
    end
  }
  raise ex if (ex)
end