@@ -37,21 +37,17 @@ class ClientCore < Extension
37
37
UNIX_PATH_MAX = 108
38
38
DEFAULT_SOCK_PATH = "/tmp/meterpreter.sock"
39
39
40
- METERPRETER_TRANSPORT_TCP = 0
41
- METERPRETER_TRANSPORT_HTTP = 1
42
- METERPRETER_TRANSPORT_HTTPS = 2
43
-
44
40
TIMEOUT_SESSION = 24 *3600 *7 # 1 week
45
41
TIMEOUT_COMMS = 300 # 5 minutes
46
42
TIMEOUT_RETRY_TOTAL = 60 *60 # 1 hour
47
43
TIMEOUT_RETRY_WAIT = 10 # 10 seconds
48
44
49
- VALID_TRANSPORTS = {
50
- 'reverse_tcp' => METERPRETER_TRANSPORT_TCP ,
51
- 'reverse_http' => METERPRETER_TRANSPORT_HTTP ,
52
- 'reverse_https' => METERPRETER_TRANSPORT_HTTPS ,
53
- 'bind_tcp' => METERPRETER_TRANSPORT_TCP
54
- }
45
+ VALID_TRANSPORTS = [
46
+ 'reverse_tcp' ,
47
+ 'reverse_http' ,
48
+ 'reverse_https' ,
49
+ 'bind_tcp'
50
+ ]
55
51
56
52
include Rex ::Payloads ::Meterpreter ::UriChecksum
57
53
@@ -722,11 +718,8 @@ def shutdown
722
718
# Indicates if the given transport is a valid transport option.
723
719
#
724
720
def valid_transport? ( transport )
725
- if transport
726
- VALID_TRANSPORTS . has_key? ( transport . downcase )
727
- else
728
- false
729
- end
721
+ return false if transport . nil?
722
+ VALID_TRANSPORTS . include? ( transport . downcase )
730
723
end
731
724
732
725
#
@@ -830,11 +823,11 @@ def transport_prepare_request(method, opts={})
830
823
opts [ :lhost ] = nil
831
824
end
832
825
833
- transport = VALID_TRANSPORTS [ opts [ :transport ] ]
826
+ transport = opts [ :transport ] . downcase
834
827
835
828
request = Packet . create_request ( method )
836
829
837
- scheme = opts [ : transport] . split ( '_' ) [ 1 ]
830
+ scheme = transport . split ( '_' ) [ 1 ]
838
831
url = "#{ scheme } ://#{ opts [ :lhost ] } :#{ opts [ :lport ] } "
839
832
840
833
if opts [ :luri ] && opts [ :luri ] . length > 0
@@ -864,7 +857,7 @@ def transport_prepare_request(method, opts={})
864
857
end
865
858
866
859
# do more magic work for http(s) payloads
867
- unless opts [ : transport] . ends_with? ( 'tcp' )
860
+ unless transport . ends_with? ( 'tcp' )
868
861
if opts [ :uri ]
869
862
url << '/' unless opts [ :uri ] . start_with? ( '/' )
870
863
url << opts [ :uri ]
@@ -878,7 +871,7 @@ def transport_prepare_request(method, opts={})
878
871
opts [ :ua ] ||= 'Mozilla/4.0 (compatible; MSIE 6.1; Windows NT)'
879
872
request . add_tlv ( TLV_TYPE_TRANS_UA , opts [ :ua ] )
880
873
881
- if transport == METERPRETER_TRANSPORT_HTTPS && opts [ :cert ]
874
+ if transport == 'reverse_https' && opts [ :cert ]
882
875
hash = Rex ::Socket ::X509Certificate . get_cert_file_hash ( opts [ :cert ] )
883
876
request . add_tlv ( TLV_TYPE_TRANS_CERT_HASH , hash )
884
877
end
0 commit comments