LLM4Decompile: Decompiling Binary Code with Large Language Models

📄 arXiv: 2403.05286v3 📥 PDF

作者: Hanzhuo Tan, Qi Luo, Jing Li, Yuqun Zhang

分类: cs.PL, cs.CL

发布日期: 2024-03-08 (更新: 2024-10-22)

期刊: Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing

DOI: 10.18653/v1/2024.emnlp-main.203

🔗 代码/项目: GITHUB


💡 一句话要点

提出LLM4Decompile以解决二进制代码反编译问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 二进制反编译 大型语言模型 代码可读性 机器学习 软件安全

📋 核心要点

  1. 现有的反编译工具如Ghidra生成的代码可读性差,执行效果不佳,限制了其应用。
  2. LLM4Decompile通过训练大型语言模型,直接反编译二进制代码,优化了传统反编译流程。
  3. 实验结果表明,LLM4Decompile在重执行率上超过了现有工具,且在精细调优后进一步提升了性能。

📝 摘要(中文)

反编译旨在将二进制代码转换为高级源代码,但传统工具如Ghidra常常生成难以阅读和执行的结果。基于大型语言模型(LLMs)的进展,我们提出了LLM4Decompile,这是第一个也是最大的开源LLM系列(1.3B到33B),专门用于反编译二进制代码。我们优化了LLM的训练过程,并引入了LLM4Decompile-End模型以直接反编译二进制代码。结果显示,这些模型在HumanEval和ExeBench基准测试中,重执行率超过GPT-4o和Ghidra超过100%。此外,我们改进了标准的精细调优方法,以有效提升LLM4Decompile-Ref模型的性能,使其在Ghidra反编译代码的基础上进一步提高了16.2%。LLM4Decompile展示了LLMs在二进制代码反编译领域的潜力,显著提升了可读性和可执行性,同时与传统工具互补以达到最佳效果。

🔬 方法详解

问题定义:本论文旨在解决二进制代码反编译的可读性和可执行性问题。现有工具如Ghidra在生成的代码质量上存在不足,导致用户难以理解和使用。

核心思路:论文提出的LLM4Decompile利用大型语言模型的强大能力,直接将二进制代码转换为高层次的源代码,从而提升反编译的质量和效率。通过优化训练过程,模型能够更好地理解和生成代码结构。

技术框架:LLM4Decompile的整体架构包括两个主要模块:LLM4Decompile-End模型用于直接反编译,LLM4Decompile-Ref模型用于精细调优和代码优化。训练过程中采用了大规模的二进制代码和对应的源代码数据集。

关键创新:最重要的技术创新在于首次将大型语言模型应用于二进制代码反编译,且通过优化训练流程和模型架构,显著提升了反编译结果的可读性和可执行性。

关键设计:在模型设计上,采用了多层Transformer结构,并在训练中引入了针对反编译任务的特定损失函数,以提高生成代码的质量和准确性。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

在实验中,LLM4Decompile的重执行率在HumanEval和ExeBench基准测试中超过了GPT-4o和Ghidra,提升幅度超过100%。此外,通过精细调优,LLM4Decompile-Ref模型在Ghidra生成的代码基础上又提升了16.2%的性能,显示出其在反编译领域的卓越能力。

🎯 应用场景

LLM4Decompile的研究成果在软件逆向工程、安全分析、恶意代码检测等领域具有广泛的应用潜力。其显著提升的反编译效果能够帮助开发者更好地理解和分析二进制程序,促进安全性和可维护性的提高。未来,该技术有望与其他工具结合,形成更强大的反编译解决方案。

📄 摘要(原文)

Decompilation aims to convert binary code to high-level source code, but traditional tools like Ghidra often produce results that are difficult to read and execute. Motivated by the advancements in Large Language Models (LLMs), we propose LLM4Decompile, the first and largest open-source LLM series (1.3B to 33B) trained to decompile binary code. We optimize the LLM training process and introduce the LLM4Decompile-End models to decompile binary directly. The resulting models significantly outperform GPT-4o and Ghidra on the HumanEval and ExeBench benchmarks by over 100% in terms of re-executability rate. Additionally, we improve the standard refinement approach to fine-tune the LLM4Decompile-Ref models, enabling them to effectively refine the decompiled code from Ghidra and achieve a further 16.2% improvement over the LLM4Decompile-End. LLM4Decompile demonstrates the potential of LLMs to revolutionize binary code decompilation, delivering remarkable improvements in readability and executability while complementing conventional tools for optimal results. Our code, dataset, and models are released at https://github.com/albertan017/LLM4Decompile