0

I am working on the following war game from Defend The Web, which requires me to do a source code review to login as the user memtash. The code is on GitLab here.

Having inspected the source code during this code review, I find this line interesting:

$token = md5(openssl_random_pseudo_bytes(32));

The output of the md5() function in PHP is:

 - Always 32 characters
 - Lowercase
 - Hexadecimal format (0-9, a-f)

My plan is to request a password reset for the user memtash on the webpage, and then bruteforce through every possible combination, following the above rules. Eventually, one combination will bring me to the password reset screen.

I was wondering how long it would take an average consumer computer to brute force this token? I was planning to write a Python script, but it is likely Burpsuite can already do this.

3
  • 1
    Note that the output of the PHP md5() function is something of a red herring here, because the output as described is really the hexadecimal string encoding of a bunch of raw bytes. ie, it's not actually randomly picking 1e, but instead has generated the byte pattern 00011110. Feb 6, 2023 at 1:52
  • 1
    Having looked at the code on gitlab, there is a major security bug in the way login() and reset() are coded in combination with each other. Due to this bug, it also creates a user experience problem as well... You don't actually need to worry about the token, the solution is much simpler than that. Feb 6, 2023 at 1:56
  • @Clockwork-Muse Yeah I figured it out, if you look at the question I posted after this one. Feb 6, 2023 at 17:38

1 Answer 1

3

How long it takes to bruteforce something depend on a couple factors: if the attack is offline (where the attacker have the hash and bruteforces it) or online (the attacker sends data to the server and receives responses back), the hash type, the number of iterations.

It is not clear from your question if you are trying to get the password from the hash, or you are sending the hash to the server.

If you have the hash and want the password, and you are doing it on your machine, it will heavily depend on how fast you can feed data to MD5. The output of MD5 is 2128, and that's a large number.

If the attack is online, it's usually not feasible to bruteforce a hash. Even if you can send a million tries per second, it's still too little to get a collision on a 2128 output space.

Even if you are just trying to "forge" the token (it's a hash of 32 bytes), it will still take too much time to do online (I mean several thousand centuries).

So if this is a CTF, you need to find another route.

2
  • It is an online attack, sending the hash to the server. Feb 4, 2023 at 23:19
  • Any ideas what else I could try, it seems vulnerable to SQL injection since there is no sanitising, but I am stuck. Feb 4, 2023 at 23:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .