1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-18 15:14:10 +01:00

Fix python3 support for the session GUID header

Updates the code so that the GUID is handled as a hex-encoded value,
just like the payload UUID. This avoids what appeared to be encoding
issues when the value was packed into the header, resulting in more than
16 bytes appearing and hence screwing it all up!
This commit is contained in:
OJ 2017-06-28 17:57:07 +10:00
parent 60c751c27d
commit eeeecd7234
No known key found for this signature in database
GPG Key ID: D5DC61FB93260597

@ -545,7 +545,7 @@ class Transport(object):
# always return the session guid and the encryption flag set to 0 # always return the session guid and the encryption flag set to 0
# TODO: we'll add encryption soon! # TODO: we'll add encryption soon!
xor_key = rand_xor_key() xor_key = rand_xor_key()
raw = bytes(SESSION_GUID, 'UTF-8') + NULL_BYTE + pkt raw = binascii.a2b_hex(bytes(SESSION_GUID, 'UTF-8')) + NULL_BYTE + pkt
result = struct.pack('BBBB', *xor_key) + xor_bytes(xor_key, raw) result = struct.pack('BBBB', *xor_key) + xor_bytes(xor_key, raw)
return result return result
@ -937,13 +937,13 @@ class PythonMeterpreter(object):
return ERROR_SUCCESS, response return ERROR_SUCCESS, response
def _core_get_session_guid(self, request, response): def _core_get_session_guid(self, request, response):
response += tlv_pack(TLV_TYPE_SESSION_GUID, SESSION_GUID) response += tlv_pack(TLV_TYPE_SESSION_GUID, binascii.a2b_hex(bytes(SESSION_GUID, 'UTF-8')))
return ERROR_SUCCESS, response return ERROR_SUCCESS, response
def _core_set_session_guid(self, request, response): def _core_set_session_guid(self, request, response):
new_guid = packet_get_tlv(request, TLV_TYPE_SESSION_GUID) new_guid = packet_get_tlv(request, TLV_TYPE_SESSION_GUID)
if new_guid: if new_guid:
SESSION_GUID = new_guid['value'] SESSION_GUID = binascii.b2a_hex(new_guid['value'])
return ERROR_SUCCESS, response return ERROR_SUCCESS, response
def _core_machine_id(self, request, response): def _core_machine_id(self, request, response):