Introduction to Reversing
Reverse engineering (reversing) is the art of understanding how a program works without its source code, starting only from the compiled binary. It’s used to analyze malware, find vulnerabilities, bypass protections (licenses, DRM), understand proprietary protocols, and solve CTF challenges. It consists of translating machine code back into something understandable —assembly and, with decompilers, pseudo-C— and reasoning about its logic.
What it is
Section titled “What it is”Reversing walks the reverse path of compilation: where the developer went from C to a binary, the reverser goes from a binary to understanding. You don’t always recover the original source (almost never with native C/C++), but you do reconstruct enough logic to answer a concrete question: how does this password check work? what server does this malware contact? where’s the bug?
What it’s used for
Section titled “What it’s used for”- Malware analysis — understand what a suspicious executable does without trusting its appearance.
- Vulnerability research — find bugs in software without source, the basis of pwn.
- Protection bypass — licenses, DRM, anti-cheat, integrity checks (in authorized settings).
- Interoperability — understand proprietary formats and protocols.
- CTF — solve crackmes: deduce the password or the flag.
Theory: static vs dynamic
Section titled “Theory: static vs dynamic”The two big approaches are complementary:
flowchart TD
A["unknown binary"] --> B["file + strings + checksec"]
B --> C["STATIC analysis (no execution)"]
B --> D["DYNAMIC analysis (execution)"]
C --> C1["Ghidra/IDA: pseudo-C, logic, xrefs"]
D --> D1["GDB/ltrace: runtime state, decryption"]
C1 --> E["understanding of the logic"]
D1 --> E
E --> F["answer the question: how does it validate? what does it do?"]
- Static analysis (see Static Analysis) — examine the binary without running it: disassemble/decompile, read the logic, strings, imports. Safe (you don’t run malware), but laborious.
- Dynamic analysis (see Dynamic Analysis) — run the binary and observe it: debugger, traces, syscalls/APIs, live memory. Fast to understand behavior, but you run the code (risky with malware).
In practice they’re combined: static to map the logic, dynamic to confirm and for what’s hard to follow statically (obfuscation, runtime decryption).
First contact with a binary
Section titled “First contact with a binary”file binary # type, architecture, stripped? static?strings -n 6 binary # readable strings: messages, paths, URLs, hintsstrings -e l binary # UTF-16 strings (typical on Windows)checksec --file=binary # mitigations (if ELF)nm binary 2>/dev/null # symbols (if not stripped)strings is always the first step: it often reveals passwords, error messages, function names, or the flag itself.
Binary formats
Section titled “Binary formats”- ELF — Linux (executables,
.so). - PE — Windows (
.exe,.dll). - Mach-O — macOS/iOS.
- Bytecode — .NET (IL, almost recoverable to source with dnSpy/ILSpy), Java (
.class→ jadx/jd-gui), Python (.pyc→ decompyle3/pycdc).
Bytecode languages are far easier to reverse (you nearly recover the source); native-compiled C/C++ is the hardest.
Exploitation (lab): a crackme workflow
Section titled “Exploitation (lab): a crackme workflow”# 1) reconfile crackme && strings -n 6 crackme && checksec --file=crackme# 2) static: open in Ghidra, locate main / the check function# read the pseudo-C: how does it validate the password/flag?# 3) if clear -> deduce the correct input# 4) if obfuscated/encrypted -> dynamic:ltrace ./crackme # does it do strcmp(your_input, "key")?gdb -q ./crackme # breakpoint at the cmp, read the expected value# 5) (if applicable) patch the binary to skip the checkltrace is gold in crackmes: if the program does strcmp(your_input, "correct_password"), it shows you the expected password directly.
Mitigations / Blue Team (anti-reversing)
Section titled “Mitigations / Blue Team (anti-reversing)”Reversing is hindered —not prevented— by protections covered in Anti-debugging and Anti-analysis:
- Code obfuscation and string encryption (decrypted at runtime).
- Packers / executable encryption (the real code only exists after unpacking).
- Anti-debugging / anti-VM / analysis-environment detection.
- Integrity checks (anti-tampering).
For those defending their own software these raise the pirate’s cost; for the malware analyst they’re obstacles to bypass. None fully protects against a determined analyst.
Checklist
Section titled “Checklist”-
file/strings/checksecas first contact - Tell static from dynamic and when to use each
- Recognize the format (ELF/PE/Mach-O/bytecode)
- Open a binary in Ghidra and locate
main/logic - Read pseudo-C and follow the validation logic
-
ltrace/straceto see calls quickly - Combine static + dynamic on obfuscated code
- Solve a basic crackme (deduce/patch)