"""Independent ELF/GNU oracle for the pinned SQLite pooled-string task.""" import hashlib import json from pathlib import Path import re import struct import subprocess import sys if sys.flags.optimize: raise RuntimeError('Run the oracle without Python optimization') binary, output = map(Path, sys.argv[1:]) raw = binary.read_bytes() digest = hashlib.sha256(raw).hexdigest() assert digest == '2e6eef9a727f081f0d453b4e5e6cbd8b9ef8b6f86cbf7681cbad444d3b0b55c8' assert raw[:6] == b'\x7fELF\x02\x01' and struct.unpack_from('= 56 and phoff + phsize * phcount <= len(raw) segments = [struct.unpack_from('> 3) & 7) | ((data[0] & 4) << 1) names = ['rax', 'rcx', 'rdx', 'rbx', 'rsp', 'rbp', 'rsi', 'rdi', 'r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15'] return at + 7 + struct.unpack_from('