WCU / Cybersecurity
~/CSC 472/Class 07/KP 04
Class 07 · KP 04 / 18

32-bit ret2libc: Arguments Live on the Stack (cdecl)

attacker stackpadding A*N→ pop rdi ; retgadgetarg1in RDI→ pop rsi ; retgadgetarg2in RSI→ system()target.text / libcexisting code
A ROP chain: each 'ret' launches the next gadget already present in the code.

On x86 (32-bit), a called function reads its arguments from the stack, just

above the saved return address. We forge a fake call frame:

{ Layout after overflow: [padding][&system][&exit][&"/bin/sh"].

When the vulnerable function returns, it "returns into" system,

which finds "/bin/sh" exactly where a normal caller would have left it.}