Narnia4
Narnia Level 4 — a stack overflow where the environment has been cleared, so your injected code must live in the buffer itself.
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 narnia4, find the password for narnia5.
What this level teaches
Adapting a familiar attack when a convenient hiding place is taken away.
Key ideas
- Where payload can live. Earlier you may have used the environment; if the program wipes it, the buffer or arguments must hold your code.
- Reliable addresses. The stack position can shift with environment and argument size, so use
gdb’s view and be consistent between debugging and real runs. - NOP sleds. A run of no-operation instructions in front of shellcode widens the target you must hit.
- Size limits. Shellcode has to be small enough to fit.
How to approach it
- Read the source and find out what the program does to the environment.
- Use
gdbto find the offset and your buffer’s address. - Build a payload of padding, shellcode and return address that fits.
Why it matters
Practice in adapting to constraints is the core skill of exploit development.