@@ -25,7 +25,7 @@ module Meterpreter
25
25
#
26
26
###
27
27
class ClientCore < Extension
28
-
28
+
29
29
METERPRETER_TRANSPORT_TCP = 0
30
30
METERPRETER_TRANSPORT_HTTP = 1
31
31
METERPRETER_TRANSPORT_HTTPS = 2
@@ -710,7 +710,7 @@ def migrate(target_pid, writable_dir = nil, opts = {})
710
710
711
711
# Renegotiate TLV encryption on the migrated session
712
712
secure
713
-
713
+
714
714
# Load all the extensions that were loaded in the previous instance (using the correct platform/binary_suffix)
715
715
client . ext . aliases . keys . each { |e |
716
716
client . core . use ( e )
@@ -768,9 +768,16 @@ def negotiate_tlv_encryption(timeout: client.comm_timeout)
768
768
response = client . send_request ( request , timeout )
769
769
key_enc = response . get_tlv_value ( TLV_TYPE_ENC_SYM_KEY )
770
770
key_type = response . get_tlv_value ( TLV_TYPE_SYM_KEY_TYPE )
771
-
771
+ is_weak_key = false
772
772
if key_enc
773
- sym_key = rsa_key . private_decrypt ( key_enc , OpenSSL ::PKey ::RSA ::PKCS1_PADDING )
773
+ key_dec_data = rsa_key . private_decrypt ( key_enc , OpenSSL ::PKey ::RSA ::PKCS1_PADDING )
774
+
775
+ if key_dec_data . length == 17 || key_dec_data . length == 33
776
+ sym_key = key_dec_data [ 0 , key_dec_data . length - 1 ]
777
+ is_weak_key = key_dec_data [ key_dec_data . length - 1 ] == "\x01 "
778
+ else
779
+ sym_key = key_dec_data
780
+ end
774
781
else
775
782
sym_key = response . get_tlv_value ( TLV_TYPE_SYM_KEY )
776
783
end
@@ -781,7 +788,8 @@ def negotiate_tlv_encryption(timeout: client.comm_timeout)
781
788
782
789
{
783
790
key : sym_key ,
784
- type : key_type
791
+ type : key_type ,
792
+ is_weak_key : is_weak_key
785
793
}
786
794
end
787
795
0 commit comments