Files
WoW-Hybrid-gateway/ops/native_netclient_audit.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

51 lines
3.5 KiB
Python

#!/usr/bin/env python3
"""Read existing code-only snapshots; locate NetClient candidates without hooks.
No heap/auth dumps, game calls, process writes or original-file modifications.
"""
import hashlib,json,re,struct,tarfile,zipfile
from pathlib import Path
import capstone
from capstone.x86_const import X86_OP_MEM,X86_REG_RIP
ROOT=Path(__file__).resolve().parents[1]
EXE=Path('/mnt/Games/Games/WoW-Forever/_classic_beta_/WowB.exe')
def main():
archive=Path.home()/'Downloads/forever-netclient-70334.tar.gz';pages=Path.home()/'Downloads/forever-70334-code-after.zip'
with tarfile.open(archive)as t:
code=t.extractfile('netclient-code.bin').read(100000);strings=t.extractfile('netclient-strings.bin').read(100000)
with zipfile.ZipFile(pages)as z:
bases=[]
for n in z.namelist():
if not re.fullmatch(r'code/[0-9a-f]+\.bin',n):continue
b=z.read(n)
if len(b)==4096 and (at:=code.find(b))>=0:bases.append(int(Path(n).stem,16)-at)
if len(bases)<2 or len(set(bases))!=1:raise ValueError('Cannot independently establish snapshot virtual base')
base=bases[0];pe=EXE.read_bytes();nt=struct.unpack_from('<I',pe,0x3c)[0];count=struct.unpack_from('<H',pe,nt+6)[0];opt=nt+24;optsize=struct.unpack_from('<H',pe,nt+20)[0];image=struct.unpack_from('<Q',pe,opt+24)[0];sections={}
for i in range(count):
at=opt+optsize+i*40;name=pe[at:at+8].rstrip(b'\0').decode();vsize,rva,size,offset=struct.unpack_from('<4I',pe,at+8);sections[name]=(rva,offset,size)
def address(offset):
for rva,at,size in sections.values():
if at<=offset<at+size:return image+rva+offset-at
raise ValueError('Unmapped disk offset')
# Match immutable printable bytes, not a presumed string-dump base.
labels={}
for m in re.finditer(rb'[ -~]{8,}\0',strings):
text=m.group()[:-1]
if not any(s in text.lower() for s in (b'connection',b'netstate',b'neteventqueue',b'compressed packet',b'game realm',b'client connected')):continue
at=pe.find(text+b'\0')
if at<0 or pe.find(text+b'\0',at+1)>=0:continue
labels[address(at)]=text.decode()
rva,off,size=sections['.pdata'];functions=[struct.unpack_from('<3I',pe,i)[:2] for i in range(off,off+size-11,12)]
md=capstone.Cs(capstone.CS_ARCH_X86,capstone.CS_MODE_64);md.detail=True;md.skipdata=True;hits=[]
for ins in md.disasm(code,base):
if ins.id==0:continue
for op in ins.operands:
if op.type==X86_OP_MEM and op.mem.base==X86_REG_RIP:
target=ins.address+ins.size+op.mem.disp
if target in labels:
bounds=next(((image+a,image+b)for a,b in functions if image+a<=ins.address<image+b),None)
hits.append({'label':labels[target],'reference':hex(ins.address),'function_range':[hex(v)for v in bounds] if bounds else None,'instruction':ins.mnemonic+' '+ins.op_str})
report={'build':70334,'exe_sha256':hashlib.sha256(pe).hexdigest(),'archive_sha256':hashlib.sha256(archive.read_bytes()).hexdigest(),'snapshot_base':hex(base),'independently_matching_pages':len(bases),'hits':hits,'limits':['Code snapshots are prior local captures, not newly validated live function signatures.','RIP references and unwind bounds identify investigation candidates, not safe callable engine APIs.','No hooks installed and no engine world entry claimed.']}
output=ROOT/'runtime/native-netclient-audit.json';output.write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps(report,indent=2))
if __name__=='__main__':main()