emsec/hal

GitHub: emsec/hal

一个面向 FPGA 和 ASIC 网表的硬件逆向工程与分析框架,提供图形化界面、数据流分析和模拟功能。

Stars: 785 | Forks: 92

# 欢迎使用 HAL! [![Ubuntu 22.04](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/c8800e5ed3200555.svg)](https://github.com/emsec/hal/actions/workflows/ubuntu22.04.yml) [![Ubuntu 24.04](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/b37afa218d200556.svg)](https://github.com/emsec/hal/actions/workflows/ubuntu24.04.yml) [![macOS](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/45f3202986200557.svg)](https://github.com/emsec/hal/actions/workflows/macOS.yml) [![Deploy Documentation](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/d9734b660e200558.svg)](https://github.com/emsec/hal/actions/workflows/releaseDoc.yml) [![Doc: C++](https://img.shields.io/badge/doc-c%2B%2B-orange)](https://emsec.github.io/hal/doc/) [![Doc: Python](https://img.shields.io/badge/doc-python-red)](https://emsec.github.io/hal/pydoc/) HAL \[/hel/\] 是一个全面的网表逆向工程和处理框架。 [![HAL Screenshot](https://raw.githubusercontent.com/emsec/hal/master/hal_screenshot.png "HAL Screenshot")](https://emsec.github.io/hal/hal_screenshot.html) # 导航 1. [简介](#introduction) 2. [构建说明](#build-instructions) 3. [快速入门指南](#quickstart) 4. [学术背景](#academic-context) # 简介 ## HAL 到底是什么? 几乎所有关于网表分析的现有研究都基于受检网表的图表示形式进行操作。 HAL 的核心正是提供了这一点:一个能够将任意来源(例如 FPGA 或 ASIC)的网表解析为基于图的网表表示的框架,并提供必要的内置工具用于遍历和分析其中包含的门和网。 我们的愿景是让 HAL 成为像 IDA 或 Ghidra 那样的硬件逆向工程工具。 我们希望 HAL 能为研究人员和分析师提供一个通用的基准,以提高研究结果的的可重复性,并抽象掉诸如网表解析等重复的基础任务。 - **高性能** 得益于优化的 C++ 核心 - **灵活性** 通过内置的 Python bindings 实现 - **模块化** 通过 C++ 插件系统实现 - **稳定性** 通过丰富的测试套件确保 HAL 由 [Max Planck Institute for Security and Privacy](https://www.mpi-sp.org) 的 Embedded Security 小组积极开发。 除了多个研究项目外,它也用于我们在波鸿鲁尔大学 (RUB) 开设的大学课程“Einführung ins Hardware Reverse Engineering”(硬件逆向工程入门)。 请注意,我们还在单独的[仓库](https://github.com/emsec/hal-benchmarks)中提供了一组用于评估网表逆向工程技术的**现代化**最先进基准电路。 ## 内置插件 本仓库包含一系列精选插件: - **GUI:** 功能丰富的 GUI,支持可视化网表检查和交互式分析 - 原生集成 Python shell,可访问 HAL Python bindings - 隔离特定的门或模块,以实现无干扰的检查 - 网表的交互式遍历 - 详细的小部件,提供有关受检网表各个方面的信息 - **Netlist Simulator:** 用于加载网表中任意部分的模拟器 - **Dataflow Analysis:** 我们的 dataflow analysis 插件 [DANA](https://eprint.iacr.org/2020/751.pdf),用于在非结构化网表中恢复高层寄存器 - **Graph Algorithms:** [igraph](https://igraph.org) 集成,可直接访问图论中的常用算法 - **Python Shell:** 一个命令行插件,用于生成预加载了 HAL Python bindings 的 Python shell - **VHDL & Verilog Parsers:** 增加了对将 VHDL 和 Verilog 文件作为网表输入格式进行解析的支持 - **Liberty Parser:** 增加了对标准 `liberty` 门库格式中任意门库的支持 - **VHDL & Verilog Writers:** 增加了对将(修改后的)网表序列化为可综合的 VHDL 或 Verilog 文件的支持 - **Gate Libraries:** 增加了对 XILINX Unisim 和 Simprim 门库的支持 ## 文档 关于 HAL 功能的用户视角综合文档可在我们的 [Wiki](https://github.com/emsec/hal/wiki) 中找到。此外,我们还提供完整的 [C++ API](https://emsec.github.io/hal/doc/) 和 [Python API](https://emsec.github.io/hal/pydoc/) 文档。 # 构建说明 有关如何构建 HAL 的说明,请参阅我们 [Wiki](https://github.com/emsec/hal/wiki/Building-HAL) 中的专门页面。 # 快速入门指南 安装 HAL 或构建 HAL,然后通过 `hal -g` 启动 GUI。你可以通过 `hal [--help|-h]` 列出所有可用选项。 我们在 `examples` 中包含了一些示例网表,并在 `plugins/example_gate_library` 中包含了相应示例门库的实现。 有关创建自己的门库的说明以及其他有用的教程,请查看 [wiki](https://github.com/emsec/hal/wiki)。 从 `examples` 目录加载库并开始探索图形表示。 使用集成的 Python shell 或 Python 脚本窗口进行交互。两者都具有(有限的)自动补全功能。 让我们列出所有的查找表并打印它们的布尔函数: ``` for gate in netlist.get_gates(): if "LUT" in gate.type.name: print("{} (id {}, type {})".format(gate.name, gate.id, gate.type.name)) print(" {}-to-{} LUT".format(len(gate.type.input_pins), len(gate.type.output_pins))) boolean_functions = gate.boolean_functions for name in boolean_functions: print(" {}: {}".format(name, boolean_functions[name])) print("") ``` 对于示例网表 `fsm.vhd`,这将打印: ``` FSM_sequential_STATE_REG_0_i_3_inst (id 4, type LUT6) 6-to-1 LUT O: (!I1 & !I2 & I3 & !I4 & I5) | (I0 & !I2) | (I0 & I1) | (I0 & I3) | (I0 & I4) | (I0 & I5) FSM_sequential_STATE_REG_0_i_2_inst (id 3, type LUT6) 6-to-1 LUT O: (I2 & I3 & I4 & !I5) | (I1 & !I5) | (I1 & !I4) | (I1 & !I3) | (I0 & I1) | (I1 & I2) FSM_sequential_STATE_REG_1_i_3_inst (id 6, type LUT6) 6-to-1 LUT O: (!I1 & I4 & !I5) | (!I1 & !I3 & I4) | (I0 & I4 & !I5) | (I0 & !I3 & I4) | (!I1 & I2 & I4) | (I0 & I2 & I4) | (!I2 & !I5) | (!I2 & !I4) | (!I2 & !I3) | (!I0 & !I4) | (!I0 & !I2) | (!I0 & !I1) | (I1 & !I4) | (I1 & !I2) | (I0 & I1) | (I3 & !I5) | (I3 & !I4) | (!I0 & I3) | (I1 & I3) | (I2 & I3) | (!I4 & I5) | (!I3 & I5) | (!I0 & I5) | (I1 & I5) | (I2 & I5) FSM_sequential_STATE_REG_1_i_2_inst (id 5, type LUT6) 6-to-1 LUT O: (!I0 & I1 & !I2 & I3 & I4 & !I5) | (I0 & !I2 & I3 & I4 & I5) OUTPUT_BUF_0_inst_i_1_inst (id 18, type LUT1) 1-to-1 LUT O: !I0 OUTPUT_BUF_1_inst_i_1_inst (id 20, type LUT2) 2-to-1 LUT O: (I0 & !I1) | (!I0 & I1) ``` # 贡献 欢迎你为 HAL 的开发做出贡献。随时可以通过 github 提交新的 pull request。 在此之前,请考虑运行静态检查 + `clang format`。 你也可以在任何提交之前将这些检查安装为 git hooks。 ## 在本地运行静态检查和 clang format 要安装 clang-format hook,请安装 [git-hooks](https://github.com/icefox/git-hooks) 并运行: `git hooks --install` 通过以下命令启动 Docker 构建: `docker-compose run --rm hal-build` ## 生成更新日志 `git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s" --no-merges` # 学术背景 如果你在学术环境中使用 HAL,请使用下面的参考文献引用该框架: ``` @misc{hal, author = {{Embedded Security Group}}, publisher = {{Max Planck Institute for Security and Privacy}}, title = {{HAL - The Hardware Analyzer}}, year = {2019}, howpublished = {\url{https://github.com/emsec/hal}}, } ``` 也可以随意包含原始[paper](http://eprint.iacr.org/2017/783)。但是,我们注意到,自从论文中描述其原始原型以来,HAL 已经发生了巨大的变化。 因此,我们更倾向于引用上述条目。 ``` @article{2018:Fyrbiak:HAL, author = {Marc Fyrbiak and Sebastian Wallat and Pawel Swierczynski and Max Hoffmann and Sebastian Hoppach and Matthias Wilhelm and Tobias Weidlich and Russell Tessier and Christof Paar}, title = {{HAL-} The Missing Piece of the Puzzle for Hardware Reverse Engineering, Trojan Detection and Insertion}, journal = {IEEE Transactions on Dependable and Secure Computing}, year = {2018}, publisher = {IEEE}, howpublished = {\url{https://github.com/emsec/hal}} } ``` 为了概览我们要用 HAL 解决的挑战,请随意观看我们在 36C3 的[talk](https://media.ccc.de/v/36c3-10879-hal_-_the_open-source_hardware_analyzer)。 # 许可 HAL 根据 MIT 许可证授权,以鼓励与其他研究小组的合作以及来自行业的贡献。请参阅许可证文件以获取更多信息。 # 免责声明 HAL 最多只是 alpha 质量的软件。 使用风险自负。 我们反对任何恶意使用我们工具包的行为。
标签:ASIC, C++, DNS枚举, DNS重绑定攻击, EDA, FPGA, Python, SubJs, Wayback Machine, 半导体, 反汇编, 图论, 开源框架, 持续集成, 数字逻辑, 数据擦除, 无后门, 电路分析, 硬件分析, 硬件安全, 硬件木马检测, 网络安全, 网络安全工具, 网表逆向工程, 计算机工程, 调试插件, 逆向工具, 隐私保护, 集成电路