How to Prompt an AI to Reverse-Engineer Software: A Practical Workflow
[!NOTE] TL;DR: Pointing an agent at a binary and saying “reverse engineer this” produces confident gibberish. The workflow that works is structured: orient first, map before rewriting, rename as you go, and verify against observed behavior — with the decompiler exposed as tools, not pasted output.
The video’s most quietly useful segment is the prompting section. Everyone tries the naive version once — upload a binary, ask for source — and gets a plausible hallucination. The working version looks less like a magic prompt and more like delegating a code review to a very fast junior engineer with perfect recall.
Table of Contents
The Setup: Tools, Not Pasted Output
The foundational rule: the agent needs interactive access to the decompiler, not a static dump. That means MCP servers — ghidra-mcp, ida-mcp, or a packaged toolkit like REA — so the agent can call “decompile this function,” “list imports,” or “show callers” on demand. A decompiled function pasted into chat is a dead end; a decompiler the agent can query is a research assistant.
For Unity and .NET targets, run Cpp2IL or ILSpy first and hand the agent the managed output — you skip the hardest layer entirely.
Step 1: Orient Before You Analyze
The first prompt is never “explain the binary.” It is a map request:
“List the imports, exports, and interesting strings. Based on those, tell me which subsystem handles [networking / licensing / save files] and which functions to start with.”
This mirrors what a human reverse engineer does and gives the agent the reconnaissance data it needs to plan — instead of decompiling functions at random. Guide collections like ai-game-modding-guides are useful precisely because they encode these starting moves.
Step 2: Ask for a Map, Not a Rewrite
The most common failure is asking for the reimplementation too early. The agent will oblige — and it will be wrong in ways you cannot see. The working order is:
- “Give me the call graph around
FUN_xxxxand describe what each function does in one line.” - “Identify the data structures these functions share.”
- Only then: “Reimplement
validate_savein Rust, preserving the exact checksum behavior.”
Each step constrains the next. A rewrite grounded in a verified map is auditable; a rewrite from nothing is fan fiction.
Step 3: Rename and Annotate as You Go
This is the highest-leverage habit in the whole workflow. Every time the agent understands a function, have it rename the symbol in the decompiler — FUN_14001a3c0 becomes parse_packet_header — and add a comment. Because MCP tools write back to the project, each subsequent decompilation inherits the good names. The binary literally gets easier to read the longer the session runs, and the agent’s own later analysis improves.
Step 4: Verify Against Behavior
Analysis is a hypothesis until tested. Close the loop:
- For mods and rebuilds: compile the output and run it. Behavior mismatch beats elegant reasoning every time.
- For understanding: ask the agent to predict a behavior — “if I send this input, what happens?” — then check the prediction against the running program. Confirmed predictions are evidence; failed ones localize the error.
- Demand coverage statements. Ask which functions were examined versus skipped. Tools like REA report this natively; if yours doesn’t, ask for the list explicitly so you know the blind spots.
Frequently Asked Questions
Q: What’s the single biggest prompting mistake? A: Asking for the final artifact first — “rewrite this in Rust,” “make a mod” — before the agent has mapped the binary. The working order is orient → map → rename → reimplement → verify, and skipping steps produces confident, wrong output.
Q: Do I need MCP tooling, or can I paste decompiled code into chat? A: Pasting works for a single function. Anything real needs the agent calling the decompiler itself — following call graphs, renaming symbols, pulling adjacent functions — which requires ghidra-mcp, ida-mcp, or REA. Interactive access is the whole trick.
Q: Which binaries are easiest to start with? A: Managed ones. A .NET app via ILSpy or a Unity game via Cpp2IL hands the agent near-source code, so you can learn the workflow without fighting raw disassembly. Native stripped binaries are the advanced course.
Q: How do I know the agent’s analysis is right? A: Test predictions. Ask it to predict observable behavior — output for a given input, a checksum, a protocol response — and verify against the running program. Verified predictions are the closest thing RE has to unit tests; also insist it report which functions it examined and which it skipped.
Q: What should I use this for? A: Legitimate targets: modding games you own, interoperability research, security auditing, malware triage, and preservation. The same workflow pointed at someone else’s DRM or license enforcement is a different legal and ethical conversation — the technique is neutral, the target isn’t.