Skip to main content

Settings

Color Mode

Theme Skin

Background

Appearance preferences are saved in this browser only.

Environment

Current Environment Production

Built with JEKYLL_ENV=production. Changes require deployment.

Theme & Build

Jekyll v3.10.0
Last BuildOct 17, 19:54

Page Info

Layout default
Collection none
Path overthewire/narnia/narnia4.md
URL /docs/wargames/narnia/narnia4/
Date 2026-04-07

Source Code

Set repository: USER/REPO in your _config.yml to enable source-code shortcuts.

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

  1. Read the source and find out what the program does to the environment.
  2. Use gdb to find the offset and your buffer’s address.
  3. 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.