Vortex Level 3
Vortex Level 3 — a stack overflow with a twist, involving shellcode that must call setuid and the limits of overwriting constructor and destructor tables.
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
A Stack Overflow with a Difference
This level is pretty straight forward. Just sit down and understand what the code is doing. Your shellcode will require a setuid(LEVEL4_UID) since bash drops effective privileges. You could alternatively write a quick setuid(geteuid()) wrapper around bash.
NOTE: ctors/dtors might no longer be writable, although this level is compiled with -Wl,-z,norelro. Lookup some information about this e.g. here
Reading Material
Study guide
Level map: logged in as vortex3, obtain access to vortex4.
What this level teaches
Writing shellcode that survives dropped privileges, and understanding binary hardening flags.
Key ideas
- Bash drops privilege. The page notes that bash drops effective privileges, so your shellcode needs to call
setuiditself, or you can use a tiny wrapper that doessetuid(geteuid()). - ctors and dtors. Old writable tables of constructors and destructors were classic overwrite targets.
- Relocation hardening. The level is compiled without full relocation read-only (
norelro), yet the page notes the tables might no longer be writable; research why. - Reading. “Smashing the Stack” and “Bypassing StackGuard and StackShield” are linked.
How to approach it
- Read the code until you can say what it does line by line.
- Decide which overwrite target will work on this system, and verify it in
gdb. - Write shellcode that sets the right user ID before starting a shell.
Why it matters
Privilege handling in shells and the evolution of mitigations like RELRO explain why old exploit recipes stop working.