REA: Teaching AI Agents to Reverse Engineer Binaries Through MCP
Hook
Most LLMs will confidently explain what a function does even when they can't see the assembly. REA fixes this by giving agents an explicit 'I don't know' button—complete with file offsets pointing to exactly what they couldn't resolve.
Context
Reverse engineering has a fundamental mismatch problem: the tools are fragmented (Ghidra for open-source work, Hopper for macOS ARM64, IDA for commercial gigs), the workflows are iterative (check imports, trace cross-references, read pseudocode, repeat for hours), and AI assistants are terrible at it. Ask GPT-4 to help analyze a stripped binary and you get hallucinated function names, made-up system calls, and zero awareness of what the disassembler actually found versus what the LLM invented.
REA (Reverse Engineer Anything) solves this by implementing a Model Context Protocol server that bridges AI agents to real reverse engineering toolchains. Instead of copying pseudocode into ChatGPT and hoping for insight, agents can now call MCP tools like analyze_binary, get_function_pseudocode, or trace_cross_references that talk directly to Ghidra's headless analyzer, Hopper's Python bridge, or static parsers for JavaScript/Electron apps. The clever part isn't just wrapping disassemblers in JSON—it's the evidence contract that forces every response to include file offsets, confidence scores, and explicit 'unknowns' fields so LLMs understand the difference between 'this import resolves to libc.dylib' and 'could not resolve this external reference at offset 0x4A2C'. You're not eliminating hallucination, but you're containing it to the interpretation layer instead of letting it infect the raw analysis data.
Technical Insight
REA's architecture is a three-layer stack that's more sophisticated than most MCP servers in the wild. The top layer exposes 40+ standardized tools through Model Context Protocol—things like list_imports, find_strings, get_call_graph. The middle orchestration layer manages provider lifecycle and session state, which is critical because disassembling a 500MB native binary can take 20 minutes in Ghidra. The bottom layer is heterogeneous provider adapters: native tools (Hopper, Ghidra, IDA), static parsers for JavaScript/Electron, browser automation for web apps, .NET metadata readers, and specialized handlers for EVM bytecode and Android APKs.
The session snapshot model is the architectural breakthrough. When you analyze a binary, REA creates a persistent session—Ghidra's project database stays loaded in memory, Hopper's disassembly graph remains hot, symbol tables are cached. Subsequent MCP calls from the agent hit that live session instead of re-parsing from scratch:
// Agent makes iterative queries without reload penalties
const session = await rea.analyze_binary({
path: './suspicious.exe',
provider: 'ghidra' // or 'hopper', auto-selected by format
});
// First query: get entry point
const entry = await rea.get_function_pseudocode({
session_id: session.id,
address: '0x401000'
});
// Second query: trace where that function is called from
const xrefs = await rea.get_cross_references({
session_id: session.id,
address: '0x401000',
direction: 'to' // who calls this?
});
// Session state persists across all queries
This solves the stateless MCP problem elegantly. The Model Context Protocol is fundamentally request-response, but reverse engineering is stateful—you build mental models over hours, jumping between functions, following data flows. REA keeps that disassembly state alive so agents can think iteratively.
The evidence contract is what prevents LLM confabulation. Every tool response includes structured metadata about what was actually found versus what's uncertain:
{
"function": {
"address": "0x401000",
"name": "sub_401000",
"confidence": "high",
"pseudocode": "void sub_401000(char* arg0) { ... }",
"imports": [
{
"name": "CreateFileW",
"library": "kernel32.dll",
"resolved": true,
"offset": "0x401A4C"
},
{
"name": "unknown_external_3",
"library": null,
"resolved": false,
"offset": "0x401B12",
"reason": "Import table entry corrupted or obfuscated"
}
],
"unknowns": [
{
"type": "unresolved_call",
"offset": "0x401B12",
"context": "Indirect call through register, target unknown"
}
]
}
}
That unknowns array is gold. Instead of GPT-4 guessing what happens at offset 0x401B12, it sees explicit acknowledgment that the tool couldn't resolve it, plus file offset context so the agent can pivot strategies—maybe check for dynamic resolution, search for function pointers, or flag it for manual review.
Provider abstraction is pragmatic rather than elegant. REA doesn't try to create a universal intermediate representation (IR) that all tools compile to—Ghidra's Pcode, Binary Ninja's BNIL, and Hopper's internal graph are too different. Instead, each provider implements a common interface but returns tool-native output:
interface REProvider {
analyze(target: string): Promise<SessionHandle>;
getFunctions(session: SessionHandle): Promise<Function[]>;
getPseudocode(session: SessionHandle, addr: string): Promise<string>;
getXrefs(session: SessionHandle, addr: string): Promise<Reference[]>;
// ... ~15 more standard operations
}
The Hopper provider launches the macOS GUI app and drives it through Python bridge scripts—wasteful but necessary since Hopper doesn't have a true headless mode. Ghidra's provider spawns analyzeHeadless subprocesses and communicates via scripted output. The JavaScript provider is pure static analysis using acorn parser plus custom logic to detect Electron IPC boundaries (looking for ipcRenderer.send / ipcMain.on patterns).
The auto-injection of investigation workflows is a pragmatic hack that probably shouldn't work but does. REA ships with templates like 'How to investigate an Electron app' or 'Firmware extraction workflow' and can inject these into Claude's claude_desktop_config.json or Cursor's .cursorrules file:
{
"mcpServers": {
"rea": {
"command": "npx",
"args": ["-y", "@morluto/rea"],
"systemPrompt": "When analyzing Electron apps: 1) Use list_asar_contents to map app.asar structure, 2) Search for ipcRenderer usage in renderer processes, 3) Trace corresponding ipcMain handlers in main process, 4) Check preload scripts for context bridge exposure..."
}
}
}
You're literally shipping domain expertise as templated prompts. Junior researchers get investigation patterns without reading 'The IDA Pro Book'. Senior folks can override or ignore them. It's training wheels that don't get in the way.
Gotcha
Windows support is marked experimental and it shows—only Ghidra works, and even that's flaky. No Hopper (macOS-only tool), no firmware extraction (binwalk/unblob are Linux-native), and the PTY process capture used for observing running binaries doesn't work on Windows pseudoterminals. This is darkly ironic since Windows PE executables are the most common reverse engineering target. You can analyze Windows malware from a Linux VM running Ghidra, but you're cutting yourself off from half the toolchain.
The bigger limitation is that REA is purely static analysis with minimal dynamic capabilities. There's basic process observation (watching a binary run, capturing output) but no Frida integration for runtime hooking, no debugger attachment, no memory dumping. Modern malware uses anti-debug tricks, string obfuscation, and runtime unpacking that static analysis can't crack. You can see that a function calls VirtualAlloc and writes to the returned buffer, but you can't see what executable payload gets decrypted into that memory at runtime. Similarly, the JavaScript analysis claims to handle Electron apps, but real-world targets like Discord or Slack use webpack bundlers that flatten module boundaries and mangle imports—REA's static acorn parsing sees a giant blob, not the clean IPC boundaries shown in the docs' demo examples.
Session state lives in-process with no persistence backend. Crash the MCP server or restart your agent, and you lose hours of Ghidra analysis. There's no 'save session to disk' or 'recover from checkpoint' because REA relies on tool-native state (Ghidra's .gpr project files, Hopper's .hop databases) that aren't designed for MCP-style serialization. For long investigations of complex firmware or large binaries, this is a ticking time bomb.
Verdict
Use REA if you're doing offensive security research, CTF competitions, or exploratory reverse engineering where you want LLM assistance navigating unfamiliar codebases without manually teaching the agent how disassemblers work. The evidence contracts and multi-provider abstraction genuinely solve the 'fragmented tooling' problem—write your investigation workflow once, run it against iOS binaries in Hopper and Android APKs in Ghidra without rewriting scripts. The auto-injected workflow prompts are surprisingly useful for getting junior researchers unstuck or documenting your team's investigation patterns as executable templates. Skip it if you need production Windows support (it's broken), rely on dynamic analysis for packed malware (no Frida/debugger integration), or work with heavily obfuscated JavaScript where static parsing is security theater. The lack of session persistence is a landmine for multi-day investigations. Best used as a force multiplier for the 'initial reconnaissance' phase: let the agent map out imports, identify interesting functions, and build a call graph, then switch to manual tools (Frida, IDA scripts, custom instrumentation) once you've narrowed down the attack surface.