Narnia Level 6
Narnia Level 6 — a harder overflow where relying on injected shellcode is unattractive; think about reusing code that already exists in the program.
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 narnia6, find the password for narnia7.
What this level teaches
Reusing existing code rather than injecting your own, a stepping stone to modern exploitation.
Key ideas
- Return-to-libc. The C library is already loaded and contains useful functions. Redirecting execution to one with chosen arguments avoids needing shellcode.
- Calling conventions. On 32-bit x86, arguments go on the stack; you have to place them where the called function expects.
- Finding addresses.
gdbandlddhelp locate library functions, and addresses differ between runs if randomisation is on. - Read the source closely. The program’s structure determines which pointers or return addresses are reachable.
How to approach it
- Read the source and list what can be overwritten and what it controls.
- Locate the function you want to call and the string you want to pass it.
- Assemble and test the payload in
gdbbefore running it for real.
Why it matters
Return-to-libc leads directly to return-oriented programming (ROP), the standard bypass for non-executable stacks.