refactor: fix a bug and cleanup

This commit is contained in:
Dobin
2024-03-16 14:16:39 +00:00
parent 057f85e2bc
commit 2e491272c9
4 changed files with 18 additions and 6 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ Code section size : {sect_size}
''')
offset = int((sect_size - len(self.shellcodeData)) / 2)
logger.debug(f'Inserting shellcode into 0x{offset:X} offset.')
logger.info(f'Inserting shellcode into 0x{offset:X} offset.')
self.superpe.pe.set_bytes_at_offset(offset, self.shellcodeData)
self.shellcodeOffset = offset
+4
View File
@@ -132,8 +132,12 @@ class SuperPe():
iat[dll_name].append(IatEntry(dll_name, imp_name, imp_addr))
return iat
def write_code_section_data(self, data: bytes):
sect = self.get_code_section()
if len(data) != sect.SizeOfRawData:
logger.error(f'New code section data is larger than the original! {len(data)} != {sect.SizeOfRawData}')
return
self.pe.set_bytes_at_offset(sect.PointerToRawData, data)