@@ -129,6 +129,12 @@ module Meterpreter
129
129
LOAD_LIBRARY_FLAG_EXTENSION = ( 1 << 1 )
130
130
LOAD_LIBRARY_FLAG_LOCAL = ( 1 << 2 )
131
131
132
+ #
133
+ # Sane defaults
134
+ #
135
+ GUID_SIZE = 16
136
+ NULL_GUID = "\x00 " * GUID_SIZE
137
+
132
138
###
133
139
#
134
140
# Base TLV (Type-Length-Value) class
@@ -670,13 +676,10 @@ class Packet < GroupTlv
670
676
###
671
677
672
678
XOR_KEY_SIZE = 4
673
- SESSION_GUID_SIZE = 16
674
679
ENCRYPTED_FLAGS_SIZE = 4
675
680
PACKET_LENGTH_SIZE = 4
676
681
PACKET_TYPE_SIZE = 4
677
- PACKET_HEADER_SIZE = XOR_KEY_SIZE + SESSION_GUID_SIZE + ENCRYPTED_FLAGS_SIZE + PACKET_LENGTH_SIZE + PACKET_TYPE_SIZE
678
-
679
- SESSION_NULL_GUID = "\x00 " * SESSION_GUID_SIZE
682
+ PACKET_HEADER_SIZE = XOR_KEY_SIZE + GUID_SIZE + ENCRYPTED_FLAGS_SIZE + PACKET_LENGTH_SIZE + PACKET_TYPE_SIZE
680
683
681
684
AES_IV_SIZE = 16
682
685
@@ -804,7 +807,7 @@ def aes_decrypt(key, iv, data)
804
807
def to_r ( session_guid = nil , key = nil )
805
808
xor_key = ( rand ( 254 ) + 1 ) . chr + ( rand ( 254 ) + 1 ) . chr + ( rand ( 254 ) + 1 ) . chr + ( rand ( 254 ) + 1 ) . chr
806
809
807
- raw = ( session_guid || SESSION_NULL_GUID ) . dup
810
+ raw = ( session_guid || NULL_GUID ) . dup
808
811
tlv_data = GroupTlv . instance_method ( :to_r ) . bind ( self ) . call
809
812
810
813
if key && key [ :key ] && key [ :type ] == ENC_FLAG_AES256
@@ -836,7 +839,7 @@ def decrypt_packet(key, encrypt_flags, data)
836
839
end
837
840
838
841
def parse_header!
839
- xor_key = self . raw . unpack ( 'A4 ' ) [ 0 ]
842
+ xor_key = self . raw . unpack ( 'a4 ' ) [ 0 ]
840
843
data = xor_bytes ( xor_key , self . raw [ 0 ..PACKET_HEADER_SIZE ] )
841
844
_ , self . session_guid , self . encrypt_flags , self . length , self . type = data . unpack ( 'a4a16NNN' )
842
845
end
0 commit comments