All Projects → VDOO-Connected-Trust → Ghidra Pyi Generator

VDOO-Connected-Trust / Ghidra Pyi Generator

Licence: apache-2.0
Generates `.pyi` type stubs for the entire Ghidra API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ghidra Pyi Generator

Efiseek
Ghidra analyzer for UEFI firmware.
Stars: ✭ 45 (-23.73%)
Mutual labels:  reverse-engineering
Bincat
Binary code static analyser, with IDA integration. Performs value and taint analysis, type reconstruction, use-after-free and double-free detection
Stars: ✭ 1,078 (+1727.12%)
Mutual labels:  reverse-engineering
Matire
Malware Analysis, Threat Intelligence and Reverse Engineering: LABS
Stars: ✭ 55 (-6.78%)
Mutual labels:  reverse-engineering
Pecli
CLI tool to analyze PE files
Stars: ✭ 46 (-22.03%)
Mutual labels:  reverse-engineering
Openmoonstone
Open source reimplementation of Moonstone: A Hard Day's Knight
Stars: ✭ 50 (-15.25%)
Mutual labels:  reverse-engineering
Frida Snippets
Hand-crafted Frida examples
Stars: ✭ 1,081 (+1732.2%)
Mutual labels:  reverse-engineering
Ida android script
some idapython scripts for android debugging.
Stars: ✭ 38 (-35.59%)
Mutual labels:  reverse-engineering
Darter
🕵️ Dart / Flutter VM snapshot analyzer
Stars: ✭ 57 (-3.39%)
Mutual labels:  reverse-engineering
Termux Apktool
Decompile and Recompile android aplication use termux without openjdk installed
Stars: ✭ 53 (-10.17%)
Mutual labels:  reverse-engineering
Mem
A collection of C++11 headers useful for reverse engineering
Stars: ✭ 56 (-5.08%)
Mutual labels:  reverse-engineering
Pjorion Deobfuscator
A deobfuscator for PjOrion, python cfg generator and more
Stars: ✭ 48 (-18.64%)
Mutual labels:  reverse-engineering
Wslreverse
Experiments with hidden COM interface and LxBus IPC mechanism in WSL
Stars: ✭ 47 (-20.34%)
Mutual labels:  reverse-engineering
Ntrghidra
Fully Featured Nintendo DS Loader for Ghidra
Stars: ✭ 56 (-5.08%)
Mutual labels:  reverse-engineering
Write Ups
📚 VoidHack CTF write-ups
Stars: ✭ 45 (-23.73%)
Mutual labels:  reverse-engineering
Starflight Reverse
Reversed engineered game Starflight (1986)
Stars: ✭ 56 (-5.08%)
Mutual labels:  reverse-engineering
Minject
Mono Framework Interaction / Injection Library for .NET (C++/CLI)
Stars: ✭ 42 (-28.81%)
Mutual labels:  reverse-engineering
Ollvm de fla
deobfuscation ollvm's fla
Stars: ✭ 55 (-6.78%)
Mutual labels:  reverse-engineering
Vgm ripping
Sources for game music ripping tools
Stars: ✭ 58 (-1.69%)
Mutual labels:  reverse-engineering
Dll hook Rs
Rust code to show how hooking in rust with a dll works.
Stars: ✭ 57 (-3.39%)
Mutual labels:  reverse-engineering
Pcsgolh
PCSGOLH - Pointless Counter-Strike: Global Offensive Lua Hooks. A open-source Lua API for CS:GO hacking written in modern C++
Stars: ✭ 56 (-5.08%)
Mutual labels:  reverse-engineering

Ghidra .pyi Generator

The Ghidra .pyi Generator generates .pyi type stubs for the entire Ghidra API. Those stub files can later be used in PyCharm to enhance the development experience.

You can either use the stubs released here, or follow the instructions below to generate them yourself.

To use the stubs in PyCharm, follow the instructions in Install, uninstall, and upgrade interpreter paths.

Using The Stubs

Once installed, all you need to do is import the Ghidra modules as usual, and PyCharm will do the rest.

import ghidra

To get support for the Ghidra builtins, you need to import them as well. The type hints for those exist in the generated ghidra_builtins.pyi stub. Since it is not a real Python module, importing it at runtime will fail. But the .pyi gives PyCharm all the information it needs to help you.

try:
    from ghidra_builtins import *
except:
    pass

Once done, just code & enjoy.

Pycharm Demo

Dependencies

Ghidra Docs

To properly extract all types from Ghidra, make sure to extract the API documentation.

  1. Open the Ghidra CodeBrowser
  2. Go to Help -> Ghidra API Help
  3. Wait for Ghidra to extract the docs

Python Packages

The script depends on both the attr and typing packages.

# Create a virtualenv for Ghidra packages.
# It is important to use Python2.7 for this venv!
# If you want, you can skip this step and use your default Python installation.
mkvirtualenv -p python2.7 ghidra
 
# Create Jython's site-pacakges directory.
jython_site_packages=~/.local/lib/jython2.7/site-packages
mkdir -p $jython_site_packages
 
# Create a PTH file to point Jython to Python's site-packages directories.
# Again, this has to be Python2.7.

# Outside a virtualenv, use
python2.7 -c "import site; print(site.getusersitepackages()); print(site.getsitepackages()[-1])" > $jython_site_packages/python.pth

# If using virtualenv, use the following instead
python2.7 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" > $jython_site_packages/python.pth

 
# Use pip to install packages for Ghidra
pip install attrs typing

Creating the .pyi files

GUI

  1. Add this directory to the Script Directories in the Ghidra Script Manager
  2. Refresh the script list
  3. Run generate_ghidra_pyi.py (will be located under IDE Helpers)
  4. When a directory-selection dialog appears, choose the directory you'd like to save the .pyi files in.

CLI

$GHIDRA_ROOT/support/analyzeHeadless /tmp tmp -scriptPath $(pwd) -preScript generate_ghidra_pyi.py ./

Python Package

generate_ghidra_pyi.py generates a setup.py inside the directory that was selected.

This allows using pip install to install a PEP 561 stub package that is recognized by PyCharm and other tools as containing type information for the ghidra module.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].