#!/usr/bin/env python3 """Execute actual shipped Linux registry leaves, without substituting statuses.""" from pathlib import Path import hashlib,json,warnings warnings.filterwarnings('ignore',category=UserWarning,module='unicorn') from elftools.elf.elffile import ELFFile from unicorn import Uc,UC_ARCH_X86,UC_MODE_64,UC_HOOK_MEM_READ,UC_HOOK_MEM_WRITE from unicorn.x86_const import * R=Path(__file__).resolve().parents[1];P=Path('/home/geodd/nvidia-driver/analysis-580.178.04/extracted/kernel/nvidia/nv-kernel.o_binary');SHA='5269a23ffba19a17fe16f076463e7ad4151254659441d1711bee6c6221ff6f4b';assert hashlib.sha256(P.read_bytes()).hexdigest()==SHA TEXT=0x10000000;DATA=0x30000000;STACK=0x40000000;STOP=0x60000000 with P.open('rb') as f: e=ELFFile(f);text=e.get_section_by_name('.text').data();syms={s.name:s for s in e.get_section_by_name('.symtab').iter_symbols()} uc=Uc(UC_ARCH_X86,UC_MODE_64);uc.mem_map(TEXT,(len(text)+4095)&~4095);uc.mem_write(TEXT,text);uc.mem_map(DATA,4096);uc.mem_map(STACK,4096);uc.mem_map(STOP,4096) accesses=[] def access(uc,kind,address,size,value,user): if DATA<=address