Lesson 10 of 13 · 24m
Debuggers, Breakpoints, and Watchpoints
Four gdb commands, hardware watchpoints, conditional breakpoints, and rr time-travel settle in thirty seconds what an hour of listing-staring can't.
Static analysis shows you every path a program can take; the debugger shows you the one it does take. When the listing and your model disagree — and they will — thirty seconds in a debugger settles the argument that an hour of staring couldn't. Learn four commands well and you can dissect almost anything.
The gdb minimum
$ gdb -q ./crackme
(gdb) set disassembly-flavor intel
(gdb) starti # stop at the very first instruction
(gdb) break strcmp # break on an imported function
(gdb) c
(gdb) info registers rdi rsi # args live in rdi/rsi — read them
(gdb) x/s $rdi # examine as a C string
(gdb) x/32bx $rsi # 32 bytes, hex
(gdb) si / ni # step into / step over one instruction
(gdb) finish # run until this function returnsbreak strcmp alone solves half of hobbyist crackmes: run to the call, x/s $rdi, x/s $rsi, and the expected input is sitting in the registers. Real work needs more finesse, but the reflex is identical — stop where the decision happens, read the operands.
Two upgrades worth installing immediately. pwndbg (or gef, or bata24 — pick one) gives gdb the context panes it should have shipped with: registers, disassembly at $pc, and the stack on every stop, instead of you typing x/2i $pc forever. And rr — record-and-replay — turns "the thing I needed happened 40,000 instructions ago" into rr record ./crackme, rr replay, reverse-continue, reverse-stepi. Time-travel debugging is the single biggest quality-of-life upgrade in the discipline and it runs on stock Linux x86.
Watchpoints: ask "who writes this"
The killer feature isn't breakpoints — it's watchpoints, "stop when this memory changes":
(gdb) watch *(int*)0x555555558040 # break on any write
(gdb) rwatch *(int*)0x555555558040 # break on any readFound the flag byte that decides licensed-versus-not? Don't trace code forward hoping to find its writer — watchpoint the byte, run, and the debugger hands you every function that touches it, in order, with the call stack at each touch. It's a dynamic xref, and for "where does this value come from" it's often faster than static analysis. The hardware limit is real: x86 has four debug registers (DR0–DR3), so you get four watchpoints at hardware speed — beyond that gdb falls back to single-stepping and your program runs a thousand times slower.
Cut the noise
A breakpoint inside a hot loop that fires 40,000 times is worse than useless. condition 1 $rdi == 0x41414141 makes it selective; ignore 1 39999 skips the warm-up; commands blocks that print and continue turn breakpoints into instrumentation. tb sets a breakpoint that deletes itself on first hit — one-shot checks where you don't want a permanent stop. catch syscall and catch signal SIGSEGV stop on the event class, not the address: crash analysis starts at the signal, not wherever you happened to be. Binaries that fork — daemons, self-checking children — run away from your breakpoints because gdb stays with the parent: set follow-fork-mode child switches the chase, and set detach-on-fork off keeps both sides under breakpoints.
On Windows, x64dbg does the same job with a GUI — breakpoint-by-API-name, a memory map you can break on by region, "run to user code" to skip loader transitions, and hardware/software/memory breakpoints on tabs you can see. Its Intermodular Calls tab is the static xref list ltrace gives you dynamically on Linux. Same discipline, different skin.
Two stock-gdb conveniences survive any plugin choice: ctrl+x a toggles the built-in TUI — split disassembly and registers, no install — and x/2i $pc disassembles at the instruction pointer when the context panes aren't there.
PIE, ASLR, and why your breakpoint never hit
Modern binaries are position-independent: the listing's 0x1180 lives at base + 0x1180 at runtime. info proc mappings gives you the load base; gdb also sets disable-randomization on by default, so at least addresses stay put between your runs. Rebased addresses are the number-one cause of "my breakpoint never fires" in new reversers — the second is breaking on a file offset instead of a virtual address (the loader lesson covers the translation).
Field notes
- One run is one path. Inputs, environment, and timing change control flow; a conclusion drawn from a single execution is a hypothesis, not a finding.
- Some programs watch back:
ptrace(PTRACE_TRACEME)self-checks, timing loops, debugger-detection APIs. When a binary behaves differently under the debugger, that difference is the check — the packing/anti-debug lesson covers the catalog. x/2i $pcdisassembles at the instruction pointer;display/i $pckeeps it on screen every step. In pwndbg thecontextis already doing this — one more reason to install it.
Keep reading
Related articles from the SudoSecurity blog.
A Fake GTA 6 ISO Didn’t Install a Game. It Installed a Wiper.
A fake GTA 6 ISO used a believable installer error to cover remote-access malware, browser-data theft, and destructive file wiping. The “License not found” message wasn’t the crack failing. It was there so the victim would stop looking.
CVE-2025-62718: Critical Axios SSRF Vulnerability Explained
A critical SSRF flaw in Axios was used in a North Korean supply chain attack. Here's what it does and how to patch it today.
Hacktivism, 2021 to Today: From Steel Mills to Power Grids
Part 1 ended on a 70-gigabyte breach in 2021. Since then, hacktivists derailed trains, dumped molten steel on camera, and reached grids in three countries.
What is an Infostealer?
Infostealers are commodity malware that silently harvest credentials, session tokens, and crypto wallets from infected machines. The Lumma Stealer infection that triggered the Vercel breach started with one. Here is how they work and why they are so effective.