Skip to content

Commit 48c50a8

Browse files
David MaloneyDavid Maloney
authored andcommitted
add rpc call to change meterp transport
this rpc method allows the user to change transport on an existing meterp session. if it's successful it will close the old 'session' tied to the rpevious transport MSP-12722
1 parent c1b8cee commit 48c50a8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,37 @@ 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+
# @option opts [String] :transport The transport protocol to use (e.g. reverse_tcp, reverse_http, bind_tcp etc)
401+
# @option opts [String] :lhost The LHOST of the listener to use
402+
# @option opts [String] :lport The LPORT of the listener to use
403+
# @option opts [String] :ua The User Agent String to use for reverse_http(s)
404+
# @option opts [String] :proxy_host The address of the proxy to route transport through
405+
# @option opts [String] :proxy_port The port the proxy is listening on
406+
# @option opts [String] :proxy_type The type of proxy to use
407+
# @option opts [String] :proxy_user The username to authenticate to the proxy with
408+
# @option opts [String] :proxy_pass The password to authenticate to the proxy with
409+
# @option opts [String] :comm_timeout Connection timeout in seconds
410+
# @option opts [String] :session_exp Session Expiration Timeout
411+
# @option opts [String] :retry_total Total number of times to retry etsablishing the transport
412+
# @option opts [String] :retry_wait The number of seconds to wait between retries
413+
# @option opts [String] :cert Path to the SSL Cert to use for HTTPS
414+
# @return [Boolean] whether the transport was changed successfully
415+
def rpc_meterpreter_transport_change(sid,opts={})
416+
session = _valid_session(sid,"meterpreter")
417+
real_opts = {}
418+
opts.each_pair do |key, value|
419+
real_opts[key.to_sym] = value
420+
end
421+
real_opts[:uuid] = session.payload_uuid
422+
result = session.core.transport_change(real_opts)
423+
if result == true
424+
rpc_stop(sid)
425+
end
426+
result
427+
end
428+
398429

399430
# Returns the separator used by the meterpreter.
400431
#

0 commit comments

Comments
 (0)