Skip to main content
QUICK REVIEW

[论文解读] Extending Source Code Pre-Trained Language Models to Summarise Decompiled Binaries

Ali Al-Kaswan, Toufique Ahmed|arXiv (Cornell University)|Jan 4, 2023
Software Engineering Research被引用 5
一句话总结

本文提出 BinT5,一种针对反汇编二进制函数摘要的微调 CodeT5 模型,采用 CAPYBARA——一个包含 214K 个跨编译器优化级别的反汇编函数-文档对的新数据集。BinT5 在反汇编代码上的 BLEU-4 得分达到 60.83,在混淆反汇编代码上的得分达到 44.21,表明预训练源代码模型可有效扩展至二进制逆向工程任务,尽管标识符减少导致性能略有下降,但依然表现稳健。

ABSTRACT

Reverse engineering binaries is required to understand and analyse programs for which the source code is unavailable. Decompilers can transform the largely unreadable binaries into a more readable source code-like representation. However, reverse engineering is time-consuming, much of which is taken up by labelling the functions with semantic information. While the automated summarisation of decompiled code can help Reverse Engineers understand and analyse binaries, current work mainly focuses on summarising source code, and no suitable dataset exists for this task. In this work, we extend large pre-trained language models of source code to summarise decompiled binary functions. Furthermore, we investigate the impact of input and data properties on the performance of such models. Our approach consists of two main components; the data and the model. We first build CAPYBARA, a dataset of 214K decompiled function-documentation pairs across various compiler optimisations. We extend CAPYBARA further by generating synthetic datasets and deduplicating the data. Next, we fine-tune the CodeT5 base model with CAPYBARA to create BinT5. BinT5 achieves the state-of-the-art BLEU-4 score of 60.83, 58.82, and 44.21 for summarising source, decompiled, and synthetically stripped decompiled code, respectively. This indicates that these models can be extended to decompiled binaries successfully. Finally, we found that the performance of BinT5 is not heavily dependent on the dataset size and compiler optimisation level. We recommend future research to further investigate transferring knowledge when working with less expressive input formats such as stripped binaries.

研究动机与目标

  • 为解决二进制逆向工程中反汇编二进制函数摘要缺乏数据集和模型这一关键问题。
  • 将预训练的源代码语言模型(特别是 CodeT5)扩展至生成反汇编二进制函数的自然语言摘要。
  • 研究输入格式(如反汇编代码与剥离代码)、编译器优化级别以及数据质量(如重复项、标识符移除)对摘要性能的影响。
  • 建立一个基准数据集 CAPYBARA,用于训练和评估二进制代码摘要模型。
  • 探索将源代码 NLP 技术迁移至反编译器输出的低表达性、语法贫乏代码的可行性。

提出的方法

  • 构建了 CAPYBARA,一个大规模数据集,包含 214K 个对齐的反汇编函数与文档对,数据来自多个编译器优化级别的开源项目。
  • 通过移除标识符并去重,对 CAPYBARA 进行增强,创建出‘半剥离’变体,以模拟真实世界逆向工程中的挑战。
  • 在 CAPYBARA 上微调 CodeT5 base 模型,训练出 BinT5,一种用于代码摘要的序列到序列 Transformer 模型。
  • 使用标准指标(BLEU-4、ROUGE、BERTScore)评估 BinT5,并分析其在不同输入变体(如剥离代码和混淆代码)下的性能表现。
  • 通过消融研究分析数据集规模、重复率以及编译器优化影响,以评估模型的鲁棒性与数据效率。
  • 采用迁移学习,将预训练于源代码的模型适配至反汇编二进制领域,利用其学习到的语义与句法模式。
Figure 2 : Data Collection Pipeline
Figure 2 : Data Collection Pipeline

实验结果

研究问题

  • RQ1预训练的源代码语言模型能否被有效微调以摘要反汇编二进制函数?
  • RQ2反汇编代码中标识符的存在或缺失如何影响代码摘要模型的性能?
  • RQ3编译器优化级别对反汇编代码质量及后续摘要性能有何影响?
  • RQ4在二进制代码摘要背景下,模型对数据重复和数据集规模的敏感程度如何?
  • RQ5在反汇编代码上训练的模型,能在多大程度上泛化至剥离或混淆的二进制代码?

主要发现

  • BinT5 在反汇编代码上的 BLEU-4 得分为 60.83,表明其在标准代码摘要基准上表现强劲。
  • 在混淆反汇编代码上的 BLEU-4 得分为 44.21,表明尽管性能有所下降,但在语法表达性降低的情况下仍具有效性。
  • 在剥离代码上的性能显著降低,但 BinT5 在‘半剥离’代码(即移除标识符的反汇编代码)上仍取得 58.82 的 BLEU-4 得分,表明标识符恢复对模型成功至关重要。
  • 模型对数据重复表现出鲁棒性,重复项虽有一定影响但并非决定性因素,表明高质量数据比数据量更为关键。
  • BinT5 仅需 CAPYBARA 数据集的一小部分即可有效微调,表明其具备强大的数据效率,适用于低资源场景。
  • 本研究证实,源代码预训练模型可成功扩展至反汇编二进制领域,标志着代码摘要技术首次应用于二进制逆向工程。
Figure 4 : Tokens in source C and decompiled code
Figure 4 : Tokens in source C and decompiled code

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。