Skip to content

Commit 8f747d2

Browse files
author
Brent Cook
committed
Land rapid7#5382, add meterpreter session reconnect RPC call
2 parents fc61f1a + 356f361 commit 8f747d2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lib/msf/core/rpc/v10/rpc_session.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,38 @@ def rpc_meterpreter_script( sid, data)
395395
rpc_meterpreter_run_single( sid, "run #{data}")
396396
end
397397

398+
# Changes the Transport of a given Meterpreter Session
399+
#
400+
# @param sid [Fixnum] The Session ID of the `Msf::Session`
401+
# @option opts [String] :transport The transport protocol to use (e.g. reverse_tcp, reverse_http, bind_tcp etc)
402+
# @option opts [String] :lhost The LHOST of the listener to use
403+
# @option opts [String] :lport The LPORT of the listener to use
404+
# @option opts [String] :ua The User Agent String to use for reverse_http(s)
405+
# @option opts [String] :proxy_host The address of the proxy to route transport through
406+
# @option opts [String] :proxy_port The port the proxy is listening on
407+
# @option opts [String] :proxy_type The type of proxy to use
408+
# @option opts [String] :proxy_user The username to authenticate to the proxy with
409+
# @option opts [String] :proxy_pass The password to authenticate to the proxy with
410+
# @option opts [String] :comm_timeout Connection timeout in seconds
411+
# @option opts [String] :session_exp Session Expiration Timeout
412+
# @option opts [String] :retry_total Total number of times to retry etsablishing the transport
413+
# @option opts [String] :retry_wait The number of seconds to wait between retries
414+
# @option opts [String] :cert Path to the SSL Cert to use for HTTPS
415+
# @return [Boolean] whether the transport was changed successfully
416+
def rpc_meterpreter_transport_change(sid,opts={})
417+
session = _valid_session(sid,"meterpreter")
418+
real_opts = {}
419+
opts.each_pair do |key, value|
420+
real_opts[key.to_sym] = value
421+
end
422+
real_opts[:uuid] = session.payload_uuid
423+
result = session.core.transport_change(real_opts)
424+
if result == true
425+
rpc_stop(sid)
426+
end
427+
result
428+
end
429+
398430

399431
# Returns the separator used by the meterpreter.
400432
#

0 commit comments

Comments
 (0)