Reverse Engineering Anything using small open models

Community Article
Published October 26, 2026
HF logo rebuilt Space shooter rebuilt

Introduction

Reverse Engineering modern software has become very popular in recent weeks and months, especially with the exponential rise of the Reverse Engineer Anything (REA) repository, which crossed 370k GitHub stars as we write this blog post.

image

Today, if you plug powerful models into this application, you can easily reverse engineer almost any modern software, and the results are impressive. We have seen community re-implementations of Adobe products, Linux extensions, and customizations of popular games. We also recommend this very nice YouTube video from Low Level, which goes through this technique, and made us want to dig a bit deeper into the topic.

What is exactly Reverse Engineering in this context, and are organized agents and their subordinates sufficiently performant to see interesting results? In this blog post, we are going to share preliminary experiments and results as we explore this concept by leveraging local and open AI models.

Reverse Engineering in the context of software engineering

In the context of software engineering, reverse engineering makes sense when the software is closed-source and distributed to common folks as compiled binary files. It is not possible to retrieve the software's source code directly from the binary file, but you can extract essential information and the compiled software's structure from it. Below is a demo that showcases the components that can be inspected from the binary file that we used for the Hugging Face logo assignment:

For more details from (this article):

  • Machine Code & Control Flow: Instructions that the CPU executes, including loops, function calls, and conditional branches, which can be visualized using disassemblers.
  • Embedded Strings & Data: Hardcoded text, file paths, API endpoints, error messages, and configuration constants visible via string-extraction utilities.
  • Symbols & Function Names: Unstripped binaries reveal function names, global variables, and debugging metadata that outline how the program is organized.
  • Linked Libraries & Dependencies: Imports and shared libraries (such as .dll files on Windows or .so files on Linux, as shown by tools like ldd) indicate which external code the binary relies on.
  • Architectural & Format Details: The file container structure (such as ELF on Linux or PE on Windows) reveals target hardware architecture, compilation flags, and section layouts.
  • Security Flaws & Vulnerabilities: Static and dynamic analysis can uncover hardcoded secrets, weak cryptographic implementations, or memory-safety bugs

Therefore, it is possible to use existing tools from the community, to disassemble binary files and inspect core components such as:

Symbols & Function Names: Unstripped binaries reveal function names, global variables, and debugging metadata that outline how the program is organized.

This is the main piece we will exploit to build our REA proof of concept using small local models.

Experimental design and results

We designed two very simple toy problems to reverse engineer. For both problems, we use Claude Code to generate the associated C codebase and provide the compiled software as input to the reverse engineering pipeline.

For each problem, we assign a lead agent who needs to be capable; thus, we use deepseek-ai/DeepSeek-V4.1-Flash-1017. The lead disassembles the binary, finds and names the functions, guesses their signatures, and recovers the memory layout and data tables. Then it posts tasks with hints on a shared board, and idle workers pick up tasks themselves. For the workers, we use the Qwen/Qwen3.5-9B model.

The worker agents also have access to a testing oracle, diff_test, which runs ~600 cases through the original binary function and the Python version and compares the return value and every byte of game state exactly. It returns a pass rate on held-out cases plus the first mismatches (which bytes or pixels differ). The worker will submit their final implementation only if all tests passed. After a certain number of attempts (if not completed), the submission will be escalated to the lead agent, who will take the task on their own.

All AI agents here leverage an extended version of a harness purely based on IPython. Every agent starts with the same small toolkit: read the binary (disasm, rodata, …), watch it run (trace, call_address), and test a rewrite against the original (diff_test, submit). The lead also gets tools to record the shared map and post tasks. It is also allowed for the lead to modify the workers' harnesses by adding new tools or modifying core components of the harness if the lead estimates it is relevant. This will allow us also to observe the ‘evolution’ of the harnesses for the worker agents. The diagram below summarizes very well the designed pipeline - on the example of the second assignment:

Problem 1: Hugging Face animated logo

The first problem we designed was to reconstruct an animated video that had been compiled in binary format. The video is a simple pixel art version of the HF logo. In this problem, there are 38 functions to re-write in Python. Below is a video that shows how the video renders, function after function rewritten by the worker agents:

This table summarizes the performance of this pipeline, compared to a full solo run:

Run Setup Functions accepted Escalated to the lead Lead harness changes Big model tokens (in / out) Small model tokens (in / out) Cost Active time
Team 1 Lead + 4 workers 38 / 38 15 0 7.79M / 0.21M 3.56M / 0.21M $2.97 86 min (2 launches)
Solo One DeepSeek agent 38 / 38 n/a n/a 2.53M / 0.10M none $0.87 ⁴ 14 min

Note that the workers escalated 15 functions to the lead, judging them too difficult to re-write. Overall, the pipeline is slower and more expensive, and the lead did not propose any harness changes for the workers. Perhaps the problem was way too easy for the lead agent to solve in one shot, and the functions were difficult for the small agents to complete (perhaps not granular enough).

What if we scale up slightly the number of functions to write? We made a second experiment with a different style, a space shooter game.

Problem 2: Space Shooter game

In this setup, we designed a simple Space Shooter game and tasked the models with reverse-engineering it. The original source code contains 56 functions that need to be rewritten.

Run Setup Functions accepted Escalated to the lead Lead harness changes Big model tokens (in / out) Small model tokens (in / out) Cost Active time
Team (completed) Lead + 4 workers 56 / 56 20 3 (2 worker prompts, 1 lookup tool) 8.96M / 0.30M 4.94M / 0.37M $3.60 100 min (2 launches)
Solo One DeepSeek agent 56 / 56 n/a n/a 9.69M / 0.31M none $3.28 54 min (4 launches)

In absolute cost, the pipeline now starts to tie with the solo run. A solo run struggles handling this big task in a single long run. Interestingly, putting this side by side with the first run shows that scaling the number of functions to rewrite, highlights the advantage of using such pipeline.

A good example of why the lead's oversight matters is draw_particles. The workers kept failing to reverse-engineer it. Their Python looked structurally right, but diff_test kept reporting mismatches. The problem was not the logic but how they read the ARM instructions. The disassembly compares a value with cmp and then branches with b.ls, which on AArch64 means "lower or same" as an unsigned comparison. The workers kept translating it as a plain signed <. That one misread off-by-one boundary was enough to make every attempt fail. The lead noticed the same mistake across several workers. It did not take the function over itself. Instead, it edited the workers' system prompt to spell out exactly how to read b.ls/b.hi. With that guidance in place, the workers could finish the task on their own.

Note also that the lead agent modified the ipython-harness twice for this problem. It performed two system prompt modifications:

Base system prompt (v0)

You are a worker on a reverse-engineering team. Rebuild exactly one function in Python until it passes 100% on the held-out cases. Read its disassembly, submit a first version early with the submit tool, read the mismatches, fix, submit again. Keep edits small. If the map entry looks wrong, tell the lead with map_note.

System prompt v1

Base prompt +

1. Read port/layout.py for the offset of every state field and port/constants.py for tables. Index the bytearray directly: e.g. alien_alive at 469 -> s[469+i]; a u16 signed field -> (s[o] | s[o+1]<<8); if it is listed as s16 use v = v-65536 if v>=32768 else v.
2. Only call fn('name') for functions that exist in port/map.json (check the names listed in the board/map). Never invent helper names like star_x/star_y.
3. Your submission is exactly one function def <name>(s, ...) with the arguments of the mapped signature, mutating the bytearray in place. Import helpers with from experiments.rebuild.runtime import fn and tables with from port.constants import *.
4. Follow the hint literally: the hints are transcribed from the disassembly. Do not "improve" constants. AArch64 traps: b.hi/b.ls compare UNSIGNED (negative args are > 23!), ldrsh/ldrsb are signed, strb stores value & 0xFF.
5. If the diff_test mismatch is in one or two pixels/cells only, suspect a signedness or off-by-one in a loop bound, not the overall structure. Report what you could not explain rather than guessing wildly.

We also record the motivation of the lead on why it made this change:

Workers repeatedly fail on the same chores: they invent helper function names (draw_stars_layer1 used fn('star_x')), ignore signed/unsigned distinctions, and do not use layout.py offsets.

System prompt v2

v1 +

1. … if it is listed as s16 use v = v-65536 if v>=32768 else v. Confirm an offset with lookup("<offset>") instead of recomputing base-pointer arithmetic by hand: ldrsh w1,[x23,x19,lsl #1] with a negative-offset base resolves to a plain field offset.
2. … Never invent helper names like star_x/star_y. Before calling a callee run lookup('callee') and pass exactly the recorded number and order of arguments - a wrong argument count throws and burns the attempt.
3. (unchanged)
4. … b.hi/b.ls compare UNSIGNED (negative args are > 23!) so cmp w,#0xc + b.ls means x <= 12 unsigned, not < 12; b.lt/b.gt/b.le/b.ge after cmp are signed. ldrsh/ldrsb are signed, strb stores value & 0xFF (mask negative values before storing).
5. (unchanged)
6. Never use call_address yourself with an invented signature; rely on the mapped signature. If a mismatch names fields you do not recognise, run lookup on the offset.

We also record the motivation of the lead on why it made this change:

Workers repeat three mistakes: they translate cmp/b.ls as < instead of unsigned <= (draw_particles, update_shots), they call callees with the wrong argument count (update_ufo/boxes_overlap TypeErrors), and they hand-derive field offsets from base-pointer arithmetic instead of reading the layout (593 vs 625, 581 vs 565).

The v2 harness also includes a new tool lookup, a small tool the lead wrote for its workers so they can look up facts the team had already recorded instead of re-deriving them: the signature of any function, or which state field sits at a given byte offset.

Conclusion and open questions

Small models are capable of producing decisive content if they are properly conditioned, i.e., well prompted (given a scope they can work on) and in the right scaffold (or harness) where they can work.

Overall, for both tasks, about 40% of the functions needed the lead (15 of 38 on the HF logo, 20 of 56 on the space shooter). A possible direction would be to explore using a pool of workers of different sizes and families, which would open the possibility of exploring swarms of small models guided by a lead (or a set of leads) or much larger models.

There also seems to be a correlation (though difficult to say, with only two data points), with respect to the number of functions to re-write. This protocol might make sense for very long-horizon tasks, which require tons of planning, and for problems that can be scoped into granular task distributions. It would also be very interesting to observe the evolution of harnesses for worker agents in such a setup.

Community

Sign up or log in to comment