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
- The encoding is: hex-encode, reverse, base64-encode.
- The reverse is: base64-decode, reverse, hex-decode.
bytes.fromhex()converts the hex string to the original bytes.
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