"""Analyze oneocr.onemodel file format.""" import os import struct MODEL_PATH = r"ocr_data\oneocr.onemodel" with open(MODEL_PATH, "rb") as f: data = f.read() print(f"Total size: {len(data)} bytes = {len(data)/1024/1024:.2f} MB") print(f"First 8 bytes (hex): {data[:8].hex()}") print(f"First 4 bytes as uint32 LE: {struct.unpack('= 0: ctx_start = max(0, idx - 8) ctx_end = min(len(data), idx + len(pattern) + 8) print(f"Found '{pattern.decode(errors='replace')}' at offset {idx} (0x{idx:x})") print(f" Context hex: {data[ctx_start:ctx_end].hex()}") print() # Check entropy by sections import collections def entropy_score(chunk): c = collections.Counter(chunk) unique = len(c) return unique print("Entropy analysis (unique byte values per 4KB block):") for i in range(0, min(len(data), 64*1024), 4096): chunk = data[i:i+4096] e = entropy_score(chunk) print(f" Offset 0x{i:06x}: {e}/256 unique bytes", "(encrypted/compressed)" if e > 240 else "(structured)" if e < 100 else "") # Look at first int as possible header size hdr_size = struct.unpack('