1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-26 17:41:08 +01:00

check for invalid parameter in read/write memory

This commit is contained in:
Alex Romero 2023-04-25 19:28:42 -04:00
parent 4f12dd814b
commit dbf1916a65
No known key found for this signature in database

View File

@ -1670,6 +1670,9 @@ def stdapi_sys_process_memory_read(request, response):
base = packet_get_tlv(request, TLV_TYPE_BASE_ADDRESS).get('value', 0)
size = packet_get_tlv(request, TLV_TYPE_LENGTH).get('value', 0)
if not (handle and base and size):
return ERROR_INVALID_PARAMETER, response
ReadProcessMemory = ctypes.windll.kernel32.ReadProcessMemory
ReadProcessMemory.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t, ctypes.POINTER(ctypes.c_size_t)]
ReadProcessMemory.restype = ctypes.c_bool
@ -1690,6 +1693,9 @@ def stdapi_sys_process_memory_write(request, response):
base = packet_get_tlv(request, TLV_TYPE_BASE_ADDRESS).get('value', 0)
data = packet_get_tlv(request, TLV_TYPE_PROCESS_MEMORY).get('value', 0)
if not (handle and base and data):
return ERROR_INVALID_PARAMETER, response
WriteProcessMemory = ctypes.windll.kernel32.WriteProcessMemory
WriteProcessMemory.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t, ctypes.POINTER(ctypes.c_size_t)]
WriteProcessMemory.restype = ctypes.c_bool