For Secure Hobby, a 250 point challenge, we were given a file and a place to connect to. The archive contained a binary, which looked okay enough to run. It opened a port on localhost. Upon connecting using nc
, the program first crashes because it can’t find flag
and namak
. After creating those files and connecting again, we are presented with the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Hmm. The second function verifies a login and the third displays a secret. Trying to register the user ‘admin’ resulted in an error. Still, it’s fair to assume we need to get the secret of the admin user. Let’s break this key down.
1 2 |
|
This looks like the last part of the login. What about the start? It seems to end with \x3d
which is ASCII =
. This screams base64!
1 2 3 4 5 |
|
So putting it all together again:
1 2 3 4 5 6 7 |
|
Looks like 595752746157343d21232f297a57a5a743894a0e4a801fc3
is the login we need! But alas, this doesn’t work. On the remote box, registering test
returns:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
It has to do with the namak
file. Namak is Persian for salt.
1
|
|
Now, registering test on the localhost server returns Your key for login is: 6447567a64413d3d1c13f2701648e0b0d46d8a2a5a131a53
. Furthermore, it looks like the salt is prepended to before hashing. We grabbed md5(salt) using a small Python script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
The output showed:
1 2 3 |
|
So the md5 of the salt would be 5624717e9a5fd673f17f5678c6303ffe
. I enlisted the help of NullMode to crack this hash, but to no avail. Instead of cracking this hash (seems inpossible), we decided to focus on the string comparison. We cannot register a username containing admin
, but perhaps we can circumvent this checking system somehow. First, I tried:
1
|
|
But this led to the same error message. Apparently, the username is not truncated. Instead, we assumed the check-string-for-admin uses normal string routines. These stop when they encounter a null-byte. Hash-functions on the other hand, do not. Let’s register a user \x00admin
using Python:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
This little gem returned 4147466b62576c7503812bbd45e23c059a0eab18e936b7ed
. Let’s try it out!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Holy crap, it worked! Let’s grab that secret! Fingers crossed:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
BOOM! We just landed another flag :) This one was actually fun to solve!