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

Fixed whitespace and replaced string buffers with unicode buffers for unicode functions

This commit is contained in:
ouahib-el-hanchi 2017-04-14 06:40:45 +01:00
parent 242d2bf936
commit dae985f66f

@ -241,24 +241,23 @@ if has_ctypes:
class UNIVERSAL_NAME_INFO(ctypes.Structure): class UNIVERSAL_NAME_INFO(ctypes.Structure):
_fields_ = [("lpUniversalName", ctypes.c_char_p)] _fields_ = [("lpUniversalName", ctypes.c_char_p)]
class EVENTLOGRECORD(ctypes.Structure): class EVENTLOGRECORD(ctypes.Structure):
_fields_ = [ _fields_ = [("Length", ctypes.c_uint32),
("Length", ctypes.c_uint32), ("Reserved", ctypes.c_uint32),
("Reserved", ctypes.c_uint32), ("RecordNumber", ctypes.c_uint32),
("RecordNumber", ctypes.c_uint32), ("TimeGenerated", ctypes.c_uint32),
("TimeGenerated", ctypes.c_uint32), ("TimeWritten", ctypes.c_uint32),
("TimeWritten", ctypes.c_uint32), ("EventID", ctypes.c_uint32),
("EventID", ctypes.c_uint32), ("EventType", ctypes.c_uint16),
("EventType", ctypes.c_uint16), ("NumStrings", ctypes.c_uint16),
("NumStrings", ctypes.c_uint16), ("EventCategory", ctypes.c_uint16),
("EventCategory", ctypes.c_uint16), ("ReservedFlags", ctypes.c_uint16),
("ReservedFlags", ctypes.c_uint16), ("ClosingRecordNumber", ctypes.c_uint32),
("ClosingRecordNumber", ctypes.c_uint32), ("StringOffset", ctypes.c_uint32),
("StringOffset", ctypes.c_uint32), ("UserSidLength", ctypes.c_uint32),
("UserSidLength", ctypes.c_uint32), ("UserSidOffset", ctypes.c_uint32),
("UserSidOffset", ctypes.c_uint32), ("DataLength", ctypes.c_uint32),
("DataLength", ctypes.c_uint32), ("DataOffset", ctypes.c_uint32)]
("DataOffset", ctypes.c_uint32)]
# #
# Linux Structures # Linux Structures
@ -1131,7 +1130,7 @@ def stdapi_sys_eventlog_read(request, response):
bytes_needed = ctypes.c_ulong(0) bytes_needed = ctypes.c_ulong(0)
if adv32.ReadEventLogW(handle, flags, offset, ctypes.byref(bytes_read), 0, ctypes.byref(bytes_read), ctypes.byref(bytes_needed)): if adv32.ReadEventLogW(handle, flags, offset, ctypes.byref(bytes_read), 0, ctypes.byref(bytes_read), ctypes.byref(bytes_needed)):
return error_result_windows(), response return error_result_windows(), response
buf = ctypes.create_string_buffer(bytes_needed.value) buf = ctypes.create_unicode_buffer(bytes_needed.value)
if not adv32.ReadEventLogW(handle, flags, offset, buf, bytes_needed, ctypes.byref(bytes_read), ctypes.byref(bytes_needed)): if not adv32.ReadEventLogW(handle, flags, offset, buf, bytes_needed, ctypes.byref(bytes_read), ctypes.byref(bytes_needed)):
return error_result_windows(), response return error_result_windows(), response
record = cstruct_unpack(EVENTLOGRECORD, buf) record = cstruct_unpack(EVENTLOGRECORD, buf)
@ -1361,7 +1360,7 @@ def stdapi_fs_mount_show(request, response):
mount += tlv_pack(TLV_TYPE_MOUNT_TYPE, drive_type) mount += tlv_pack(TLV_TYPE_MOUNT_TYPE, drive_type)
# Get UNC path for network drives # Get UNC path for network drives
if drive_type == DRIVE_REMOTE: if drive_type == DRIVE_REMOTE:
buf = ctypes.create_string_buffer(1024) buf = ctypes.create_unicode_buffer(1024)
bufsize = ctypes.c_ulong(1024) bufsize = ctypes.c_ulong(1024)
if mpr.WNetGetUniversalNameW(drive, UNIVERSAL_NAME_INFO_LEVEL, ctypes.byref(buf), ctypes.byref(bufsize)) == 0: if mpr.WNetGetUniversalNameW(drive, UNIVERSAL_NAME_INFO_LEVEL, ctypes.byref(buf), ctypes.byref(bufsize)) == 0:
pUniversalNameInfo = cstruct_unpack(UNIVERSAL_NAME_INFO, buf) pUniversalNameInfo = cstruct_unpack(UNIVERSAL_NAME_INFO, buf)