# PyLingual Python 字节码反编译器

> 面向 Python 3.6 及以后版本 CPython 字节码的研究型反编译器，将按版本训练的 Transformer 模型与控制流重建相结合。分段模型把字节码切分为语句，语句模型将每段翻译为源码，再由模板重建循环、条件分支、异常处理、with 块和 match 语句。生成结果会用目标 Python 版本重新编译，并与原字节码比较控制流，未通过的片段会改用其他分段方案重试；其设计见 IEEE S&P 2025 论文《PyLingual: Toward Perfect Decompilation of Evolving High-Level Languages》。

- 类型：工具
- 目标：应用 · 二进制
- 类别：原生分析工具
- 关联：基础工具
- 来源复核于：2026-10-19
- 收录于：2026-10-19
- 原始资源：<https://github.com/syssec-utd/pylingual>
- 一手来源：<https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/README.md>
- 目录页面：<https://awesomerea.org/zh/resources/pylingual/>
- 记录 JSON：<https://awesomerea.org/resources/pylingual/record.json>
- 英文版：[English](https://awesomerea.org/resources/pylingual/index.md)

## 使用条件与局限

- 审阅时的首个版本为 v0.0.1，发布于 2026-09-21，其发布说明称在独立的 pylingual_eval_dataset 上，Python 3.6–3.12 的反编译成功率约为 82–87%，3.13–3.15 约为 71%；这些均为项目自报数据。所审阅的 main 提交比该版本晚 67 个提交，声明的版本为 0.1.0。README 提醒，这份注重可读性的代码在控制流准确度上起初可能不及在线服务。
- 需从克隆的仓库用 uv tool install 安装；pyproject.toml 要求 Python 3.12+，并依赖 PyTorch、Transformers、Hugging Face Hub 和 xdis。各版本的分段模型和语句模型从 syssec-utd 的 Hugging Face 组织下载，使用未固定的 main 修订版；有 CUDA 时在 GPU 上运行，否则使用 CPU。各模型卡声明的许可证不一：3.12 语句模型标为 Apache-2.0，其分段模型则未声明。
- 检查重建结果需要用目标版本编译：uv 管理的解释器覆盖 3.8–3.15，3.6 和 3.7 则需要 pyenv 或 pyenv-win，可通过 --init-pyenv 安装。可选的 Redis 实例用于缓存模型预测，缓存键包含版本和规范化后的字节码，但不包含模型修订版。pylingual.io 网页服务是托管的替代方案，因此机密的 .pyc 文件应只用本地命令行处理。
- 采用 GPL-3.0-only 许可。通过控制流检查并不能证明恢复出的源码与原始源码完全一致，恢复出的代码仍归原权利人所有。

## 一手来源

1. <https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/README.md>
2. <https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/pyproject.toml>
3. <https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/pylingual/decompiler_config.yaml>
4. <https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/pylingual/decompiler.py>
5. <https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/pylingual/equivalence_check.py>
6. <https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/pylingual/models.py>
7. <https://github.com/syssec-utd/pylingual/tree/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/pylingual/control_flow_reconstruction/templates>
8. <https://github.com/syssec-utd/pylingual/blob/509ea92e560b2c2c99b0c9901bd33e404fbfb4b8/LICENSE>
9. <https://github.com/syssec-utd/pylingual/releases/tag/v0.0.1>
10. <https://huggingface.co/syssec-utd/py312-pylingual-v1-statement>
11. <https://doi.org/10.1109/SP61157.2025.00052>

## 同分区更多条目：原生二进制

- [Miasm 逆向工程框架](https://awesomerea.org/zh/resources/miasm/index.md) · 工具
- [HyperDbg 虚拟化辅助调试器](https://awesomerea.org/zh/resources/hyperdbg/index.md) · 工具
- [Kuna 智能体优先反编译器](https://awesomerea.org/zh/resources/kuna/index.md) · 工具
- [Binary Ninja 公开 API](https://awesomerea.org/zh/resources/binary-ninja-api/index.md) · 工具
- [capa 可执行文件功能识别工具](https://awesomerea.org/zh/resources/capa/index.md) · 工具
- [RetDec 可重定向机器码反编译器](https://awesomerea.org/zh/resources/retdec/index.md) · 工具

## 关于此条目

说明已依据一手来源复核。
原创说明采用 MIT 许可；外部项目、论文与素材保留各自的权利和许可。
