A dictionary attack is form of lookup attack used to crack passwords even when the passwords have been obscured with a hash function.
Step 1: Steal a Password Table
This is the most difficult part of the attack, as system administrators don't just give away user's passwords. Obtaining a password table means being able to defeat a system's security or buying one from someone who has. Since it is a security flaw for even admins to know a user's password, the passwords in the table are almost always obfuscated through a one-way hash function. So, when you look at a password table, it may look something like this:
In this case, the passwords have been run through an MD5 hash function which cannot be reversed. When a user logs in, the computer will first apply the hash to the password they typed in, and compare it with the one on file to ensure a match. This way, the plaintext password is only even known by the user. So then, how can a password cracker ever determine a user's password? This is where the dictionary attack comes into play.
Step 2: Obtain a List of Commonly Used Passwords
This is particularly easy since many crackers have already done the hard work and compiled lists of commonly used passwords. Here is an example list:
Step 3: Run the Same Hash On the List of Common Passwords
Hash functions used to obfuscate passwords cannot be reversed, but they can be repeated. To do this, a cracker must know the exact same hash function used to obfuscate the passwords in the stolen password table. This isn't too difficult, since only a few are commonly used. From here, the cracker runs all the commonly used passwords through the same hash function and gets a list of the hashes for each of the passwords.
|Common Password||MD5 Hash|
I should point out that the MD5 hash function is not a cryptographically secure hash function and should never be used to store passwords. I'm just using it for this example.
Step 4: Compare Against the Password Table
Once the dictionary of hashes has been generated, the cracker need simply look for matches in the hashes between the stolen password table and their dictionary. A match indicates that the user chose the password in the table.
|User||Password||Match From Dictionary|
This method will identify every password in the stolen password table that matches one in the dictionary of commonly used passwords, which, in common practice, is often over half.
Since computers are very fast at generating hash functions and comparing values between two tables, a dictionary attack with millions of commonly used passwords can be carried out against a table of millions of user passwords in a matter of minutes.
In order to combat dictionary attacks, most modern password tables first apply a salt to passwords before sending them through a hash function. A salt is a modification to a password so that it will yield a completely different hash. For example, the password below have been salted by adding a question mark to the beginning of them before being hashed, which gives an MD5 hash that is totally different from the hash without the question mark.
|Common Password||MD5 Hash||Salted Hash|
When using a salt, the program that handles user passwords must not only apply the salt when storing the password into the password table, but it must also apply the salt to the password each time a user logs in to make sure it will match the hash in the password table.
A salted password table adds a layer of security because, in order for a dictionary attack to work, the dictionary of hashes must be generated with the passwords and the salt. So, if the cracker doesn't know the salt, all of the password will fail to find a match. However, if a cracker defeated a system's security well enough to make a copy of the password table, they probably also made a copy of the program that adds the salt. So, a salt will not stop a cracker, because they will be able to determine how the salt was added and apply it to their password dictionary, but it will slow them down.
- en.wikipedia.org/wiki/Dictionary_attack - Wikipedia.