13

HAL:一款功能强大的硬件安全分析工具

 4 years ago
source link: https://www.freebuf.com/articles/terminal/221644.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

YvUFb2U.jpg!web

HAL是一款针对网关级网络设备列表的完整的逆向工程分析套件以及操作框架,该工具专注于提升网络安全人员的效率、可扩展性和可移植性。HAL附带了成熟的插件系统,允许安全研究人员在内核中引入任意功能。

RNNvqia.jpg!web

除了很多其他的研究项目之外,HAL还被应用于大学安全课程之中:《 硬件逆向工程概论 》。

功能介绍

 1、网络设备列表及其链接的自然有向图表示;
 2、支持自定义网关库;
 3、优化C++核心带来的高性能;
 4、模块化:可以编写自己的C++插件来进行有效的网表分析和操作;
 5、提供了功能丰富的用户操作界面,支持可视化检测以及交互式分析;
 6、集成了Python Shell,可用于跟网表元素交互以及访问GUI接口;
 7、该工具(v1.1.0)目前新增了针对Xilinx Unisim、Xilinx Simprim、Synopsys 90nm、GSCLIB 3.0和UMC 0.18μm库的支持;

API文档

C++文档:【 传送门

Python文档:【 传送门

工具安装

Ubuntu

HAL的release版本通过ppa发布,你可以从【 这里 】获取。

macOS

使用下列命令并通过 homebrew 安装HAL:

brew tap emsec/hal
brew install hal

构建指令

运行下列命令下载并安装HAL:

git clone https://github.com/emsec/hal.git && cd hal

./install_dependencies.sh

mkdir build && cd build

cmake

make

make install

macOS构建

需要使用一个支持OpenMP的编译器,我们可以通过下列命令安装:

brew install llvm

然后运行下列命令让cmake使用我们自定义的编译器:

cmake .. -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++

快速开始

广大研究人员可以通过命令“hal -g”来安装或构建HAL,并启动GUI界面。使用命令“hal [--help|-h]”可以查看工具所有可用的选项。我们在examples目录中提供了样本网表,以及用于分析的样本库,位于路径plugins/example_gate_library。

从examples目录加载一个代码库,并开启图形化分析功能。使用整合的Python Shell或Python脚本窗口来与目标进行交互。

我们可以枚举所有的lookup表,并输出相关信息:

from hal_plugins import libquine_mccluskey
qm_plugin = libquine_mccluskey.quine_mccluskey()
for gate in netlist.get_gates():
    if "LUT" in gate.type:
        print(gate.name + " (id "+str(gate.id) + ", type " + gate.type + ")")
        print("  " + str(len(gate.input_pin_types)) + "-to-" + str(len(gate.output_pin_types)) + " LUT")
        boolean_functions = qm_plugin.get_boolean_function_str(gate, False)
        for pin in boolean_functions:
            print("  " + pin + ": "+boolean_functions[pin])
        print("")

比如说针对fsm.vhd样本,输出结果如下:

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)
FSM_sequential_STATE_REG_0_i_2_inst (id 3, type LUT6)
  6-to-1 LUT
  O: (I2 I3 I4 ~I5) + (I1 I2) + (I0 I1) + (I1 ~I3) + (I1 ~I4) + (I1 ~I5)
FSM_sequential_STATE_REG_0_i_3_inst (id 4, type LUT6)
  6-to-1 LUT
  O: (~I1 ~I2 I3 ~I4 I5) + (I0 I5) + (I0 I4) + (I0 I3) + (I0 I1) + (I0 ~I2)
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)
FSM_sequential_STATE_REG_1_i_3_inst (id 6, type LUT6)
  6-to-1 LUT
  O: (I0 I2 I4) + (~I1 I2 I4) + (I0 ~I3 I4) + (~I1 ~I3 I4) + (I0 I4 ~I5) + (~I1 I4 ~I5) + (I2 I5) + (I2 I3) + (I1 I5) + (I1 I3) + (I0 I1) + (~I0 I5) + (~I0 I3) + (~I0 ~I1) + (I1 ~I2) + (~I0 ~I2) + (~I3 I5) + (~I2 ~I3) + (~I4 I5) + (I3 ~I4) + (I1 ~I4)

参考引用

如果你需要在学校或在学术研究条件下使用HAL,请使用下列引用方式来标记并使用该框架:

@misc{hal,

author = {{EmSec Chair for Embedded Security}},

publisher = {{Ruhr University Bochum}},

title = {{HAL - The Hardware Analyzer}},

year = {2019},

howpublished = {\url{ https://github.com/emsec/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的开发与发布遵循MIT开源许可证协议。

项目地址

HAL:【 GitHub传送门

* 参考来源: emsec ,FB小编Alpha_h4ck编译,转载请注明来自FreeBuf.COM


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK