Narnia Level 3
Narnia Level 3 — another overflow level; use the source to see what an overflowing input can reach and plan around the program's file handling.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
There is no information for this level, intentionally.
Study guide
Level map: logged in as narnia3, find the password for narnia4.
What this level teaches
Reasoning about stack layout and about what the program does with files, not only about return addresses.
Key ideas
- Read the source before debugging. Note every buffer, its size, the variables declared near it and what the program does with them.
- Not all overflows target return addresses. Overwriting the right neighbouring variable can be easier and just as powerful.
- Files as inputs and outputs. When a program reads and writes files, think about what names you control and what links to other files you could create in a private
/tmpdirectory.
How to approach it
- Draw the stack layout of the main function from the source.
- Work out which variable your overflow reaches first and how the program uses it.
- Test in
gdb, then craft the file names or links needed.
Why it matters
Real exploits are usually found by studying program behaviour, not by blindly overwriting return addresses.