rizinorg/rz-ghidra
GitHub: rizinorg/rz-ghidra
将 Ghidra 反编译能力集成到 Rizin 的轻量级插件,解决跨平台反编译与架构扩展问题。
Stars: 929 | Forks: 99

# rz-ghidra
这是用于 [Rizin](https://github.com/rizinorg/rizin) 的 Ghidra 反编译器和 Sleigh 指令集反汇编器的集成。
它完全基于 Ghidra 的反编译部分,而该部分是纯 C++ 编写的,因此根本不需要 Ghidra 本身,并且插件可以独立构建。
该项目最初针对 radare2 在 r2con 2019 上以 Cutter 演讲的形式呈现:[https://youtu.be/eHtMiezr7l8?t=950](https://youtu.be/eHtMiezr7l8?t=950)
## 用法
```
Usage: pdg # Native Ghidra decompiler plugin
| pdg # Decompile current function with the Ghidra decompiler
| pdgd # Dump the debug XML Dump
| pdgx # Dump the XML of the current decompiled function
| pdgj # Dump the current decompiled function as JSON
| pdgo # Decompile current function side by side with offsets
| pdgs # Display loaded Sleigh Languages
| pdg* # Decompiled code is returned to rizin as comment
```
以下配置变量(用于 `e` 命令)可用于调整 rz-ghidra 的行为:
```
ghidra.cmt.cpp: C++ comment style
ghidra.cmt.indent: Comment indent
ghidra.indent: Indent increment
ghidra.lang: Custom Sleigh ID to override auto-detection (e.g. x86:LE:32:default)
ghidra.linelen: Max line length
ghidra.nl.brace: Newline before opening '{'
ghidra.nl.else: Newline before else
ghidra.sleighhome: SLEIGHHOME
```
在此,`ghidra.sleighhome` 必须指向一个包含 `*.sla`、`*.lspec` 等文件的目录,
这些文件是针对应由反编译器支持的架构。如果使用 rz-pm 包或以下安装说明进行设置,则会自动完成此配置。
## 构建
首先,确保获取并更新此仓库中包含的子模块:
```
git submodule init
git submodule update
```
然后,可以按如下方式构建并安装 Rizin 插件:
```
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
make
make install
```
在此,将 `CMAKE_INSTALL_PREFIX` 设置为 Rizin 可以加载插件的路径。
安装步骤是必要的,因为插件会安装所需的 Sleigh 文件。
如果使用 Rizin 的 git 版本,请还将 `CMAKE_PREFIX_PATH` 设置为 Rizin 的安装目录。
若要同时构建 Cutter 插件,必须已从源代码安装 Cutter,并指定某个前缀路径,
可通过 `-DCMAKE_PREFIX_PATH=
` 可选指定,然后在 cmake 中传递 `-DBUILD_CUTTER_PLUGIN=ON` 以启用插件:
```
/my/path/rz-ghidra> mkdir build && cd build
/my/path/rz-ghidra/build> cmake -DBUILD_CUTTER_PLUGIN=ON -DCMAKE_PREFIX_PATH=/path/to/cutter/prefix -DCMAKE_INSTALL_PREFIX=~/.local ..
/my/path/rz-ghidra/build> make && make install
```
默认情况下,Cutter 插件将安装在当前用户主目录中自动选择的路径下。
可通过 `-DCUTTER_INSTALL_PLUGDIR` 覆盖此路径。
## 版本控制与 Rizin 兼容性
Rizin 的 C API 演进迅速,因此必须明确说明 rz-ghidra 的哪些版本与哪些 Rizin 版本兼容:
在使用 Rizin 和 rz-ghidra 的 git 版本时:
* rz-ghidra 的 `dev` 分支跟随 Rizin 的 `dev` 分支。
* rz-ghidra 的 `stable` 分支跟随 Rizin 的 `stable` 分支。
关于版本发布,rz-ghidra 通常会与 Rizin 同时发布,
并且经常使用相同的版本号(但不保证,因此不要依赖这些数字!)。
此外,每个 Rizin 版本都会创建一个类似 `rz-0.1.2` 的标签,精确指向对应的 rz-ghidra 版本,
并表明该版本与指定的 Rizin 版本兼容。
这些标签可供发行维护人员查找如何设置依赖项。
## 许可证
请注意,本插件在 **LGPLv3** 下可用,
其限制比 Ghidra 的许可证更严格!
本程序是自由软件:你可以重新分发它和/或修改
它在 GNU 较宽松通用公共许可协议的条款下发布,
由自由软件基金会发布,版本 3 或(由你选择)任何后续版本。
本程序的分发希望它将有用,
但没有任何担保;甚至没有隐含的适销性或特定用途适用性的担保。
请参阅
GNU 较宽松通用公共许可协议 获取更多细节。
你应该已经收到了一份 GNU 较宽松通用公共许可协议的副本。
如果没有,请参见 。标签:Amass, Bash脚本, C++, Cloudflare Workers, Decompiler, Decompiler Integration, Disassembler, Findomain, Ghidra, Ghidra decompiler, Reverse Engineering, Rizin, Rizin plugin, Sleigh, Sleigh Disassembler, URL提取, Wayback Machine, 二进制分析, 云安全监控, 云安全运维, 云资产清单, 反汇编, 反编译, 威胁狩猎, 开源安全工具, 插件, 数据擦除, 逆向工程, 逆向工程平台, 集成, 静态分析