Files
metasploit-gs/lib/msf/core/handler/reverse/comm.rb
T

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

60 lines
1.3 KiB
Ruby
Raw Normal View History

2015-05-20 00:24:09 +01:00
# -*- coding: binary -*-
require 'rex/socket'
module Msf
module Handler
2015-10-06 14:48:49 -05:00
module Reverse
2015-05-20 00:24:09 +01:00
###
#
2015-10-06 14:48:49 -05:00
# Implements the reverse Rex::Socket::Comm handlng.
2015-05-20 00:24:09 +01:00
#
###
2015-10-06 14:48:49 -05:00
module Comm
2015-05-20 00:24:09 +01:00
def initialize(info = {})
super
register_advanced_options(
[
OptString.new('ReverseListenerComm', [ false, 'The specific communication channel to use for this listener']),
2015-10-06 14:48:49 -05:00
], Msf::Handler::Reverse::Comm)
2015-05-20 00:24:09 +01:00
end
def select_comm
rl_comm = datastore['ReverseListenerComm'].to_s
case rl_comm
when 'local'
comm = ::Rex::Socket::Comm::Local
2022-01-24 11:42:39 -05:00
when /\A-?[0-9]+\Z/
comm = framework.sessions.get(rl_comm.to_i)
2015-05-20 00:24:09 +01:00
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
2015-06-24 20:38:28 +01:00
when nil, ''
2015-05-20 00:24:09 +01:00
comm = nil
2015-06-24 20:38:28 +01:00
else
raise(RuntimeError, "Reverse Listener Comm '#{rl_comm}' is invalid")
2015-05-20 00:24:09 +01:00
end
comm
end
2015-10-16 15:08:00 -05:00
def via_string(comm)
2015-10-16 15:08:00 -05:00
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
2015-05-20 00:24:09 +01:00
end
end
end
2015-10-06 14:48:49 -05:00
end