Module 3 · Cryptography and PKI · Lesson 27 of 42
Password cracking: brute force, dictionaries and rainbow tables
How systems store passwords as hashes, how attackers who steal those hashes crack them with brute force, dictionaries and precomputed tables, and why salting and key stretching are the defenses.
In this lesson · about 22 minutes
- Explain where logon passwords are stored and why they're hashed, not kept in clear text
- Compare brute-force, dictionary and rainbow-table attacks
- Explain how salting defeats precomputed tables and how key stretching slows every guess
- Recognise that longer, less predictable passwords and keys are the real defense against brute force
Passwords protect logon accounts on Linux and Windows, and they also stand in for keys: the passphrase on a Wi-Fi network, the password on an encrypted PDF or ZIP. So "password cracking" and "key cracking" turn out to be the same problem, and the exam treats them together.
Systems don't store your password
Picture a single Linux box that everyone has to log in to. Somewhere there's a list of usernames paired with passwords, but the password column isn't readable text. It's a hash. When you type your password, the system hashes what you typed and compares it with the stored hash. Match means you're authenticated. The real password is never written down, so an administrator (or a thief) who reads the file sees only hashes.
That's nearly universal. The weak point isn't the hashing, it's us: people pick predictable passwords. Roughly most passwords are an ordinary word (a pet, a partner, a child's name) with one or two digits and maybe a ! on the end. An attacker who steals the hashes exploits exactly that.
Three ways to crack a stolen hash
- Brute force: try every possible combination, hashing each guess and comparing. It always works eventually, but "eventually" can be longer than the age of the universe. Every extra character multiplies the work.
- Dictionary attack: instead of every combination, try a wordlist, a huge file of likely passwords (real human words and known leaked passwords), with common variations like
Mike1,Mike123,Mike123!. Far fewer guesses, and it catches the predictable passwords most people actually use. - Rainbow table: do the hashing ahead of time. A rainbow table stores dictionary words with their hashes already computed, using clever math (reduction functions) to stay a few hundred megabytes instead of petabytes. At attack time there's no hashing at all, just a lookup: find the stolen hash in the table and read off the password.
Attackers usually work offline: grab the hash file (booting from a USB stick, for example), copy it, and crack it at leisure on their own machine. Out of 30 stolen accounts they may only crack a few, but one is often enough.
Try it: password cracking lab
Crack a stolen password file
Below is a made-up /etc/shadow-style file: five accounts, each stored as a SHA-256 hash. Run each attack and watch which passwords fall. Then turn on Salt each password and run them again to see what changes.
Stolen password file (SHA-256)
| user | stored hash | cracked |
|---|
Everything runs in your browser on made-up accounts. A real rainbow table uses hash chains and reduction functions to store far less than this simple lookup table, but the idea is the same: the work is done before the attack.
How long would brute force take?
9 characters from a pool of 95 possible characters = about 10^17 combinations.
Fast hash, no stretching
Average brute-force time: about 365 days
Key stretching (PBKDF2, 600,000 rounds)
Average brute-force time: about 599,142 years
✗ This is a common word with a few characters on the end. A dictionary attack tries it in the first few hundred guesses, so the brute-force times above don't protect it.
Assumes an attacker testing 10 billion guesses per second against a fast hash such as unsalted SHA-256. Real rates depend on the hardware and the hash, so treat these as rough comparisons.
Salting: beat the precomputed table
Salting adds a random value to each password before hashing. The salt isn't secret, it's stored right next to the hash. Its job is to make every stored hash unique: two users who both chose password get completely different hashes. That breaks rainbow tables, because a table built without your exact salt matches nothing. An attacker is forced back to hashing one guess at a time, and must redo the work separately for every user.
Key stretching: make every guess slow
Salting doesn't slow brute force down; it just stops the shortcut. Key stretching does slow it: hash the password thousands of times over (algorithms like PBKDF2, bcrypt and Argon2 are built for this). One login is still fast enough for a person, but an attacker testing billions of guesses now pays that cost on every single one. Wi-Fi does the same thing: WPA runs your passphrase and the network name through PBKDF2 thousands of times.
The estimator in the lab above lets you feel both effects: a short common word falls to a dictionary instantly no matter what, while a long random password pushes brute force past any realistic timeframe, and key stretching pushes it further still.
Check your understanding0 of 6 correct
Quiz score: 0 of 6
Noviq Academy is free and for learning. This course is independent and is not affiliated with or endorsed by CompTIA. CompTIA and Security+ are trademarks of CompTIA, Inc. Exam details such as price and policies change; confirm them on CompTIA's website before you book.