Présentation de PyGhidra
PyGhidra est la bibliothèque officielle pour utiliser l’API de Ghidra depuis CPython 3 natif. Elle intègre projets, programmes, symboles et analyses dans des workflows Python reproductibles.
PyGhidra est la bibliothèque officielle pour utiliser l’API de Ghidra depuis CPython 3 natif. Elle intègre projets, programmes, symboles et analyses dans des workflows Python reproductibles.
Prérequis et versions
La version actuelle est PyGhidra 3.1.0, publiée le 14 mai 2026. Elle demande Python 3.9 ou plus récent, Ghidra 12.0 ou plus récent et un JDK 21 compatible.
La version actuelle est PyGhidra 3.1.0, publiée le 14 mai 2026. Elle demande Python 3.9 ou plus récent, Ghidra 12.0 ou plus récent et un JDK 21 compatible.
Installer PyGhidra
Créez un environnement virtuel dédié. Installez depuis PyPI ou utilisez le paquet hors ligne de la distribution officielle. N’utilisez pas un EXE tiers.
Créez un environnement virtuel dédié. Installez depuis PyPI ou utilisez le paquet hors ligne de la distribution officielle. N’utilisez pas un EXE tiers.
- 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
Relier PyGhidra à Ghidra
GHIDRA_INSTALL_DIR doit viser la racine extraite de Ghidra. On peut aussi passer install_dir à pyghidra.start().
GHIDRA_INSTALL_DIR doit viser la racine extraite de Ghidra. On peut aussi passer install_dir à pyghidra.start().
GHIDRA_INSTALL_DIR=<path-to-ghidra-root>
Première automatisation
Démarrez Ghidra une fois par processus, ouvrez un échantillon autorisé dans un contexte et écrivez les résultats hors du dossier d’installation.
Démarrez Ghidra une fois par processus, ouvrez un échantillon autorisé dans un contexte et écrivez les résultats hors du dossier d’installation.
from pathlib import Path
import pyghidra
with pyghidra.open_program(Path('sample.exe')) as api:
print(api.getCurrentProgram().getName())
Problèmes fréquents
Vérifiez interpréteur Python, java -version, racine Ghidra et compatibilité. Considérez binaires et scripts externes comme non fiables.
Vérifiez interpréteur Python, java -version, racine Ghidra et compatibilité. Considérez binaires et scripts externes comme non fiables.
| 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 est la bibliothèque officielle pour utiliser l’API de Ghidra depuis CPython 3 natif. Elle intègre projets, programmes, symboles et analyses dans des workflows Python reproductibles.
Which Python version is required?
Python 3.9 or later.
Why can it not find Ghidra?
GHIDRA_INSTALL_DIR doit viser la racine extraite de Ghidra. On peut aussi passer install_dir à pyghidra.start().
Does it replace analyzeHeadless?
No. Choose the workflow that fits the pipeline.
Is PyGhidra MCP the same project?
No. MCP tools are separate projects.