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.

Quick Links

Theme & Build

Jekyll v3.10.0
Last BuildNov 24, 17:25

Page Location

Page Info

Layout default
Collection wargames
Path _wargames/narnia/narnia0.md
URL /wargames/narnia/narnia0/
Date 2026-04-07

Narnia Level 0

Narnia Level 0 — overflow a buffer to overwrite a neighbouring variable and learn how data is laid out in memory.

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 narnia0, find the password for narnia1.

What this level teaches

The simplest memory bug: writing more data than a buffer holds so that it spills into the next variable.

Key ideas

  • Adjacent variables. Local variables sit next to each other on the stack, so overflowing one can change another.
  • Little-endian values. The target value must be written into memory least-significant byte first.
  • Printing bytes you cannot type. A printf or perl -e 'print ...' command can emit arbitrary bytes for you.
  • Keeping the shell open. The program may run a shell that exits immediately if its input ends; read about how to keep standard input open.

How to approach it

  1. Read the source and note the size of the buffer, the other variable and the check that depends on it.
  2. Find the exact number of bytes needed to reach that variable and what value it must hold.
  3. Send the input from a command and keep the connection open so the shell stays usable.

Why it matters

Overwriting an adjacent flag, length or permission field is a real-world pattern as well as a teaching one.