Reverse Engineering: Introduction, Law and Scope
Reverse engineering (RE) is working out what a program does when all you have is the program. No source, no design document, maybe no symbols: just bytes that a CPU will execute. Analysts do it to understand malware, to find and confirm vulnerabilities, to make software talk to undocumented formats and protocols, and to check that a vendor's binary really does what the vendor says. This course teaches the reading skills (x86-64 and ARM64 as compilers write them), the file formats (ELF, PE, a little Mach-O), static analysis (strings, imports, disassembly, control-flow graphs, decompilers), dynamic analysis (debuggers, tracers, instrumentation), and how protections and obfuscation look from the analyst's chair.
Before anything else: authorization, scope and the law
Analysing a program is not the same as attacking a system, but it has its own legal edges, and the techniques in this course can be turned against software and devices you have no right to touch. The rule of the track applies here too:
Only analyse software you wrote, software whose owner has authorised the analysis in writing, or software whose licence and local law clearly allow it, and only for the purpose that permission covers.
Read these Security Foundations lessons first; this course builds on them and does not repeat them:
- Authorization, Scope and Rules of Engagement: who may grant permission, and how scope is written down.
- US Law: the CFAA, Van Buren and Good-Faith Research, which includes DMCA section 1201 and its security-research exemption.
- UK and EU Law and Vietnamese Law: computer-misuse offences where you and the software's owner are.
- Responsible Disclosure, Bug Bounties and security.txt: what to do with a flaw you find.
Three bodies of law meet reverse engineering specifically. This is orientation, not legal advice; the rules differ by country and change.
| Area | What it says, in short | What it means for an analyst |
|---|---|---|
| Copyright and the licence (EULA) | Software is a copyrighted work. Disassembling it makes copies and translations, and most commercial licences forbid reverse engineering. Courts in some countries have enforced such clauses (in the US, for example, Bowers v. Baystate Technologies, Fed. Cir. 2003). | Read the licence. A "no reverse engineering" term can make analysis a breach of contract even where copyright law would allow it. |
| Anti-circumvention: US DMCA section 1201 | Forbids circumventing technical protection measures (encryption, licence checks, DRM) on copyrighted works. The statute has narrow exceptions for interoperability (section 1201(f)) and security testing (section 1201(j)), and the triennial rulemaking grants a broader good-faith security research exemption (37 CFR 201.40(b), renewed in the 2024 rule) with conditions: a lawfully acquired device or machine, or one whose owner authorised the work; solely good-faith testing of security flaws, in an environment designed to avoid harm; and it is no defence under other laws such as the CFAA. | Bypassing a protection is the legally sensitive step, not reading code. The exemption is a narrow door, not a general licence. |
| EU Software Directive 2009/24/EC | Article 5(3): a lawful user may observe, study and test a program to determine the ideas and principles behind it. Article 6: decompilation is allowed when it is indispensable to achieve interoperability of an independently created program, under strict conditions. Article 8: contract terms contrary to these are null and void. The UK has the same rules in the CDPA 1988 (sections 50B, 50BA, 296A). | In the EU and UK, interoperability and black-box study are protected even against a licence; other purposes (for example finding bugs to sell) are not covered by these articles. |
Malware is a special case: analysing a sample is generally lawful, but possessing and sharing working malicious code can fall under computer-misuse laws, so professionals keep samples in isolated labs, share them only through trusted channels, and never run them outside an isolated environment.
How this course stays on the right side of the line
The track's safety line is binding for every lesson:
- Every binary analysed here is one the lesson compiles itself, from C or assembly source printed in the lesson. No commercial software, no real malware, no real product's licence check, no DRM.
- Crackme exercises use the course's own toy binaries only, and every one ends with the fix: how the developer should have written the check (in short: don't hard-code secrets, and don't trust the client).
- Protections and obfuscation are taught for recognition: what a packed file, an anti-debugging check or a flattened function looks like, how analysts notice it, and why it doesn't replace real security. No evasion techniques for security products.
- GUI tools (Ghidra, IDA, Binary Ninja, x64dbg) appear as labelled lab transcripts of the course's own toys; their scope is stated.
How examples run here
```bash runblocks are recorded sandbox sessions: real runs of gcc 13.3, clang 18, objdump and readelf (binutils 2.42), gdb 15.1, strace, ltrace and checksec in a container with no network and no root. Each session writes its own C or assembly source, compiles it and analyses the result. Run-time addresses that change every run are shown as0xADDR, process ids as<PID>.```python runruns in your browser (Python 3.13 in WebAssembly): ELF and PE header parsers withstructon bytes the example builds, a small x86-64 decoder, entropy, and control-flow graphs with NetworkX.```c runand```nasm runcompile and run on Compiler Explorer.```consoleblocks are lab transcripts of tools that can't run here, always on the course's own toys.
Here is the shape of every analysis in the course, in miniature. The session writes a toy program, compiles it, and then asks the three first questions an analyst asks of any file: what is it, what text does it contain, and what does it call?
cat > hello.c <<'SRC'
#include <stdio.h>
int main(void) {
puts("Hello from a toy binary of the RE course");
return 0;
}
SRC
gcc -O2 hello.c -o hello
file hello | cut -d, -f1-3
strings -n 8 hello | grep -i toy
nm -D hello | grep ' U '
./hellohello: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
Hello from a toy binary of the RE course
U __libc_start_main@GLIBC_2.34
U puts@GLIBC_2.2.5
Hello from a toy binary of the RE course
file reads the magic bytes and headers: a 64-bit ELF for x86-64, position-independent. strings finds the message without running anything. nm -D lists the dynamic symbols the program imports from the C library: puts, with the glibc symbol version it needs, plus the start-up function __libc_start_main. Three commands, and you already know roughly what the program does. Most of this course is about what to do when it isn't that easy.
The map
| Section | What you learn |
|---|---|
| Getting started | what RE is used for (malware analysis, vulnerability research, interoperability, auditing) and the analyst's workflow |
| Reading machine code | x86-64 registers, flags and core instructions; System V and Microsoft x64 calling conventions; stack frames and canaries; ARM64 and AAPCS64; how compilers translate if, loops, switch, structs and virtual calls; what optimisation does; a small x86-64 decoder |
| Executable formats | ELF headers, sections and segments, symbols and stripping, relocations, PLT and GOT; PE headers, sections, imports, exports and the IAT; Mach-O in brief |
| Static analysis | strings and entropy, imports as behaviour hints, objdump, control-flow graphs in NetworkX, decompilers, recognising library code and crypto constants |
| Dynamic analysis | gdb in batch mode, strace and ltrace, x64dbg and WinDbg, instrumentation (LD_PRELOAD, Frida, DynamoRIO, Pin, eBPF) |
| Protections and obfuscation | packing and entropy, anti-debugging, control-flow flattening, opaque predicates, code signing |
| Practice | a crackme on the course's own toy with its fix, exercises, and an end-to-end analysis report |
What you should know first
x86-64 Assembly teaches the instruction set by writing it; this course reads it. C is the language of almost every toy here. Programming for Security has the short versions of two lessons this course extends: Reading Compiler Output and Assembly and C Buffers, Lengths and Unsafe Functions. Operating Systems covers processes, system calls and virtual memory. The next course, Memory Safety & Binary Exploitation Concepts, uses the reading skills from here.
Start with What Reverse Engineering Is For.
Test yourself
Which binaries are analysed in this course?
- Popular commercial programs
- Malware samples from public repositories
- Only toy programs that each lesson compiles itself from source shown in the lesson
- Any binary on your computer
Under the EU Software Directive 2009/24/EC, when is decompilation allowed without the rightholder's permission?
- Always, for any purpose
- When it is indispensable to achieve interoperability of an independently created program, under the conditions of Article 6
- Only for finding bugs to sell
- Never
In US law, which step of reverse engineering is the most legally sensitive under DMCA section 1201?
- Reading the strings in a file
- Circumventing a technical protection measure such as a licence check or encryption
- Running
fileon a program - Writing notes
What did nm -D hello reveal without running the program?
- The source code
- The functions it imports from shared libraries, such as puts
- The CPU temperature
- The developer's name