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.
翻译:C语言反编译器能将可执行文件转换为源代码。恢复后的C源代码经重编译后,应生成与原可执行文件功能相同的可执行文件。经过二十余年发展,C反编译器已广泛应用于生产环境以支持逆向工程。尽管反编译器发展迅速,但业界公认其输出主要用于人工阅读,并不适合自动重编译。通常需要大量人工修复才能使反编译器输出实现重编译与正确执行。受大型语言模型在自然语言密集语料理解方面的最新成功启发,为缓解修复反编译器输出过程中繁琐、昂贵且易错的人工工作,本文探究利用LLM增强反编译器输出的可行性,从而生成可重编译的反编译结果。需要说明的是,与既往侧重提升可读性(如恢复类型/变量名)的研究不同,本文聚焦于提升反编译器输出的可重编译性——即生成可重编译为与原可执行文件功能相同代码的程序。我们通过先导研究剖析了实际商业C反编译器IDA-Pro输出不可重编译的障碍,进而提出一种结合LLM的双阶段混合增强方法。基于主流C语言测试用例的评估表明,该方案能以适度工作量实现超过75%的高重编译成功率,而IDA-Pro原始输出完全无法重编译。最后我们讨论了当前方法的局限性与未来研究方向。