$ account simonlindholm
This repository is a specialized tool for automated C code permutation to match a target compiled binary, primarily used in video game decompilation projects (e.g., Nintendo 64). The core loop reads a C source file and a target object file, then repeatedly mutates the C code using a set of predefined random transformations, compiles it, disassembles the output, and scores the resulting assembly against the target. The goal is to produce a C source that compiles to identical or nearly identical assembly, reducing manual effort in reverse engineering. The architecture is a Python CLI application with support for multi-threading and distributed computing. The main entry points are `permuter.py` (local mode), `import.py` (project setup), and `pah.py` (network client for distributed 'permuter@home'). The system relies on a vendored fork of pycparser for C parsing and AST manipulation, and it integrates with external tools: a C compiler (GCC, IDO, or MWCC), `objdump` for disassembly, and optionally Docker for sandboxed remote evaluation. A Rust server (`src/net/controller`) manages the distributed network, and a Go systray helper provides a system tray icon for the network client. Data flows are iterative: the tool seeds a candidate, applies one or more random permutations (e.g., introducing temporaries, reordering declarations, transforming expressions), compiles the result, extracts assembly, scores it using a diff-based algorithm, and keeps the best candidate. The process repeats until a perfect match is found or the user stops it. The project demonstrates high craftsmanship in its modular design, with clean abstractions for permutations, scoring, AST utilities, and networking. The vendored pycparser is heavily patched for GNU C extensions, and the custom stubs ensure type safety.