Overview
Reverse engineering binary code is a grueling task. When code is compiled and "stripped," high-level information like variable names, function names, and comments vanish, leaving behind a massive "semantic gap." While modern decompilers can turn binary back into C-style code, the result is often a "word salad" of generic labels (e.g., sub_401A39, v5, a1) that are functionally correct but humanly incomprehensible.
This field, known as Human-Oriented Binary Reverse Engineering (HOBRE), has historically struggled with two main approaches:
- Supervised Fine-tuning: Training small models on specific tasks, which often fails to generalize to new types of code.
- Direct LLM Prompting: Asking general Large Language Models (LLMs) to explain decompiled code. While LLMs are highly capable, they often struggle with the lack of symbolic information in stripped binaries.
To address this, researchers introduce ProRec, a novel "probe-and-recover" framework. ProRec bridges the semantic gap by treating pre-trained Source Code Foundation Models (SCFMs) as vast knowledge bases. By aligning a binary encoder with a frozen SCFM, the system "probes" the model to synthesize symbol-rich code snippets. These snippets then serve as high-quality context for a black-box LLM to perform accurate reverse engineering.
The ProRec Framework
The ProRec system operates in two main phases: Probing and Recovering.
1. The Cross-Modal Knowledge Prober
Instead of fine-tuning a massive model from scratch, the researchers keep a large SCFM (like CodeLlama) frozen. They use a smaller, structure-aware binary encoder to process the assembly code and its dependency graph.
- Alignment: A simple projection layer (a two-layer MLP) is trained to map the binary embeddings into the same space as the SCFM’s word embeddings.
- Probing: By feeding these binary "prefixes" into the frozen SCFM, the system forces the model to synthesize "probed contexts." These are synthetic source code fragments that are rich in symbols and likely functionality, even if they aren't an exact match for the original source.
2. The Recoverer
The system then takes the original decompiled binary plus these synthesized "probed contexts" and feeds them into a high-reasoning black-box LLM (such as GPT-3.5, Claude-3, or Gemini-Pro). The LLM is instructed to perform an internal analysis of the contexts before producing the final output, such as a recovered function name or a natural language summary.
Datasets and Evaluation
To facilitate this cross-modal alignment, the researchers compiled a new dataset:
- Source: 18,000 GitHub projects with at least 20 stars.
- Scale: 270,000 pairs of binary functions and their corresponding original source code.
- Processing: Binaries were compiled for x86-64 (O0 optimization) and stripped of symbols.
- Evaluation: A subset of 1,000 functions was used for testing, supplemented by a human study with 12 participants (PhDs and experienced engineers) to validate the practical utility of the results.
Key Insights
- SCFMs as Knowledge Bases: The core innovation is treating a pre-trained code model as a searchable library. You don't need to teach the model what a "linked list" is; you just need to provide enough binary "clues" so it can locate its own internal representation of a linked list.
- Synthesis vs. Retrieval: Traditional Retrieval-Augmented Generation (RAG) searches a database for similar code. ProRec, however, synthesizes code. This is more flexible because the prober generates a "best-fit" context tailored to the specific binary, rather than relying on a perfect match existing in a static database.
- The Power of Internal Analysis: Asking the LLM to "think" about the relevance of the probed snippets before giving a final answer significantly reduces noise and improves the robustness of the recovery.
Results
ProRec demonstrated substantial improvements over both "zero-shot" (direct prompting) and RAG-based baselines:
- Binary Summarization: Achieved a 10.3% relative gain in CHRF (a standard translation metric) and a 16.7% relative gain in a GPT-4-based evaluation metric that correlates highly with human judgment.
- Function Name Recovery: Delivered a 6.7% absolute increase in token-level precision and a 7.4% absolute increase in recall.
- Efficiency: Because the large SCFM remains frozen and the binary encoder is relatively small, the alignment process is remarkably compute-efficient.
Limitations and Future Work
While ProRec marks a significant step forward, it currently focuses on intra-procedure analysis (individual functions). In real-world reverse engineering, understanding how functions call each other (the call graph) is vital. Additionally, the current study focused on unoptimized (O0) code. Future work will need to address how higher optimization levels—which alter code structure more drastically—affect the probing process, potentially requiring more sophisticated "prober" architectures than the straightforward MLP used here.
Summary updated