Skip to content

Narnia Level 7

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 %n and 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

  1. Read the source and note how the pointer is set and used.
  2. Find the addresses involved and the stack position of your input.
  3. 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.