Trace Carl lifecycle and add read-only original state observer

This commit is contained in:
UnixNight committed 2026-11-06 10:27:10 -05:00
1 parent c642b69849
commit 4cd62d3627
28 files changed
+2387 -5

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
"""Guard and prepare a bounded original skip/input/player composition probe."""
import argparse,hashlib,json,re,struct,subprocess
from pathlib import Path
from checkpoint_script_state import EXE_SHA256,find_case,read_va
from pe_inspect import PE
REA_ID='ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
RANGES=((0x437940,0x437c3a),(0x438a60,0x438ba2),(0x439900,0x439e33),(0x43915d,0x4395cf),(0x43a420,0x43a5cd),(0x472480,0x472570),(0x475a40,0x475a4c),(0x431518,0x431590),(0x430f1d,0x430f5c),(0x429910,0x429963))
def generate(original,out,rea):
original=Path(original).resolve();out=Path(out).resolve()
if out.is_relative_to(original) or original.is_relative_to(out):raise ValueError('Separate output required')
p=PE(find_case(original,'Neutron.exe'))
if hashlib.sha256(p.data).hexdigest()!=EXE_SHA256:raise ValueError('Original EXE identity')
record=next(r for r in json.loads(Path(rea).read_text())['records'] if r['evidence_id']==REA_ID)
if record['subject']['digest']['sha256']!=EXE_SHA256:raise ValueError('REA subject identity')
targets={0x5099e4,0x4f83e4,0x4f8181,0x4f83e0,0x438ba4}
for a,b in RANGES:
asm=subprocess.run(['objdump','-d','-Mintel',f'--start-address={a}',f'--stop-address={b}',str(p.path)],capture_output=True,text=True,check=True).stdout
targets.update(int(v,16) for v in re.findall(r'ds:0x([0-9a-f]+)',asm))
out.mkdir(parents=True,exist_ok=True)
body=Path(__file__).with_name('jimmy_skip_composition_probe.c').read_text().replace('/* RELOCATIONS */',','.join(hex(x) for x in sorted(targets)))
(out/'jimmy_skip_composition_probe.c').write_text(body)
r=dict(source_sha256=EXE_SHA256,rea_evidence_id=REA_ID,ranges=[dict(va=hex(a),file_offset=hex(p.offset(a-p.base)),length=b-a,sha256=hashlib.sha256(read_va(p,a,b-a)).hexdigest()) for a,b in RANGES],relocations=[hex(x) for x in sorted(targets)],scope='Original bounded input/controller/facing and skip-prefix composition; synthetic support/resources, base-facing shim; not full skip or original gameplay.')
(out/'source.json').write_text(json.dumps(r,indent=2)+'\n');return r
if __name__=='__main__':
c=argparse.ArgumentParser();c.add_argument('original',type=Path);c.add_argument('--output',type=Path,required=True);c.add_argument('--rea',type=Path,required=True);a=c.parse_args();print(json.dumps(generate(a.original,a.output,a.rea),indent=2))