用量化可读性指标提升逆向工程中反编译代码的可读性
LLM Agent-Assisted Reverse Engineering with Quantitative Readability Metrics
- 引入可读性评分框架,结合结构与语言特征综合评估代码质量
- 实验证明该方法在不牺牲功能正确性的前提下显著提升代码可读性
- 适合从事逆向工程、代码优化或AI辅助软件分析的研究者参考
自动反编译器生成的功能正确但可读性差的C代码是逆向工程中的常见问题。本文聚焦于改进反编译代码可读性的阶段,提出基于量化指标引导的LLM代理方法。研究分三阶段:第一阶段(Ghidra MCP驱动)因缺乏定量指导导致覆盖不全、效果不一致;第二阶段仅依赖结构相似性验证,发现代理会以牺牲可读性为代价优化指标;第三阶段提出量化可读性评分(QRS)框架,融合结构相似性阈值与三项独立子指标——词汇意外度(Lexical Surprisal)、结构简洁性(Structural Simplicity)和表达地道性(Idiomatic Quality)。实验表明,QRS引导的精炼能实现针对性可读性提升,且保持功能正确。文章简要讨论了整个逆向工程流程(二进制提升、反编译清理、功能等价性验证),但未深入展开。
原文摘要 · Abstract (English)
Automatic decompilers produce functionally correct but often unreadable C code. This paper addresses one stage of the reverse engineering workflow: improving the readability of decompiled code using LLM agents guided by quantitative metrics. We present a three-phase research evolution. Phase 1 (tool-driven steering via Ghidra MCP) suffered from incomplete coverage and inconsistent improvements due to lack of quantitative guidance. Phase 2 (structural similarity validation alone) revealed that agents optimize for metrics in unintended ways, producing structurally equivalent but less readable code. Our contribution is the Quantitative Readability Score (QRS) framework, a composite metric combining a structural similarity gate with three independent readability sub-metrics (Lexical Surprisal, Structural Simplicity, and Idiomatic Quality). We demonstrate that QRS-guided refinement enables LLM agents to make targeted readability improvements without sacrificing correctness. We provide a discussion of the broader reverse engineering workflow (binary lifting, decompilation cleanup, and achieving functional equivalence) as context, however, it remains out of scope.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。