Che cos’è PyGhidra
PyGhidra è la libreria ufficiale per usare l’API di Ghidra da CPython 3 nativo. Progetti, programmi, simboli e analisi entrano in workflow Python riproducibili.
PyGhidra è la libreria ufficiale per usare l’API di Ghidra da CPython 3 nativo. Progetti, programmi, simboli e analisi entrano in workflow Python riproducibili.
Requisiti e versioni
La versione corrente è PyGhidra 3.1.0, pubblicata il 14 maggio 2026. Richiede Python 3.9 o successivo, Ghidra 12.0 o successivo e JDK 21.
La versione corrente è PyGhidra 3.1.0, pubblicata il 14 maggio 2026. Richiede Python 3.9 o successivo, Ghidra 12.0 o successivo e JDK 21.
Installare PyGhidra
Crea un ambiente virtuale dedicato. Installa da PyPI o usa il pacchetto offline ufficiale. Non servono installer EXE di terze parti.
Crea un ambiente virtuale dedicato. Installa da PyPI o usa il pacchetto offline ufficiale. Non servono installer EXE di terze parti.
- 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
Collegare Ghidra
Imposta GHIDRA_INSTALL_DIR sulla radice estratta oppure passa install_dir a pyghidra.start().
Imposta GHIDRA_INSTALL_DIR sulla radice estratta oppure passa install_dir a pyghidra.start().
GHIDRA_INSTALL_DIR=<path-to-ghidra-root>
Prima automazione
Avvia Ghidra una volta per processo, apri un campione autorizzato in un contesto e salva i risultati fuori dall’installazione.
Avvia Ghidra una volta per processo, apri un campione autorizzato in un contesto e salva i risultati fuori dall’installazione.
from pathlib import Path
import pyghidra
with pyghidra.open_program(Path('sample.exe')) as api:
print(api.getCurrentProgram().getName())
Problemi comuni
Controlla Python, java -version, radice Ghidra e versioni. Tratta binari e script esterni come non affidabili.
Controlla Python, java -version, radice Ghidra e versioni. Tratta binari e script esterni come non affidabili.
| 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 è la libreria ufficiale per usare l’API di Ghidra da CPython 3 nativo. Progetti, programmi, simboli e analisi entrano in workflow Python riproducibili.
Which Python version is required?
Python 3.9 or later.
Why can it not find Ghidra?
Imposta GHIDRA_INSTALL_DIR sulla radice estratta oppure passa install_dir a 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.