Lion Cipher Lab
Script Ghidra with Python and run it headless: list every caller of strcpy and system into a CSV
- Digital Forensics & IR (DFIR)
- Advanced
- ~90 min
- Free · no account required
Why it matters
Triage is the first pass over software you did not write: which programs call dangerous functions, which ones talk to the network, which ones ship the same risky copy routine. Doing that by clicking through the GUI once is learning. Doing it again for fifty binaries, or again next month for the new build, is wasted days. A script turns your question into something you can run on every binary the same way, gets the same answer for the same input, and leaves a file you can sort, diff and hand to a colleague. Ghidra's headless mode and scripting API are how analysts at real teams run the same…
What you'll learn
- running Ghidra without the GUI with analyzeHeadless and its -import, -postScript, -scriptPath, -readOnly and -deleteProject options
- passing arguments to a Ghidra script and reading them with getScriptArgs
- walking functions, symbols and references with the Ghidra program API from Python
- writing a repeatable triage script that exports a CSV across several binaries
- telling the classic Jython script runtime apart from PyGhidra (native CPython 3) using the official docs
- judging when a name-based triage script is misleading
Steps in this lab
- The vocabulary, in plain words
- Build a toy program with four known calls
- Which Python? What the docs say, and how to check your copy
- Write the script
- Run it headless: strcpy first, then system
- Make it repeatable: many binaries, one CSV
- When NOT to trust this, and how a pro does it better
Open the full interactive lab →