The white box is composed of three parts:
Here is the interesting part of the server source code:
<h1>natas8</h1>
<div id="content">
<?
$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";
}
}
?>
<form method=post>
Input secret: <input name=secret><br>
<input type=submit name=submit>
</form>
<div id="viewsource"><a hrefoubWYf2kBq="index−source.html">View sourcecode</a></div>
</div>
So we need to decode the secret 3d3d516343746d4d6d6c315669563362 in this order:
The operations can be performed using tools available online. But first let’s see how we can encode our secret using the same process.
Our secret will be encodeMe.
ZW5jb2RlTWU=
.=UWTlR2bj5WZ
.3d5557546c5232626a35575a
.Decoding our secret is super easy.
If we apply this method to the secret 3d3d516343746d4d6d6c315669563362
we get:
1. ==QcCtmMml1ViV3b
2. b3ViV1lmMmtCcQ==
3. oubWYf2kBq
Our secret will be encodeMe.
sammy@server: ̃$ echo −n "encodeMe" | base64
ZW5jb2RlTWU=
The echo -n prevents the newline from echo being encoded in the result. Had we not prevented that, the result would be different:
sammy@server: ̃$ echo "encodeMe" | base64
ZW5jb2RlTWUK
sammy@server: ̃$ echo "ZW5jb2RlTWU=" | rev
=UWTlR2bj5WZ
Here is the definition of the bin2hex function from the php.net website:
string bin2hex ( string $str ) Returns an ASCII string containing the hexadecimal representation of str. The conversion is done byte-wise with the high-nibble first.
Well, a function that returns the hexadecimal representation of a string: xxd.
sammy@server: ̃$ echo −n "=UWTlR2bj5WZ" | xxd −p
3d5557546c5232626a35575a
We just have to revert xxd with the -r option.
sammy@server: ̃$ echo −n "3d5557546c5232626a35575a" | xxd −r −p
=UWTlR2bj5WZsammy@server: ̃$
sammy@server: ̃$ echo "=UWTlR2bj5WZ" | rev
ZW5jb2RlTWU=
sammy@server: ̃$ echo −n "ZW5jb2RlTWU=" | base64 −d
encodeMesammy@server: ̃$
One liner
sammy@server: ̃$ echo −n "3d3d516343746d4d6d6c315669563362" | xxd −r −p | rev | base64 −d
oubWYf2kBqsammy@server: ̃$
Once we enter oubWYf2kBq
in the input and submit the query, the page refreshes and we get the following text:
Access granted. The password for natas9 is W0mMhUcRRnG8dcghE4qvk3JA9lGt8nDl