Skip to content

Commit 3b78302

Browse files
committed
Land rapid7#9327, restore transport enum used in TLVs
2 parents 5fe9dba + 9719ede commit 3b78302

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

lib/rex/post/meterpreter/client_core.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ module Meterpreter
3434
###
3535
class ClientCore < Extension
3636

37-
VALID_TRANSPORTS = [
38-
'reverse_tcp',
39-
'reverse_http',
40-
'reverse_https',
41-
'bind_tcp'
42-
]
37+
METERPRETER_TRANSPORT_TCP = 0
38+
METERPRETER_TRANSPORT_HTTP = 1
39+
METERPRETER_TRANSPORT_HTTPS = 2
40+
41+
VALID_TRANSPORTS = {
42+
'reverse_tcp' => METERPRETER_TRANSPORT_TCP,
43+
'reverse_http' => METERPRETER_TRANSPORT_HTTP,
44+
'reverse_https' => METERPRETER_TRANSPORT_HTTPS,
45+
'bind_tcp' => METERPRETER_TRANSPORT_TCP
46+
}
4347

4448
include Rex::Payloads::Meterpreter::UriChecksum
4549

@@ -721,7 +725,7 @@ def shutdown
721725
#
722726
def valid_transport?(transport)
723727
return false if transport.nil?
724-
VALID_TRANSPORTS.include?(transport.downcase)
728+
VALID_TRANSPORTS.has_key?(transport.downcase)
725729
end
726730

727731
#
@@ -875,7 +879,7 @@ def transport_prepare_request(method, opts={})
875879
opts[:ua] ||= 'Mozilla/4.0 (compatible; MSIE 6.1; Windows NT)'
876880
request.add_tlv(TLV_TYPE_TRANS_UA, opts[:ua])
877881

878-
if transport == 'reverse_https' && opts[:cert]
882+
if transport == 'reverse_https' && opts[:cert] # currently only https transport offers ssl
879883
hash = Rex::Socket::X509Certificate.get_cert_file_hash(opts[:cert])
880884
request.add_tlv(TLV_TYPE_TRANS_CERT_HASH, hash)
881885
end
@@ -896,7 +900,7 @@ def transport_prepare_request(method, opts={})
896900

897901
end
898902

899-
request.add_tlv(TLV_TYPE_TRANS_TYPE, transport)
903+
request.add_tlv(TLV_TYPE_TRANS_TYPE, VALID_TRANSPORTS[transport])
900904
request.add_tlv(TLV_TYPE_TRANS_URL, url)
901905

902906
request

lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def cmd_sleep(*args)
758758
# Arguments for transport switching
759759
#
760760
@@transport_opts = Rex::Parser::Arguments.new(
761-
'-t' => [true, "Transport type: #{Rex::Post::Meterpreter::ClientCore::VALID_TRANSPORTS.join(', ')}"],
761+
'-t' => [true, "Transport type: #{Rex::Post::Meterpreter::ClientCore::VALID_TRANSPORTS.keys.join(', ')}"],
762762
'-l' => [true, 'LHOST parameter (for reverse transports)'],
763763
'-p' => [true, 'LPORT parameter'],
764764
'-i' => [true, 'Specify transport by index (currently supported: remove)'],

0 commit comments

Comments
 (0)