Lion Cipher Lab

ret2csu: borrow __libc_csu_init gadgets to control rdi, rsi, and rdx (in your own lab)

Why it matters

The exploitation ladder so far has quietly assumed the RIGHT gadgets exist. ret2libc needed a `pop rdi ; ret` to set the first argument and that was enough, because system("/bin/sh") only takes one. But the moment you need to call something that takes TWO or THREE arguments — execve(path, argv, envp), or a challenge's ret2win() that checks three magic values, or mprotect(addr, len, prot) to make a page executable — you suddenly need to control rsi and rdx as well, and a stripped binary very often contains no `pop rsi ; ret` and no `pop rdx ; ret` at all. ret2csu is the classic answer to…

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 gap ret2csu fills
  3. What __libc_csu_init actually is (and why it is a gadget goldmine)
  4. The reproducibility trap: glibc 2.34 REMOVED __libc_csu_init
  5. Get the Linux toolchain, pwntools, and the ret2csu challenge binary
  6. Confirm the two gadgets really exist in this binary
  7. Find the offset and the target you must call
  8. Chain the two gadgets: load rsi and rdx, then set rdi and call the target
  9. The pro way: let pwntools' ROP() assemble (and automate) the csu chain
  10. When ret2csu is the right rung — and how it is defended
  11. What you learned — and the next rung

Open the full interactive lab →