Lion Cipher Lab

Leak libc and pop a shell with ret2libc

Why it matters

The ROP lab left you with a chain that only worked because the target handed you a friendly win() and a -no-pie binary, so every address was fixed. Real targets almost never give you both. There is usually no win() at all — but there is always libc, the C standard library every program loads, and libc contains system() and the string "/bin/sh". So you reuse libc: point the first argument at "/bin/sh" and return into system(). That is ret2libc, and it is the technique the ROP lab named as the next rung. The catch is the whole lesson: ASLR (Address Space Layout Randomisation) loads libc at a…

What you'll learn

Steps in this lab

  1. Read this first: still your own machine, still authorized-only
  2. Where the ROP lab left you — and why that chain now breaks
  3. The plan: leak an address, do arithmetic, then ret2libc
  4. Get Linux and the exploit tooling
  5. Write the vulnerable program — deliberately WITHOUT a win()
  6. Compile with NX on, canary/PIE off — ASLR LEFT ON
  7. Find the offset and the gadgets
  8. Stage 1: leak the runtime address of puts
  9. Stage 2 and the full exploit: pop a shell with ret2libc
  10. The shortcut and where it goes further: one_gadget, ret2csu, SROP
  11. The defenses that make this hard — and clean up

Open the full interactive lab →