Practical Source Code Recovery from Binary Functions Using Anchor-Based Retrieval and LLM Reasoning

· Source: Artificial Intelligence · Field: Technology & Digital — Software Development & Engineering, Artificial Intelligence & Machine Learning, Cybersecurity & Data Privacy · Depth: Expert, quick

Summary

A new practical pipeline has been developed for recovering source code from stripped binary functions, integrating reverse engineering, anchor-based source code retrieval, and large language model (LLM) reasoning. This method identifies source functions from a database rather than generating pseudocode. It operates by extracting anchors like strings, constants, and external calls using Ghidra, then retrieves candidate files via an inverted-index search. These candidates are narrowed to likely function snippets and re-ranked by an LLM using disassembly, decompiled code, and source metadata. Confident matches can further serve as anchors. Evaluated on a stripped, optimized tcpdump binary with a high-fidelity source code database, the pipeline achieved 95.2% assembly instruction coverage. Performance dropped to 35.5% instruction coverage on a GitHub-based retrieval database, primarily due to retrieval misses, indicating the importance of database quality.

Key takeaway

For Software Engineers or Reverse Engineers analyzing stripped binaries, this pipeline offers a robust approach to source code recovery. You should consider integrating anchor-based retrieval with LLM re-ranking, especially when a high-fidelity source code database is available, as it significantly boosts recovery accuracy. This method provides a practical alternative to traditional decompilation, improving understanding of complex binary functions.

Key insights

Combining anchor-based retrieval with LLM reasoning enables practical source code recovery from stripped binaries, excelling with high-quality databases.

Principles

Method

Extract anchors (strings, constants, calls) with Ghidra, retrieve candidates via inverted-index, narrow snippets, then re-rank using an LLM based on disassembly, decompiled code, and source metadata.

In practice

Topics

Best for: Research Scientist, AI Scientist, Machine Learning Engineer, Software Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Artificial Intelligence.