Narnia Level 7
Narnia Level 7 — a format-string bug again, this time used to redirect a function pointer.
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 narnia7, find the password for narnia8.
What this level teaches
Combining the format-string write primitive with a function pointer to change control flow.
Key ideas
- Function pointers store the address of code to call. Changing one changes what runs.
- Writing a precise value. With
%nand careful padding, you can write multi-byte values, sometimes in smaller pieces. - Reading the layout. The addresses of the intended and unintended functions are printed or discoverable in the program.
- Same technique, new goal. You have already seen this idea in Level 5; here the target is different.
How to approach it
- Read the source and note how the pointer is set and used.
- Find the addresses involved and the stack position of your input.
- Build the format string, test with harmless values, then use the real ones.
Why it matters
Writing a pointer is the usual first step to controlling a program, even in modern, hardened software.