Possible duplicate:
Need help understanding salt salt
Update: Please note that I am not asking what salt is, what is a rainbow table, what is dictionary attack, or what is the purpose of salt. I ask: if you know user salts and hash, isn’t it easy to calculate their password?
I understand the process and implement it myself in some of my projects.
s = random salt storedPassword = sha1(password + s)
In the database you are storing:
username | hashed_password | salt
Each salting implementation that I saw adds salt either at the end of the password, or begins:
hashed_Password = sha1(s + password ) hashed_Password = sha1(password + s)
Thus, a hacker's vocabulary attack, which is worth its salt (ha ha), simply launches each keyword against stored salts in the common combinations listed above.
Undoubtedly, the implementation described above simply adds another step for the hacker, without solving the main question? What alternatives exist to solve this problem or I do not understand the problem?
The only thing I can do is to have a secret blending algorithm that combines salt and password together in a random pattern or adds other custom fields to the hashing process, i.e. the hacker must have access to the database AND code to string them to attack the dictionary, to prove their fruitfulness. (The update, as stated in the comments, is best to assume that the hacker has access to all your information, so this is probably not the best).
Let me give an example of how I suggest a hacker hack a user database with a list of passwords and hashes:
Data from our hacked database:
RawPassword (not stored) | Hashed | Salt -------------------------------------------------------- letmein WEFLS... WEFOJFOFO...
General Password Dictionary:
Common Password -------------- letmein 12345 ...
For each user entry, loop common passwords and hash them:
for each user in hacked_DB salt = users_salt hashed_pw = users_hashed_password for each common_password testhash = sha1(common_password + salt) if testhash = hashed_pw then //Match! Users password = common_password //Lets visit the webpage and login now. end if next next
Hope this illustrates my point much better.
Given 10,000 shared passwords and 10,000 user records, we will need to calculate 100,000,000 hashes to find as many user passwords as possible. This may take several hours, but this is not a problem.
Crack Theory Update
We will assume that we are a corrupt web host that has access to a database of SHA1 hashes and salts along with your algorithm for mixing them. The database contains 10,000 user records.
This site claims to be able to calculate 2,300,000,000 SHA1 hashes per second using the GPU. (In a real situation, the situation is likely to be slower, but for now we will use this figure).
(((95 ^ 4) / 2300000000) / 2) * 10000 = 177 seconds
Given the full range of 95 printable ASCII characters with a maximum length of 4 characters, divided by the computation speed (variable), divided by 2 (assuming that the average password detection time requires an average of 50% permutations), it would take 177 seconds for 10,000 users, to generate all user passwords whose length is <= 4.
Rather adjust it for realism.
(((36 ^ 7) / 1,000,000,000) / 2) * 10,000 = 2 days
Assuming case insensitivity with a password length <= 7 of only alphanumeric characters, it would take 4 days for 10,000 user records, and I halved the speed of the algorithm to reflect overhead and not ideal circumstances.
It is important to recognize that this is a linear attack using brute force, all calculations are independent of each other, so this is an ideal task for solving several systems. (IE is easy to configure 2 computers running an attack from different ends, which will be half the shutdown time).
Given the case of recursive password hashing 1000 times to make this task more expensive:
(((36 ^ 7) / 1,000,000,000) / 2) * 1000 seconds = 10.8839117 hours
This means a maximum length of 7 alphanumeric characters when performing less than half the speed of the quoted digit for one user.
Recursive hashing 1000 times effectively blocks a full attack, but targeted attacks on user data are still vulnerable.