@@ -34,12 +34,16 @@ module Meterpreter
34
34
###
35
35
class ClientCore < Extension
36
36
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
+ }
43
47
44
48
include Rex ::Payloads ::Meterpreter ::UriChecksum
45
49
@@ -721,7 +725,7 @@ def shutdown
721
725
#
722
726
def valid_transport? ( transport )
723
727
return false if transport . nil?
724
- VALID_TRANSPORTS . include ?( transport . downcase )
728
+ VALID_TRANSPORTS . has_key ?( transport . downcase )
725
729
end
726
730
727
731
#
@@ -875,7 +879,7 @@ def transport_prepare_request(method, opts={})
875
879
opts [ :ua ] ||= 'Mozilla/4.0 (compatible; MSIE 6.1; Windows NT)'
876
880
request . add_tlv ( TLV_TYPE_TRANS_UA , opts [ :ua ] )
877
881
878
- if transport == 'reverse_https' && opts [ :cert ]
882
+ if transport == 'reverse_https' && opts [ :cert ] # currently only https transport offers ssl
879
883
hash = Rex ::Socket ::X509Certificate . get_cert_file_hash ( opts [ :cert ] )
880
884
request . add_tlv ( TLV_TYPE_TRANS_CERT_HASH , hash )
881
885
end
@@ -896,7 +900,7 @@ def transport_prepare_request(method, opts={})
896
900
897
901
end
898
902
899
- request . add_tlv ( TLV_TYPE_TRANS_TYPE , transport )
903
+ request . add_tlv ( TLV_TYPE_TRANS_TYPE , VALID_TRANSPORTS [ transport ] )
900
904
request . add_tlv ( TLV_TYPE_TRANS_URL , url )
901
905
902
906
request
0 commit comments