Lion Cipher Lab

Understand a classic stack buffer overflow — hands-on, in your own lab

Why it matters

Almost every serious remote-code-execution bug in history traces back to this one idea: a program wrote past the end of a fixed-size buffer and clobbered something important — often the address the CPU was going to 'return' to. You can read that sentence a hundred times and not feel it. This lab makes you feel it: you write twelve lines of C, feed it a long string, and watch the CPU jump wherever you tell it. Then — and this is the actual point — you recompile with the defenses that ship on by default today and watch the same attack die three different ways. That is the fastest route to…

What you'll learn

Steps in this lab

  1. Read this first: the target is your own program, on your own machine
  2. What a stack buffer overflow actually is (in one breath)
  3. Get a Linux machine and the build tools
  4. Write the deliberately-vulnerable program
  5. Compile with the protections OFF — and know what each flag disables
  6. Crash it — and read the segfault as a clue
  7. Find the EXACT offset in gdb with a cyclic pattern
  8. Overwrite the return address — redirect execution into win() (ret2win)
  9. The defense half: recompile with modern defaults and watch it die three ways
  10. Why this bug class exists — and how it's actually fixed
  11. Where this goes next — and clean up

Open the full interactive lab →