Ghidra for binary analysis
Use Ghidra to narrow the search and explain the program’s paths. Use a debugger to confirm what happened at runtime.
Import and orient
Section titled “Import and orient”- Create a project and import the supplied executable.
- Check the detected format, processor, and endianness.
- Run auto-analysis with the suggested analyzers and wait for it to finish.
- Open the CodeBrowser. Keep the Program Tree, Symbol Tree, Listing, and Decompiler available.
- Start at the entry point and locate
mainor the function that owns the user-visible loop.
Follow input toward a decision
Section titled “Follow input toward a decision”Look at strings, imports, and references first. A prompt string may lead to the function that reads input. An imported API such as read, fgets, scanf, or printf may lead to a relevant caller.
- Use Search to find strings and function names.
- Use References To on a string or function to find callers.
- Follow the call sites to see how values reach a function.
- Use the Function Graph to inspect branches and loops.
Mark up what you learn
Section titled “Mark up what you learn”Rename functions by observed behavior, such as read_name or check_password. Rename variables when their purpose is clear, then add a short comment with the evidence.
Useful views
Section titled “Useful views”| View | Use it to |
|---|---|
| Decompiler | Follow likely control flow and data flow in a function. |
| Listing | Check instructions, addresses, and branch behavior. |
| References / XRefs | Find code that uses a string, function, global, or address. |
| Function Graph | See branches and merge points in a selected function. |
| Bytes / Data view | Inspect raw bytes, constants, tables, or encoded data. |
| Symbol Tree | Navigate functions, labels, imports, and external names. |
When the file is stripped
Section titled “When the file is stripped”Use strings, imported functions, entry points, and call structure as navigation anchors. Auto-analysis can miss or misclassify code, so inspect the function boundary when something looks wrong. Label small confirmed behaviors and compare them with a debugger run.
Reference
Section titled “Reference”The official Ghidra beginner guide covers projects, analysis, symbols, references, the decompiler, and function graphs.