Reverse Engineering
This hands-on guide shows how to use Ghidra to inspect a program you compile yourself. You'll compare decompiled code with the underlying assembly, follow cross-references, and document what the binary does without executing it.
sudo apt install ghidra
ghidraRun
Ghidra is a free, open-source software reverse engineering framework developed by the U.S. National Security Agency (NSA). It lets you inspect compiled programs without running them: you can read machine instructions, view a C-like approximation of the code, and trace how functions and strings are used across the binary.
Try this tiny C program: #include <stdio.h> static void print_ready(void) { puts("ready"); } int main(int argc, char **argv) { if (argc > 1) print_ready(); return 0; } Compile it on Kali with gcc -O0 -o ready ready.c, then make a stripped copy with cp ready ready-stripped && strip ready-stripped so you can practice working without the original function names. Import the stripped copy, run auto-analysis, and look for main in the Symbol Tree. If main isn't named, start at the entry point and follow the function address passed as the first argument to __libc_start_main. Typical pseudo-C (illustrative, not verbatim): if (1 < param_1) { FUN_...(); } The dots stand for an address suffix. Follow the call, verify that the helper passes "ready" to puts, and rename the FUN_ function to print_ready. Back in main, the call is now readable: an argument count above one means the user supplied at least one argument beyond the program name, which triggers the message.
In CodeBrowser, the Listing shows addresses, assembly instructions, and data. The Decompiler shows C-like logic for the selected function, while the Symbol Tree helps you find functions and imports. The Function Graph draws the blocks and branches inside a function. Defined Strings lists text already defined in the program, and the Byte Viewer lets you inspect the loaded bytes in hex.
The built-in Ghidra decompiler reconstructs expressions, branches, and calls from machine instructions. Its pseudo-C is an approximation, not the original source: comments are generally absent, and names and types may be missing or inferred. Stripped binaries offer fewer naming clues, optimized builds may inline helpers or rearrange branches, and packed binaries may initially reveal only a loader stub. Check the Listing when the pseudo-C is ambiguous.
Use analyzeHeadless to analyze files without opening CodeBrowser. Use -import for new binaries and -process for programs already in a project. Java scripts, or Python scripts (Jython), can collect function names or export selected pseudo-C. Run a script after analysis with -postScript; headless analysis does not export decompiler output on its own.
Learning how to use Ghidra follows one beginner loop: install Ghidra with a compatible JDK, create a project, import a binary you are authorized to analyze, run auto-analysis, then read the decompiler output beside the disassembly — renaming functions, chasing strings and cross-references, and saving your work as you go. This guide walks that loop step by step, so a first-time user can go from download to a decompiled function in a single session.
Ghidra is a software reverse engineering framework developed by the NSA. It includes a suite of tools for analyzing compiled code, including disassembly and decompilation.
The tool supports multiple processor architectures and executable formats. It features a built-in decompiler that converts assembly to pseudo-C code.
Ghidra is widely used for malware analysis, vulnerability research, and software reverse engineering. Its headless mode enables automated batch analysis.
| Command | Purpose |
|---|---|
ghidra | Open the Ghidra GUI from the installed Kali package. |
ghidraRun | Start the GUI from an extracted Ghidra release (run ./ghidraRun from the install folder). |
analyzeHeadless <project_dir> <project_name> -import <binary_path> | Import and analyze a binary without opening the GUI. |
analyzeHeadless <project_dir> <project_name> -process <program_name> | Process a program already in the project (use its project entry name). |
analyzeHeadless <project_dir> <project_name> -process <program_name> -scriptPath <script_dir> -postScript Decompile.java | Export decompiled output with the bundled Decompile.java post-script. |
analyzeHeadless <project_dir> <project_name> -import <binary_path> -processor <language_id> | Set the processor language explicitly with the full Ghidra language ID for the binary. |
ghidraLaunch the Ghidra graphical reverse-engineering suite on KalighidraRunAlternative launcher script that starts the Ghidra GUIanalyzeHeadless /path/to/projects MyProject -import /path/to/binaryImport a binary into a project and auto-analyze it without the GUIanalyzeHeadless /path/to/projects MyProject -import /path/to/binary -overwriteRe-import a binary, overwriting any existing program of the same nameanalyzeHeadless /path/to/projects MyProject -import /path/to/dir -recursiveRecursively import every file in a directory treeanalyzeHeadless /path/to/projects MyProject -import /path/to/binary -noanalysisImport without running auto-analysis (analyze later)analyzeHeadless /path/to/projects MyProject -processRe-run analysis/scripts against programs already in the projectanalyzeHeadless /path/to/projects MyProject -process binary -postScript Decompile.javaRun a post-analysis script against an existing programanalyzeHeadless /path/to/projects MyProject -import /path/to/binary -postScript MyScript.pyImport, analyze, then run a Python (Jython) post-scriptanalyzeHeadless /path/to/projects MyProject -import /path/to/binary -preScript Setup.javaRun a script before analysis beginsanalyzeHeadless /path/to/projects MyProject -import bin -scriptPath /path/to/scriptsSpecify where Ghidra should look for headless scriptsanalyzeHeadless /path/to/projects MyProject -import bin -deleteProjectDelete the project after the headless run completesanalyzeHeadless /path/to/projects MyProject -import bin -processor x86:LE:64:defaultForce a specific processor language ID for analysisanalyzeHeadless /path/to/projects MyProject -import bin -cspec gccSet the compiler specification used during analysisanalyzeHeadless /path/to/projects MyProject -import bin -loader ElfLoaderChoose a specific loader for the imported fileanalyzeHeadless /path/to/projects MyProject -import bin -analysisTimeoutPerFile 300Cap per-file analysis time at 300 secondsanalyzeHeadless /path/to/projects MyProject -import bin -max-cpu 4Limit analysis to 4 CPU coresanalyzeHeadless /path/to/projects MyProject -import bin -log analysis.logWrite the analysis log to a fileanalyzeHeadless /path/to/projects MyProject -import bin -scriptlog script.logWrite script output to a dedicated log fileanalyzeHeadless /path/to/projects MyProject -import bin -readOnlyAnalyze and run scripts without saving changes to the projectanalyzeHeadless ghidra://10.10.10.10/SharedProject -connect <USER> -pConnect to a Ghidra Server shared project, prompting for a passwordanalyzeHeadless ghidra://10.10.10.10/SharedProject -import bin -commit "initial import"Import into a shared project and commit with a messageanalyzeHeadless -helpPrint the full analyzeHeadless usage and option list/usr/share/ghidra/support/analyzeHeadlessInvoke the headless analyzer directly from the Ghidra install pathghidra_10.4_PUBLIC/support/buildGhidraJarBuild a single Ghidra jar for embedding Ghidra in other Java toolsAnalyze malware samples and understand behavior.
Find vulnerabilities in compiled software.
Understand compiled code without source.
Solve reverse engineering CTF problems.
Inspect authorized firmware images to trace startup code and find references to version strings.
Recover the logic of old binaries whose source code is lost, so they can be documented or replaced.
Reverse Engineering
Radare2 (r2) is a complete open-source framework for reverse engineering and binary analysis. It bundles a disassembler, debugger, hex editor, and scripting engine into a single lightweight command-line toolkit that supports dozens of architectures and executable formats.
Reverse Engineering
Learn how to use GDB, the GNU Debugger, by building a small C program with debug symbols and following it from the first breakpoint to a crash. Use the same steps to inspect variables, read a backtrace, and tell when a core dump or a look at the assembly would help.
Reverse Engineering
Objection is a runtime mobile exploration toolkit, powered by Frida, built to help you assess the security of your mobile applications without needing a jailbroken or rooted device.
Reverse Engineering
Frida is a dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers. It allows you to inject snippets of JavaScript or your own library into native apps on various platforms — making it the industry standard for runtime analysis and mobile app security testing.
Reverse Engineering
objdump displays information about object files. It can disassemble executables, show headers, symbols, and more.
Reverse Engineering
strings prints the sequences of printable characters in files. Useful for finding hidden text, URLs, and clues in binaries.
Learn reverse engineering from scratch: analyze binaries with Ghidra and GDB, read assembly, crack a practice binary, and build a starter toolkit.
Maltego · BeginnerA comprehensive guide to Maltego Community Edition — the free version of Maltego. Learn what you get, what you don't, and how to maximize your OSINT capabilities without spending a dime.
Web Security · IntermediateWhat is CSRF? Learn how cross-site request forgery tricks your browser into unwanted actions, see real examples and a DVWA worked test, and follow 7 steps to prevent CSRF attacks with tokens, SameSite cookies and framework protection.
OSINT · IntermediateLearn Google dorking: advanced search operators, a worked OSINT example on a domain you own, GHDB dorks, a cheat sheet, and how to protect your site.
Start at the entry point in the Listing. In this glibc-linked example, startup code passes the address of main to __libc_start_main. Follow that address if main isn't listed by name in the Symbol Tree. Read main in the Decompiler, checking the argument-count comparison and conditional call against the Listing. Find "ready" in Defined Strings and follow its cross-reference to the helper. Trace the helper's call to the puts import in the Symbol Tree. That connects the string to standard output, not just to bytes stored in the file. Rename the helper print_ready and return to main. Verdict: at least one extra command-line argument triggers the message, and both paths return zero.
This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.