Pwndamentals

Return-Oriented Programming

8 challenges

Challenges

CHALLENGE 01

Return to PLT

— solves

Import system() through the PLT, stage your own command in writable memory, and call it.

CHALLENGE 02

Return to libc

— solves

Use the libc leak to find system(), /bin/sh, and a pop rdi gadget inside libc, then chain them for a shell.


Common gotcha: the shell drops privileges like /bin/sh without -p, so you need to call setuid(0) first to keep root.

CHALLENGE 03

Return to Syscall

— solves

There is no helpful PLT target for a shell. Stage your own pathname, then use gadgets to invoke open(), read(), and write() as raw syscalls.

CHALLENGE 04

Return to CSU

— solves

One pop rdi is not enough when you also need rdx. The flag is already sitting in a global buffer, so use the two CSU gadgets to set rdi, rsi, and rdx at once.


The gadgets live in __libc_csu_init, which every dynamically-linked binary used to carry. glibc 2.34 removed __libc_csu_init/__libc_csu_fini, so on a modern system they are gone.

CHALLENGE 05

Stack Pivot

— solves

There is not enough room on the stack for a full ROP chain. Put the real chain somewhere writable, then pivot rsp onto it.

CHALLENGE 06

Return to Sigreturn

— solves

The gadget set is too small for normal ROP, but one rt_sigreturn can restore every register at once. Build a fake signal frame, then use it to invoke execve().

CHALLENGE 07

Return to mprotect

— solves

NX is on, but mprotect() is only a ROP chain away. Mark a writable page executable, stage shellcode there, and jump to it.

CHALLENGE 08

Return to dlresolve

— solves

No libc leak and no system() import. Stage a fake relocation, a symbol table entry, and your own command in writable memory, then bounce through the dynamic resolver to call system() anyway.