Hashing is a mathematical function which transforms an arbitrary number of input bytes into a (typically) fixed-size output; common examples of hash functions are MD5, and SHA-256.

$ echo -n dotnetguard | md5sum

$ echo -n dotnetguard | sha256sum

Hash functions are designed to work in one direction. This means it should not be possible to figure out what the original password was based on the hash alone. When attackers attempt to do this, it is called password cracking. Common techniques are to use rainbow tables, to perform dictionary attacks, and typically as a last resort, to perform brute-force attacks.

Rainbow tables

Rainbow tables are large pre-compiled maps of input and output values for a given hash function. These can be used to very quickly identify the password if its corresponding hash has already been mapped.

PasswordMD5 Hash
123456e10adc3949ba59abbe56e057f20f883e
12345827ccb0eea8a706c4c34a16891f84e7b
12345678925f9e794323b453885f5181f1b624d0b

Because rainbow tables are such a powerful attack, salting is used. A salt, in cryptographic terms, is a random sequence of bytes added to a password before it is hashed.

Brute-force attack

A brute-force attack involves attempting every possible combination of letters, numbers, and symbols until the correct password is discovered.

Dictionary attack

A dictionary attack, otherwise known as a wordlist attack, is one of the most efficient techniques for cracking passwords, especially when operating under time-constraints as penetration testers usually do.