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/narnia2.md
URL /wargames/narnia/narnia2/
Date 2026-04-07

Narnia Level 2

Narnia Level 2 — a classic stack buffer overflow where you overwrite the saved return address to take control of execution.

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 narnia2, find the password for narnia3.

What this level teaches

The textbook “smash the stack” attack.

Key ideas

  • Stack frame. Each function call stores its locals, a saved frame pointer and a return address.
  • Control flow hijack. Overwriting the return address makes the function return to a place you choose instead of its caller.
  • Finding the offset. A cyclic pattern in gdb or pwntools shows exactly how many bytes are needed to reach the return address.
  • Where to jump. Into your own shellcode, whose address you must find reliably.
  • Reading material. “Smashing the Stack for Fun and Profit” is the classic paper.

How to approach it

  1. Read the source and note the buffer size and the unsafe copy.
  2. In gdb, crash the program with a pattern to find the offset.
  3. Place shellcode where you can predict its address and aim the return address at it.

Why it matters

Understanding this attack explains stack canaries, non-executable stacks and address randomisation, all of which exist to stop it.