Document architecture checkpoint and restore original task callback order
This commit is contained in:
1 parent
69d0187a21
commit
531883aaac
45 files changed
+2935
-43
No files matched your search
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only, bounded anchors for the architecture checkpoint (not a disassembler)."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from pe_inspect import PE
|
||||
|
||||
EXE_SHA256 = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8'
|
||||
FRAME_CALLS = [(0x47E554, 0x479BC0), (0x47E560, 0x462A20),
|
||||
(0x47E56B, 0x4693A0), (0x47E57A, 0x47D8F0),
|
||||
(0x47E582, 0x473740), (0x47E587, 0x473770),
|
||||
(0x47E6B1, 0x477DB0)]
|
||||
ANCHORS = {
|
||||
'viewport_constructor': (0x47E374, 'c706c4744d00'),
|
||||
'viewport_render_import': (0x47E6DF, 'ff1504d34800'),
|
||||
'registry_update_slot10': (0x473758, 'ff5010'),
|
||||
'registry_next_after_callback': (0x47375B, '8b36'),
|
||||
'registry_sync_slot3dc': (0x473784, 'ff90dc030000'),
|
||||
'registry_sync_slot3e0': (0x47378E, 'ff92e0030000'),
|
||||
'tail_link': (0x46FF70, '894604'),
|
||||
'registry_interface_payload': (0x46FF7F, '8928'),
|
||||
'normal_update_slot3c4': (0x4702C5, 'ff92c4030000'),
|
||||
'controlled_input_slot3cc': (0x475AA9, 'ff92cc030000'),
|
||||
'morph_logic_import': (0x462265, 'ff1544d24800'),
|
||||
}
|
||||
|
||||
|
||||
def recover(original):
|
||||
exe = PE(Path(original) / 'Neutron.exe')
|
||||
digest = hashlib.sha256(exe.data).hexdigest()
|
||||
if digest != EXE_SHA256:
|
||||
raise ValueError('Unsupported original EXE hash')
|
||||
result = {'sha256': digest, 'calls': [], 'anchors': []}
|
||||
for va, expected in FRAME_CALLS:
|
||||
off = exe.offset(va - exe.base)
|
||||
if exe.data[off] != 0xE8:
|
||||
raise ValueError(f'Expected direct call at {va:#x}')
|
||||
target = va + 5 + struct.unpack_from('<i', exe.data, off + 1)[0]
|
||||
if target != expected:
|
||||
raise ValueError(f'Changed call at {va:#x}')
|
||||
result['calls'].append({'va': f'{va:#x}', 'file_offset': f'{off:#x}',
|
||||
'target': f'{target:#x}'})
|
||||
for name, (va, expected) in ANCHORS.items():
|
||||
off = exe.offset(va - exe.base)
|
||||
raw = bytes.fromhex(expected)
|
||||
if exe.data[off:off + len(raw)] != raw:
|
||||
raise ValueError(f'Changed anchor {name}')
|
||||
result['anchors'].append({'name': name, 'va': f'{va:#x}',
|
||||
'file_offset': f'{off:#x}', 'bytes': expected})
|
||||
vtable = 0x4D74C4
|
||||
off = exe.offset(vtable + 0xB8 - exe.base)
|
||||
if exe.u32(off) != 0x47E4F0:
|
||||
raise ValueError('Viewport vtable slot B8 changed')
|
||||
result['viewport_slot_b8'] = {'va': hex(vtable + 0xB8), 'file_offset': hex(off),
|
||||
'target': '0x47e4f0'}
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
print(json.dumps(recover(parser.parse_args().original), indent=2))
|
||||
Reference in new issue
Block a user