Files
metasploit-gs/lib/msf/core/handler/reverse/comm.rb
T
2015-10-06 14:48:49 -05:00

46 lines
1.0 KiB
Ruby

# -*- coding: binary -*-
require 'rex/socket'
module Msf
module Handler
module Reverse
###
#
# Implements the reverse Rex::Socket::Comm handlng.
#
###
module Comm
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
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[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
end
end
end
end