Writeups OverTheWireNatasWebPHPEncoding

Natas 8 Writeup - OverTheWire

Writeup for Natas level 8 from OverTheWire: reversing an encoding function to reconstruct the secret.

Contents

Wargame: Natas

Level: 8

Category: Web Security

Description

The PHP source shows the encoding function: base64_encode(strrev(bin2hex($secret))). The encoded secret is visible. Reversing the operations recovers the original secret.

Overview

Solution

encoded = "3d3d516343746d4d6d6c315669563362"
step1 = base64.b64decode(encoded).decode()     # base64 decode
step2 = step1[::-1]                             # reverse
secret = bytes.fromhex(step2).decode()          # hex decode

response = requests.post(url, auth=("natas8", current_password), data={"secret": secret, "submit": ""})
result = re.search(r"The password for natas9 is (.*)", response.text).group(1).strip()

Password

Sda6t0vkOPkM8YeOZkAGVhFoaplvlJFd

← Back to Blog