Multi-Stage Exploitation: Info Leak, GOT Overwrite, and ret2libc
The goals of this lab:
- Understand why modern targets (with ASLR + NX) require chaining multiple primitives.
- Perform an information leak to defeat ASLR and compute the libc base.
- Use GOT overwrite / ret2libc to get a shell on a remote server and read a flag.
Server details
- Target host/port: provided on the course website
- Vulnerable program:
lab5_vuln(lab5_vuln.c) - Target file:
flag.txt - ASLR / NX: On StackGuard / PIE: Off RELRO: Partial
- Remote libc: provided with the lab (use it for offsets)
Background
Because ASLR randomizes the libc base each run, hardcoded addresses fail. So the exploit has two stages: (1) leak a known GOT entry (e.g., puts) using the program's own output, then compute libc_base = leaked_addr - libc.symbols[func]; (2) with libc located, return into system("/bin/sh") (or a one_gadget), or overwrite a GOT entry, to get a shell. The PLT/GOT mechanism (lazy binding through a writable GOT under Partial RELRO) is what makes both the leak and the overwrite possible.
Experiment Setup
- Log in to Badger CTF and copy the binary and the remote libc for offset calculation: cp /workdir/ss2026/lab5/lab5_vuln . cp /workdir/ss2026/lab5/libc.so.6 .
- Do not recompile
lab5_vuln.cfor the remote attack — compiler/libc differences shift addresses. You may compile a local copy to practice withprocess(). - Develop locally, then switch to the remote target. A skeleton (
lab5_exp.py) is provided; it reads the host/port fromLAB5_HOST/LAB5_PORTand toggles remote withpython3 lab5_exp.py REMOTE.
Lab Exercise
Objective 1: Information leakage (4 points)
Leak a libc address and compute the libc base.
Objective 2: Get a shell and read the flag (6 points)
Use ret2libc (or GOT overwrite) to spawn a shell, then retrieve flag.txt.
flag.txt. (3 pts)Hints
Review Class 05: Exploit Mitigations and Class 08: Multi-Stage Exploitation. Useful tools: pwntools ELF/ROP, one_gadget, and a libc-offset database. Match your local libc to the remote one before porting.
Deliverables
A comprehensive PDF report documenting every stage with screenshots, code snippets, your computed libc base, and the contents of flag.txt.
Submission
- The lab due date is available on our course website. Late submissions will not be accepted.
- Submit your assignment to D2L directly.
- No copy or cheating is tolerated. If your work is based on others' or AI, please give clear attribution. Otherwise, you WILL FAIL this course.