Module: Msf::Handler::Reverse::Comm

Overview

Implements the reverse Rex::Socket::Comm handlng.

Instance Method Summary collapse

Instance Method Details

#initialize(info = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/msf/core/handler/reverse/comm.rb', line 15

def initialize(info = {})
  super

  register_advanced_options(
    [
      OptString.new('ReverseListenerComm', [ false, 'The specific communication channel to use for this listener']),
    ], Msf::Handler::Reverse::Comm)
end

#select_commObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/msf/core/handler/reverse/comm.rb', line 24

def select_comm
  rl_comm = datastore['ReverseListenerComm'].to_s
  case rl_comm
  when 'local'
    comm = ::Rex::Socket::Comm::Local
  when /\A-?[0-9]+\Z/
    comm = framework.sessions.get(rl_comm.to_i)
    raise(RuntimeError, "Reverse Listener Comm (Session #{rl_comm}) does not exist") unless comm
    raise(RuntimeError, "Reverse Listener Comm (Session #{rl_comm}) does not implement Rex::Socket::Comm") unless comm.is_a? ::Rex::Socket::Comm
  when nil, ''
    comm = nil
  else
    raise(RuntimeError, "Reverse Listener Comm '#{rl_comm}' is invalid")
  end

  comm
end

#via_string(comm) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/msf/core/handler/reverse/comm.rb', line 42

def via_string(comm)
  comm_used = comm
  comm_used ||= Rex::Socket::Comm::Local

  if comm_used.respond_to?(:type) && comm_used.respond_to?(:sid)
    via = "via the #{comm_used.type} on session #{comm_used.sid}"
  else
    via = ""
  end

  via
end