2

When checking the manual entry for man crypt, I read:

The returned value points to the encrypted password, a series of 13 printable ASCII characters (the first two characters represent the salt itself).

I made a dummy function to test 'crypt()', and, indeed, that's precisely the behaviour I see:

pass = 'abcdef', salt = 'bB' --> hashed = 'bB3chWwMx2m9A'

pass = 'abcdefgh', salt = 'bB' --> hashed = 'bBOdphLIbu4wI'

The way I see it, I read the hashed string from a file, I get the first two char, and I already have my 'salt' ready. I only need to crypt my guesses once.

So, I was wondering: if you can "deduce" the value of 'salt' from the hashed string... What's the purpose of it existing anyway? (or is it because while using other hashing methods, such as "SHA-512", it does make a difference?)

2

The salt is used to influence the encryption process. If you call crypt twice on the same key passing in different salt each time, you'll get different hashes (results).

The salt can be any two characters, each of which is in the set [./0-9A-Za-z]. That's a total of 64 characters. This means that you can have 64^2 possible combinations of 2-character salts and therefore the same key can be encrypted in 64^2 different ways.

crypt returns a 13-character string that represents the encrypted key, the first 2 of which are the same as the two-character salt that was used to encrypt the key.

| improve this answer | |
  • OK, but: if you have access to the hashed string (as it's the case in "hacker2") you can obtain the salt actually used only by getting the first 2 chars. So the 64^2 options get narrowed down to 1 again. Am I right? Even if the string was hashed several times, it would be just a matter of repeating this 'get2chars -> salt -> unencrypt' process as many times. Or am I getting something wrong? – abelinux Nov 25 '14 at 13:10
  • 1
    @abelinux sort of. A public salt does not make dictionary attacks hard when cracking a single password. However, it makes Rainbow table attacks way harder. Also, if you hashed the hash of a password, and even though you had access to the salt of the hash, probably a dictionary attack wouldn't work and if you tried a brute-force attack you'd need to generate, at the worst case, nearly 11^95 combinations to get the hash of the password, then to perform a dictionary attack to get the password which is quite time-consuming. – Kareem Nov 25 '14 at 18:03
  • @abelinux you can find more information about necessity of hiding the salt of a hash here! – Kareem Nov 25 '14 at 18:14
  • OK, I (think I) see it better now. I was looking at it "in the context" of this exercise, so I couldn't really understand the use of the 'salt'. Now I get that, since we're actually cracking single passwords, I was "kinda" right: there's merely any difference if the attacker knows the salt's length (like it's the case here). – abelinux Nov 26 '14 at 19:03
  • But in case someone else is interested I found this nice wiki about "Salt": <en.wikipedia.org/wiki/Salt_%28cryptography%29#Benefits>. Here it explains the "practical" difference between 'single' and 'multiple' password cracking. I found it really "illustrative" ;) – abelinux Nov 26 '14 at 19:15

You must log in to answer this question.

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