PyGhidraとは
PyGhidraはネイティブCPython 3からGhidra APIを利用する公式ライブラリです。プロジェクト、プログラム、シンボル、解析機能を再現可能なPython処理へ組み込めます。
PyGhidraはネイティブCPython 3からGhidra APIを利用する公式ライブラリです。プロジェクト、プログラム、シンボル、解析機能を再現可能なPython処理へ組み込めます。
要件と確認済みバージョン
現行版は2026年5月14日公開のPyGhidra 3.1.0です。Python 3.9以降、Ghidra 12.0以降、対応するJDK 21が必要です。
現行版は2026年5月14日公開のPyGhidra 3.1.0です。Python 3.9以降、Ghidra 12.0以降、対応するJDK 21が必要です。
インストール方法
専用仮想環境を作り、PyPIまたは公式Ghidra配布物内のオフラインパッケージから導入します。第三者EXEは不要です。
専用仮想環境を作り、PyPIまたは公式Ghidra配布物内のオフラインパッケージから導入します。第三者EXEは不要です。
- 1
Virtual environment
Isolate dependencies.
python -m venv .venv - 2
Install
Use the active interpreter.
python -m pip install --upgrade pyghidra==3.1.0 - 3
Offline option
Use the official bundled package.
python -m pip install --no-index -f <GhidraInstallDir>/Ghidra/Features/PyGhidra/pypkg/dist pyghidra
Ghidraとの接続
GHIDRA_INSTALL_DIRを展開済みGhidraルートへ設定するか、pyghidra.start()へinstall_dirを渡します。
GHIDRA_INSTALL_DIRを展開済みGhidraルートへ設定するか、pyghidra.start()へinstall_dirを渡します。
GHIDRA_INSTALL_DIR=<path-to-ghidra-root>
最初の自動解析
Pythonプロセスごとに一度起動し、解析権限のあるサンプルをコンテキスト内で開き、結果を本体外へ保存します。
Pythonプロセスごとに一度起動し、解析権限のあるサンプルをコンテキスト内で開き、結果を本体外へ保存します。
from pathlib import Path
import pyghidra
with pyghidra.open_program(Path('sample.exe')) as api:
print(api.getCurrentProgram().getName())
よくある問題
Python実行環境、java -version、Ghidraルート、互換性を確認します。外部バイナリやスクリプトは信頼しない前提で扱います。
Python実行環境、java -version、Ghidraルート、互換性を確認します。外部バイナリやスクリプトは信頼しない前提で扱います。
| Symptom | Cause | Check |
|---|---|---|
| Import error | Wrong environment | python -m pip show pyghidra |
| Java error | Wrong JDK | java -version |
| Path error | Wrong root | GHIDRA_INSTALL_DIR |
| API mismatch | Version boundary | PyGhidra 3.x + Ghidra 12.0+ |
PyGhidra FAQ
Is PyGhidra included with Ghidra?
PyGhidraはネイティブCPython 3からGhidra APIを利用する公式ライブラリです。プロジェクト、プログラム、シンボル、解析機能を再現可能なPython処理へ組み込めます。
Which Python version is required?
Python 3.9 or later.
Why can it not find Ghidra?
GHIDRA_INSTALL_DIRを展開済みGhidraルートへ設定するか、pyghidra.start()へinstall_dirを渡します。
Does it replace analyzeHeadless?
No. Choose the workflow that fits the pipeline.
Is PyGhidra MCP the same project?
No. MCP tools are separate projects.