feature: data reuse (tmp, to fix)

This commit is contained in:
Dobin
2024-02-24 16:23:08 +00:00
parent 334b17e7a5
commit 2c133e7175
10 changed files with 472 additions and 9 deletions
+18
View File
@@ -21,6 +21,18 @@ class IatResolve():
self.id
)
def get_physical_address(pe, virtual_address):
# Iterate through the section headers to find which section contains the VA
for section in pe.sections:
# Check if the VA is within the range of this section
if section.VirtualAddress <= virtual_address < section.VirtualAddress + section.Misc_VirtualSize:
# Calculate the difference between the VA and the section's virtual address
virtual_offset = virtual_address - section.VirtualAddress
# Add the difference to the section's pointer to raw data
return virtual_offset
#physical_address = section.PointerToRawData + virtual_offset
#return physical_address
return None
class ExeInfo():
def __init__(self):
@@ -36,6 +48,9 @@ class ExeInfo():
self.base_relocs = []
self.rwx_section = None
self.ep = None
self.ep_raw = None
def add_iat_resolve(self, func_name, placeholder):
self.iat_resolves[func_name] = IatResolve(
@@ -49,6 +64,9 @@ class ExeInfo():
if pe.FILE_HEADER.Machine != 0x8664:
raise Exception("Binary is not 64bit: {}".format(filepath))
self.ep = pe.OPTIONAL_HEADER.AddressOfEntryPoint
self.ep_raw = get_physical_address(pe, self.ep)
# image base
self.image_base = pe.OPTIONAL_HEADER.ImageBase