ghidra-decompile
Decompile a binary efficiently with Ghidra by targeting exact addresses in a prepared or no-analysis project, and repair the GhidraMCP bridge when its…
от dejanr★ 15 звёзд на GitHub
Установить ghidra-decompile в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Ghidra decompilation
Ghidra is the full decompiler and the persistent database. Reach for it when you need the decompiler's C, cross-references, vtables/RTTI, or a second opinion on other tooling's output.
The cost is analysis, not decompilation. A 114 MB stripped AArch64 image imported once, then decompiled one targeted function in 3.3 s on a reuse run with -noanalysis; full auto-analysis of the same image takes hours and is rarely needed to read one function.
Choose the path
| situation | path |
|---|---|
| one or two functions, no project | headless import with -noanalysis + targeted script |
| repeating questions about one binary | keep the project; -process between runs |
| many queries, xrefs, RTTI, renaming, a human at the GUI | open project + GhidraMCP bridge |
| whole-binary pseudocode sweep | analyzed project + decompile_tree or a batch script |
If dependencies are missing
For headless runs, check for ghidra-analyzeHeadless (Nix), analyzeHeadless on PATH, or support/analyzeHeadless in a standalone Ghidra install. If Ghidra or a debugging tool you need is missing on a host managed by these dotfiles, recommend enabling the existing Home Manager module (modules/home/cli/ghidra.nix) in that host's hosts/<host>/home.nix:
config.modules.home.cli.ghidra.enable = true;
Ask before changing the host config or running a rebuild. From the dotfiles checkout, use sudo nixos-rebuild switch --flake .# on NixOS or nix run nix-darwin -- switch --flake .# on macOS. Start a fresh login session and restart Pi so it inherits the new PATH and GHIDRA_DECOMPILE_SCRIPTS. Before continuing, check that command -v ghidra-analyzeHeadless finds the launcher and test -r "${GHIDRA_DECOMPILE_SCRIPTS:?}/ResearchDecompile.java" succeeds.
The module installs the pinned Ghidra and native debugging tools, not GhidraMCP. If only the bridge is missing, use the bridge setup; headless runs do not need it. On hosts outside these dotfiles, use an existing standalone Ghidra install and the skill's bundled tools/ directory.
1. Pin the addresses and the image base
Ghidra scripts take Ghidra virtual addresses (VAs), not file or mod offsets. Read the image base before converting:
println("imageBase=" + currentProgram.getImageBase());
println("language=" + currentProgram.getLanguageID());
Verified on the MPC Sample firmware 1.3.0.12: imageBase=00100000, language=AARCH64:LE:64:v8A. For an ELF, the rule is Ghidra VA = image base + ELF vaddr. Do not carry the constant to another loader: use the printed image base.
For that binary the first LOAD has file offset == vaddr == 0, so a .text/.rodata file offset X sits at X + 0x100000. The second LOAD is file offset 0x6d43bb0 → vaddr 0x6d53bb0, so its file offsets need +0x110000; Ghidra shows .data.rel.ro.local at 0x6e53bb0, which is vaddr 0x6d53bb0 + 0x100000. The mod expresses its offsets as ELF vaddrs, which is why +0x100000 works throughout its code. Confirm the segment before converting a raw file offset.
If the function entry is unknown, decompile the containing address first (getFunctionContaining returns a function for an address inside its body) and locate the prologue from the disassembly. On AArch64, search backwards for PACIASP (0xd503233f as a word; bytes 3f 23 03 d5 in file order) for candidate entries; treat candidates as unconfirmed until the decompiler agrees.
Done when: the image base is printed and every address you are about to decompile is a VA.
2. Decompile exact addresses headless
With the Home Manager module, the script path is already set. Otherwise, set SKILL_DIR to the directory containing this SKILL.md.
if [ -n "${GHIDRA:-}" ]; then
HEADLESS="$GHIDRA/support/analyzeHeadless"
elif command -v ghidra-analyzeHeadless >/dev/null; then
HEADLESS=ghidra-analyzeHeadless
elif command -v analyzeHeadless >/dev/null; then
HEADLESS=analyzeHeadless
else
HEADLESS="$HOME/Applications/ghidra_12.2_PUBLIC/support/analyzeHeadless"
fi
SKILL_DIR=/path/to/ghidra-decompile
PROJ=/tmp/ghproj
BIN=/path/to/mpcsample.bin
mkdir -p "$PROJ"
GHIDRA_HEADLESS_MAXMEM=32G "$HEADLESS" "$PROJ" target \
-import "$BIN" -noanalysis \
-scriptPath "${GHIDRA_DECOMPILE_SCRIPTS:-$SKILL_DIR/tools}" \
-postScript ResearchDecompile.java 0x17580d0 0x153ed40
- Create the project directory first. Without it Ghidra aborts with
Directory not found. - The first run imports and saves; later runs reuse the project and are much faster:
... "$PROJ" target -process "$(basename "$BIN")" -noanalysis -scriptPath ... -postScript ... -noanalysisis the efficiency lever. Drop it only when you genuinely need Ghidra's function discovery for a whole binary.- Script output is prefixed (
INFO ResearchDecompile.java> ...). Grep for=====to find each function header; the C follows.
Use the bundled `tools/ResearchDecompile.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- LICENSE
- README.md
- docs/RE-METHOD.md
- docs/TOOLING.md
- tools/DisasmRange.java
- tools/DumpParamNames.java
- tools/DumpParams.java
- tools/DumpRTTI.java
- tools/DumpVtable.java
- tools/DumpWords.java
- tools/FindConst.java
- tools/FindFunctionRefs.java
- tools/FindIndirectSlot.java
- tools/FindOffsetUse.java
- tools/FindPointerValues.java
- tools/FindStrings.java
- tools/HpssCommandTrace.java
- tools/HpssEntry.java
- tools/HpssFindExtract.java
- tools/HpssInstructions.java
- tools/HpssReadPointers.java
- tools/HpssRefs.java
- tools/ProgramInfo.java
- tools/README.md
- tools/ReadStrings.java
- tools/RefsDetailed.java
- tools/ResearchDecompile.java
- tools/run_bridge.py
FAQ
Что делает скилл ghidra-decompile?
Decompile a binary efficiently with Ghidra by targeting exact addresses in a prepared or no-analysis project, and repair the GhidraMCP bridge when its extension does not match the Ghidra version. Use when the task names Ghidra, needs decompiled C or xrefs from a persistent analyzed database, or when a lighter disassembler is not enough.
Как установить скилл ghidra-decompile?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ghidra-decompile запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…