Lion Cipher Lab

Write a mini-debugger from scratch with ptrace() (software breakpoints)

Why it matters

Every serious security discipline eventually runs into a debugger. Reverse engineers live in one; exploit developers step through crashes instruction by instruction; malware analysts watch a sample unpack itself in memory; and defenders read the artifacts all of that leaves behind. But most people treat gdb and lldb as opaque magic boxes -- they memorize commands without any idea what the tool is actually doing to the program underneath. This lab removes the mystery permanently by having you BUILD the machine. Once you have stamped a 0xCC byte over a running instruction with your own hands,…

What you'll learn

Steps in this lab

  1. What a debugger really is, and what ptrace gives you
  2. Set up the tools and compile a tiny target (with a fixed address)
  3. The skeleton: fork the target, opt into tracing, and take the wheel
  4. Arm a software breakpoint: save the byte, stamp 0xCC
  5. Run it, catch the SIGTRAP, and read the registers
  6. The crux: step past the breakpoint correctly, then re-arm
  7. Assemble the complete dbg.c, compile it, and run it
  8. The named failure modes (this is what makes it hard)
  9. The judgment: when to build your own, and how the pros go further

Open the full interactive lab →