arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.06530cs.SE
收藏

利用大型语言模型精化解码后的C代码

Refining Decompiled C Code with Large Language Models

Wai Kin Wong, Huaijin Wang, Zongjie Li, Zhibo Liu, Shuai Wang, Qiyi Tang, Sen Nie, Shi Wu

AI总结:

本文研究利用大型语言模型增强C语言反编译器输出,提出两步混合方法以提升代码可重新编译性,在测试集上实现超过75%的重新编译成功率,而IDA-Pro原始输出均无法重新编译。

摘要:

C语言反编译器将可执行文件转换为源代码。恢复出的C源代码在重新编译后,预期能够生成与原始可执行文件功能相同的可执行文件。经过二十多年的发展,C语言反编译器已在生产环境中被广泛用于支持逆向工程应用。尽管C语言反编译器发展迅速,但人们普遍认为反编译器的输出主要用于人工阅读,并不适合自动重新编译。通常,需要大量人工工作来修复反编译器输出,才能使其被正确重新编译和执行。本文的动机源于大型语言模型(LLMs)在理解密集自然语言语料方面的近期成功。为了减轻修复反编译器输出时繁琐、昂贵且常常容易出错的人工工作,我们研究了利用LLMs增强反编译器输出的可行性,从而提供可重新编译的反编译结果。需要注意的是,与以往专注于提高反编译器输出可读性(例如恢复类型/变量名)的工作不同,我们专注于增强反编译器输出的可重新编译性,即生成能够被重新编译为与原始可执行文件功能相同的可执行文件的代码。我们进行了一项初步研究,以刻画重新编译事实上的商业C语言反编译器——IDA-Pro——输出所面临的障碍。随后,我们提出了一种两步混合方法,利用LLMs增强反编译器输出。我们在一组流行的C语言测试用例上评估了我们的方法,结果表明,我们的方法能够以适度的努力实现超过75%的高重新编译成功率,而IDA-Pro的原始输出均无法被重新编译。最后,我们讨论了该方法的局限性以及有前景的未来研究方向。

英文摘要:

A C decompiler converts an executable into source code. The recovered C source code, once re-compiled, is expected to produce an executable with the same functionality as the original executable. With over twenty years of development, C decompilers have been widely used in production to support reverse engineering applications. Despite the prosperous development of C decompilers, it is widely acknowledged that decompiler outputs are mainly used for human consumption, and are not suitable for automatic recompilation. Often, a substantial amount of manual effort is required to fix the decompiler outputs before they can be recompiled and executed properly. This paper is motived by the recent success of large language models (LLMs) in comprehending dense corpus of natural language. To alleviate the tedious, costly and often error-prone manual effort in fixing decompiler outputs, we investigate the feasibility of using LLMs to augment decompiler outputs, thus delivering recompilable decompilation. Note that different from previous efforts that focus on augmenting decompiler outputs with higher readability (e.g., recovering type/variable names), we focus on augmenting decompiler outputs with recompilability, meaning to generate code that can be recompiled into an executable with the same functionality as the original executable. We conduct a pilot study to characterize the obstacles in recompiling the outputs of the de facto commercial C decompiler -- IDA-Pro. We then propose a two-step, hybrid approach to augmenting decompiler outputs with LLMs. We evaluate our approach on a set of popular C test cases, and show that our approach can deliver a high recompilation success rate to over 75% with moderate effort, whereas none of the IDA-Pro's original outputs can be recompiled. We conclude with a discussion on the limitations of our approach and promising future research directions.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑