Ghidrathon 项目教程

随笔3周前发布 诚诚
35 0 0

Ghidrathon 项目教程

GhidrathonThe FLARE team’s open-source extension to add Python 3 scripting to Ghidra.项目地址:https://gitcode.com/gh_mirrors/gh/Ghidrathon

项目介绍

Ghidrathon 是一个由 Mandiant 的 FLARE 团队开发的开放源代码扩展,旨在为 Ghidra 添加 Python 3 脚本功能。Ghidra 原生支持 Java 和 Jython 脚本,但由于许多开源分析工具(如 capa、Unicorn Engine、angr 等)是用 Python 3 编写的,Ghidrathon 的开发填补了这一空白,使得这些工具可以直接在 Ghidra 中使用。

项目快速启动

安装 Ghidrathon

  1. 下载并解压最新版本的 Ghidrathon

    • 从 Ghidrathon GitHub 发布页面 下载最新版本并解压。
  2. 安装依赖

    • 使用你希望与 Ghidrathon 一起使用的 Python 解释器执行以下命令(requirements.txtghidrathon_configure.py 包含在发布中):
      1. python -m pip install -r requirements.txt

      2. python ghidrathon_configure.py <absolute_path_to_ghidra_install_dir>

配置 Ghidra

  • 确保你的 Ghidra 版本 >= 10.3.2,并且 Java 版本 >= 17.0.0。
  • 将 Ghidrathon 解压到 Ghidra 的 Extensions 目录中,并重启 Ghidra。

应用案例和最佳实践

使用第三方 Python 模块

Ghidrathon 允许你在 Ghidra 中使用第三方 Python 模块。例如,你可以安装并使用 Unicorn 来模拟 ARM 代码:

  1. 安装 Unicorn

    pip install unicorn
    

  2. 在 Ghidra 中使用 Unicorn

    • 在 Ghidra 的 Python 脚本中导入并使用 Unicorn:
      1. from unicorn import *

      2. from unicorn.arm_const import *

编写 Ghidra Python 3 脚本

Ghidrathon 提供了与 Ghidra 的 Java 和 Jython 扩展类似的脚本体验,包括访问 GhidraScript 状态实例变量(如 currentProgram)和 FlatProgramAPI 方法(如 findBytes):

  1. from ghidra.program.model.address import Address

  2. def find_bytes(pattern):

  3. current_program = state.getCurrentProgram()

  4. address_set = current_program.getAddressFactory().getAddressSet()

  5. return current_program.getMemory().findBytes(address_set.getMinAddress(), pattern)

典型生态项目

capa

capa 是一个用于分析可执行文件以识别其功能的开源工具。通过 Ghidrathon,你可以在 Ghidra 中直接使用 capa 进行分析:

  1. 安装 capa

    pip install flare-capa
    

  2. 在 Ghidra 中使用 capa

    • 编写一个 Ghidra Python 脚本来调用 capa:
      import capa.main
      

Unicorn Engine

Unicorn Engine 是一个多平台、多架构的 CPU 仿真框架。通过 Ghidrathon,你可以在 Ghidra 中使用 Unicorn 进行代码仿真:

  1. 安装 Unicorn Engine

    pip install unicorn
    

  2. 在 Ghidra 中使用 Unicorn Engine

    • 编写一个 Ghidra Python 脚本来使用 Unicorn:
      1. from unicorn import *

      2. from unicorn.arm_const import *

通过这些案例和最佳实践,你可以充分利用 Ghidrathon 在 Ghidra 中使用 Python 3 进行高级分析和脚本编写。

GhidrathonThe FLARE team’s open-source extension to add Python 3 scripting to Ghidra.项目地址:https://gitcode.com/gh_mirrors/gh/Ghidrathon

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...