OverTheWire - Natas - Level 7 → Level 8

Warning: This post contains a solution!

Only continue if:
1.) you want to see a possible alternative solution or
2.) you are stuck and need a hint!


Login using given credentials.

Username: natas8
Password: DBfUxxxxxxxxxxxxxxxxxxxxxxxxxxxx
URL:      http://natas8.natas.labs.overthewire.org

Following code is used to verify the entered secret, as available in the site sourcecode:

<?

$encodedSecret = "3d3d516343746d4d6d6c315669563362";

function encodeSecret($secret) {
    return bin2hex(strrev(base64_encode($secret)));
}

if(array_key_exists("submit", $_POST)) {
    if(encodeSecret($_POST['secret']) == $encodedSecret) {
    print "Access granted. The password for natas9 is <censored>";
    } else {
    print "Wrong secret";
    }
}
?>

The entered secret is compared with the $encodedSecret to verify the entered secret. Based on the code, the entered secret is:

  1. Base64 encoded: base64_encoded
  2. String reversed: strrev()
  3. Converted from binary to hex: bin2hex()

The solution is simple, just take the value from $encodedSecret and execute the steps backwards to get the valid secret.

Show Comments