import struct, re exe = open("HAVOC_NOCD.EXE", "rb").read() base = 0x00400000 def rva2fo(rva): # Sections from pe_sections.py output sections = [ (".text", 0x00001000, 0x00066bbd, 0x00000400, 0x00066c00), (".rdata", 0x00079000, 0x000023c0, 0x00067000, 0x00002400), (".data", 0x0007c000, 0x00005650, 0x00069400, 0x00005800), (".idata", 0x00082000, 0x00000d5a, 0x0006ec00, 0x00000e00), (".rsrc", 0x00083000, 0x0000080c, 0x0006fa00, 0x00000a00), (".reloc", 0x00084000, 0x000063ba, 0x00070400, 0x00006400), ] for (name, vrva, vsz, raw, rsz) in sections: if vrva <= rva < vrva + vsz: return raw + (rva - vrva) return None # Data directory entry 1 = import table pe_off = 0x80 opt_off = pe_off + 24 import_rva = struct.unpack_from(' iat_va while True: orig_thunk_rva = struct.unpack_from('