0

In XVWA (Xtreme Vulnerable Web Application) I presented with an PBKDF2 with sha256 and 1000 iteration as such:

<?php

function create_hash($password)
{
    // format: algorithm:iterations:salt:hash
    $salt = base64_encode(mcrypt_create_iv(PBKDF2_SALT_BYTE_SIZE, MCRYPT_DEV_URANDOM));
    return  $salt . " : " . 
        base64_encode(pbkdf2(
            PBKDF2_HASH_ALGORITHM,
            $password,
            $salt,
            1000,
            24,
            true
        ));
}
// where $password is a user supplied data.

https://github.com/s4n7h0/xvwa/blob/master/vulnerabilities/crypto/PasswordHash.php

Is there a way to retrieve the password?

0

You can try to reverse a hash value by trying to brute force it, i.e. run the has function over a list of possible (password) values until you encounter the same output. If this procedure can be successful is dependent on two questions:

  • How fast can I compute a password hash (or in other words: how many passwords can I try per second)
  • How complicated is the password (how many password will I have to try before I find the password)

The calculation time is the quotient of those two values. That is why one uses designated password hashing functions which are slow.

While PBKDF2 is designed as a password hashing function, it has a rather dated design and the parameters chosen here (1000 iterations) are not appropriate for modern hardware.

So, assuming the password is not too complicated, you might have a realistic chance to reverse the hash. The standard tools for such an attack are hashcat and john the ripper.

  • on same password inputs I get different outputs. I do not think this is the case for the PBKDF2 exercises – Lucian Nitescu Jul 18 at 15:45
  • The salt ist created randomly. Running the function on the same password twice will result in different salts and thus different hashes. For verification/cracking, you need to know the salt value used (should be stored alongside the hash). – mat Jul 18 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.