Lion Cipher Lab

Pivot the stack to fit a longer ROP chain (when the overflow is too small) — ROP Emporium 'pivot'

Why it matters

Every ROP lab before this one quietly assumed the overflow gave you ROOM: enough bytes past the saved return address to lay down a whole chain of gadgets and addresses. Real bugs are stingier. Very often the buffer you can overflow past RIP is tiny — space for one or two 8-byte words, nowhere near enough for a leak stage plus a ret2libc plus alignment. A short overflow like that looks like a dead end, and this is the technique that turns it back into a win: the STACK PIVOT. The insight is that the stack is just wherever rsp (the stack pointer register) happens to point, and `ret` blindly…

What you'll learn

Steps in this lab

  1. Read this first: a downloaded challenge binary, run only on your own machine
  2. Where the arc left you — and the exact problem a pivot solves
  3. What a stack pivot actually is (rsp is the whole game)
  4. The pivot-gadget families: pop rsp, xchg, leave, add rsp
  5. Get the Linux toolchain, pwntools, and the 'pivot' challenge binary
  6. Read the challenge: it HANDS you the buffer address and a short overflow
  7. Find the offset and the pivot gadget
  8. Decide what the staged chain will DO: foothold_function -> ret2win
  9. Build it with pwntools: stage the chain, then send the pivot
  10. When you reach for a pivot — and how ASLR/PIE decide if you can

Open the full interactive lab →