This skill should be used when the user asks to "write a Ghidra script", "create a Ghidra analyzer", "automate Ghidra analysis", "use GhidraScript API", "access FlatProgramAPI", "decompile with DecompInterface", or needs guidance on Ghidra's Python/Jython scripting capabilities. Provides comprehensive guidance for writing Ghidra automation scripts.
From ghidranpx claudepluginhub und3rf10w/ai-ghidra-tools --plugin ghidraThis skill uses the workspace's default tool permissions.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Configures VPN and dedicated connections like Direct Connect, ExpressRoute, Interconnect for secure on-premises to AWS, Azure, GCP, OCI hybrid networking.
This skill provides guidance for writing Ghidra scripts using Python/Jython to automate reverse engineering tasks.
# @runtime Jythonprogram.getName()# @runtime PyGhidraprogram.name# My Analysis Script
# @category Analysis
# @runtime Jython
def run():
program = currentProgram
if program is None:
println("No program loaded")
return
# Your analysis code here
fm = program.getFunctionManager()
for func in fm.getFunctions(True):
println(func.getName())
run()
Available in all GhidraScript-based scripts:
| Variable | Description |
|---|---|
currentProgram | Active program being analyzed |
currentAddress | Current cursor location |
currentLocation | Current ProgramLocation |
currentSelection | Selected address range |
monitor | TaskMonitor for progress/cancellation |
state | GhidraState with tool access |
addr = toAddr("0x401000") # Parse address string
addr = toAddr(0x401000) # From integer
func = getFunctionAt(addr) # Exact address
func = getFunctionContaining(addr) # Any address in function
func = getFirstFunction() # First in program
func = getFunctionAfter(func) # Next function
func = getFunction("main") # By name
refs = getReferencesTo(addr) # Incoming references
refs = getReferencesFrom(addr) # Outgoing references
blocks = getMemoryBlocks() # All memory blocks
data = getBytes(addr, length) # Read bytes
symbol = getSymbolAt(addr) # Primary symbol
symbols = getSymbols("name", namespace)
createLabel(addr, "my_label", True)
from ghidra.app.decompiler import DecompInterface, DecompileOptions
from ghidra.util.task import ConsoleTaskMonitor
def decompile_function(func):
decompiler = DecompInterface()
decompiler.setOptions(DecompileOptions())
decompiler.openProgram(currentProgram)
try:
monitor = ConsoleTaskMonitor()
results = decompiler.decompileFunction(func, 60, monitor)
if results.decompileCompleted():
return results.getDecompiledFunction().getC()
return None
finally:
decompiler.dispose()
fm = currentProgram.getFunctionManager()
for func in fm.getFunctions(True):
println("%s @ %s" % (func.getName(), func.getEntryPoint()))
listing = currentProgram.getListing()
for data in listing.getDefinedData(True):
if data.hasStringValue():
println("%s: %s" % (data.getAddress(), data.getValue()))
for ref in getReferencesTo(addr):
from_addr = ref.getFromAddress()
ref_type = ref.getReferenceType()
println("From %s (%s)" % (from_addr, ref_type))
for func in currentProgram.getFunctionManager().getExternalFunctions():
ext_loc = func.getExternalLocation()
lib = ext_loc.getLibraryName() if ext_loc else "unknown"
println("%s from %s" % (func.getName(), lib))
Run scripts via analyzeHeadless:
analyzeHeadless /project/dir ProjectName \
-import /path/to/binary \
-postScript MyScript.py arg1 arg2 \
-scriptlog /tmp/script.log
Access arguments:
args = getScriptArgs()
if args:
target = args[0]
For scripts that output structured data:
import json
def output_json(data):
print("===JSON_START===")
print(json.dumps(data))
print("===JSON_END===")
result = {"functions": [...], "status": "success"}
output_json(result)
currentProgram is not Nonemonitor to long operations for cancellation# Core
from ghidra.program.model.symbol import SymbolType
from ghidra.program.model.data import StringDataType
# Decompiler
from ghidra.app.decompiler import DecompInterface, DecompileOptions
# Analysis
from ghidra.app.services import AnalysisPriority
from ghidra.program.model.listing import Function
# Utilities
from ghidra.util.task import ConsoleTaskMonitor
from java.io import File
Place scripts in:
~/ghidra_scripts/ (user scripts)<ghidra>/Ghidra/Features/Base/ghidra_scripts/ (examples)-scriptPath argument