Files
ctf/2026/cscg/rev/connivance/patch_map.py
2026-03-22 21:53:40 +01:00

19 lines
579 B
Python

import hashlib
import struct
with open("main", "rb") as f:
data = f.read()
hash1 = hashlib.sha256(data[0x2000 : 0x2000 + 0x5334D]).digest()
hash2 = hashlib.sha256(data[0x56000 : 0x56000 + 0x226BB]).digest()
with open("./romfs/map", "wb") as f:
f.write(struct.pack("<Q", 0x5334D)) # region 1 size
f.write(struct.pack("<Q", 0x226BB)) # region 2 size
f.write(hash1) # 32 bytes
f.write(hash2) # 32 bytes
print("map written")
print(f" region1 hash: {hash1.hex()}")
print(f" region2 hash: {hash2.hex()}")