Vortex Level 4
Vortex Level 4 — a common format-string bug guarded by a check on argc, which makes you think about how programs are started.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
To exec or not to exec
This is the common format string bug, exploit it with care though as a check is made with argc. What is the layout of a process’s memory? How are programs executed?
Reading Material
- Format String Technique
- Exploiting Format String Vulnerabilities
- Bypassing StackGuard and StackShield
Study guide
Level map: logged in as vortex4, obtain access to vortex5.
What this level teaches
Format-string exploitation under an unusual constraint.
Key ideas
- Format strings. The page links papers on the technique, the classic guides to reading and writing memory with
printf. - The
argccheck. The program verifies the number of arguments, so you must find another way to deliver the format string and control execution. - Process memory layout. The page asks: what is the layout of a process’s memory, and how are programs executed? Environment variables, arguments and the loader all matter.
- Executing programs.
execvelets you start a program with arbitrary argument and environment settings, including an unusualargc.
How to approach it
- Read the code and find where the format string comes from.
- Work out how to start the program with the argument count and environment you need.
- Use
gdbto find the stack positions and build the write.
Why it matters
Understanding how the kernel and loader hand a program its arguments helps in many exploitation scenarios.