367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
37 lines
2.0 KiB
Python
37 lines
2.0 KiB
Python
"""Read-only guild message getter/constructor code through the owning debugger.
|
|
|
|
No engine calls, packet/authentication buffers, heap walks or protection changes.
|
|
The pinned image code range excludes writable account/session data. Only
|
|
currently executable pages are read; cold code is never activated.
|
|
"""
|
|
import hashlib,json,struct
|
|
from pathlib import Path
|
|
START=0x140a33000
|
|
END=0x140a37000
|
|
OPCODES=(0x530012,0x530002)
|
|
def scan(read,executable):
|
|
matches=[]
|
|
for page in range(START,END,4096):
|
|
if not executable(page,4096):continue
|
|
raw=b''.join(read(page+i,512)for i in range(0,4096,512))
|
|
if len(raw)!=4096:raise ValueError('Incomplete original code page')
|
|
for opcode in OPCODES:
|
|
needle=b'\xc7\x02'+struct.pack('<I',opcode)+b'\x48\x8b\xc2\xc3';at=raw.find(needle)
|
|
if at<0:continue
|
|
if raw.find(needle,at+1)>=0:raise ValueError('Ambiguous guild opcode getter')
|
|
matches.append((dict(opcode=hex(opcode),getter=hex(page+at),page=hex(page),sha256=hashlib.sha256(raw).hexdigest()),raw))
|
|
if len({r['opcode']for r,_ in matches})!=len(matches):raise ValueError('Duplicate original guild getters')
|
|
return matches
|
|
|
|
def inspect(read,executable,root,pid):
|
|
out=Path(root)/'runtime/native-handler-code';cache=out/('guild-message-code-fixed-pages-'+str(pid)+'.json')
|
|
if cache.exists():return json.loads(cache.read_text())
|
|
matches=scan(read,executable);rows=[];out.mkdir(exist_ok=True)
|
|
for row,raw in matches:
|
|
path=out/(row['page']+'-guild-'+row['sha256'][:12]+'.bin')
|
|
if path.exists()and path.read_bytes()!=raw:raise ValueError('Prior code capture differs')
|
|
if not path.exists():path.write_bytes(raw);path.chmod(0o600)
|
|
rows.append(dict(row,file=path.name))
|
|
report=dict(kind='original-guild-message-code',pid=pid,engine_calls_made=False,authentication_buffers_read=False,protection_changes=False,scan_range=[hex(START),hex(END)],matches=rows)
|
|
cache.write_text(json.dumps(report,indent=2)+'\n');return report
|