[论文解读] Improving type information inferred by decompilers with supervised machine learning
本文提出了一种监督式机器学习方法,通过在大规模C源代码及其对应二进制文件的数据集上训练模型,以提升反汇编器中的类型推断能力。通过在代码中插入标记,将二进制模式与高级类型信息关联,该系统在预测函数返回类型方面实现了79.1%的F1得分,显著优于现有反汇编器(30% F1得分),同时为反汇编器集成提供了可操作的二进制模式文档。
In software reverse engineering, decompilation is the process of recovering source code from binary files. Decompilers are used when it is necessary to understand or analyze software for which the source code is not available. Although existing decompilers commonly obtain source code with the same behavior as the binaries, that source code is usually hard to interpret and certainly differs from the original code written by the programmer. Massive codebases could be used to build supervised machine learning models aimed at improving existing decompilers. In this article, we build different classification models capable of inferring the high-level type returned by functions, with significantly higher accuracy than existing decompilers. We automatically instrument C source code to allow the association of binary patterns with their corresponding high-level constructs. A dataset is created with a collection of real open-source applications plus a huge number of synthetic programs. Our system is able to predict function return types with a 79.1% F1-measure, whereas the best decompiler obtains a 30% F1-measure. Moreover, we document the binary patterns used by our classifier to allow their addition in the implementation of existing decompilers.
研究动机与目标
- 提升反汇编器在类型信息推断方面的准确性,特别是针对函数返回类型。
- 解决从二进制代码中恢复高级类型语义的挑战,该过程因编译器优化而固有地存在信息丢失。
- 构建一个大规模、带标签的二进制模式数据集,与高级类型信息配对,用于训练机器学习模型。
- 识别并记录可复用的二进制模式,以区分相同大小和表示形式的类型。
- 实现学习到的模式在现有反汇编器中的集成,以增强其逆向工程能力。
提出的方法
- 对C源代码进行插桩,将二进制机器码模式与高级类型构造(如int、float、bool和struct)关联。
- 结合真实开源C应用程序和使用Microsoft Visual C++为32位Windows编译的合成程序,生成数据集。
- 在二进制操作码序列和函数调用后指令模式上训练多种监督分类模型,特别是梯度提升模型,以预测返回类型。
- 通过特征工程提取RET(返回)和POST CALL(调用后)模式,以编码值如何传递回调用者。
- 应用基于规则的模式提取方法,识别与特定类型相对应的高置信度、特定二进制指令序列。
- 在未见过的代码上验证模型,以确保其在训练数据之外的泛化能力,使用F1得分作为主要评估指标。
实验结果
研究问题
- RQ1监督式机器学习能否在反汇编器中实现超越当前最先进工具的函数返回类型推断准确性?
- RQ2哪些特定的二进制操作码模式与int、float、bool和struct等不同高级类型相关联?
- RQ3RET和POST CALL指令模式如何帮助区分相同大小和表示形式的类型?
- RQ4学习到的模式是否能够泛化并复用于增强现有反汇编器?
- RQ5当类型共享相同二进制大小和表示形式时,模型性能如何变化,尤其是在这些类型之间?
主要发现
- 所提出的系统在未见过的代码上预测函数返回类型的F1得分为79.1%,显著优于最佳现有反汇编器(仅30% F1得分)。
- 梯度提升是此任务中最有效的分类算法,优于随机森林和XGBoost等其他模型。
- 系统识别出高置信度的二进制模式,如特定的操作码序列和调用后指令使用方式,可区分float与double,或bool与int等类型。
- 结合RET和POST CALL模式可提高分类置信度,其中一条规则通过同时采用两种序列实现了100%的置信度。
- 该方法成功识别并记录了Microsoft C编译器使用的代码生成模板,例如通过指针返回结构体以及将比较结果作为整数返回的模式。
- 数据集和模式已公开发布,可直接集成到现有反汇编器中,以提升类型推断能力。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。