An audit before a thief does it
A college's security team copies its own password table and runs a cracker against it. Every password that falls in an hour is one a thief would find too. Those people are asked to change their password today.
That is the only honest reason to crack hashes: your own, or with written permission.
By the end of this lesson
Note
I can use John the Ripper's word list, rules and mask modes on hashes I may test.
Key words
| Word | What it means | Example |
|---|---|---|
| John the Ripper | an open source password cracker | |
| Word list mode | trying every word in a file | |
| Rules | changes made to each word before it is tried | |
| Mask | a pattern of characters to try | ?d is any digit |
| Pot file | where John keeps what it has cracked | |
| Cost | how much work one guess takes |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsThe rule for this lesson
Warning
Crack only the hashes this lab made. Every account and password in it is made up, and your copy has no way out to the internet. Trying passwords against anybody else's accounts without written permission is a crime under the Computer Misuse Act 1990.
A word list cracks the common choices
John hashes each word in the list with the same scheme and compares it with every stored hash. A fast, unsalted hash like raw SHA-256 lets one guess test every account at once.
John prints each password it finds beside the account. It keeps them in its pot file, so --show lists everything cracked so far, and a second run has nothing left to do.
Try the word list on the fast hashes
docker exec john john --format=raw-sha256 --wordlist=words.txt hashes/fast.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Show what is cracked so far
docker exec john john --show --format=raw-sha256 hashes/fast.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Worked example: the word list run
| What John printed | What it means |
|---|---|
| Loaded 5 password hashes with no different salts | Six accounts, but two shared one hash |
| dragon (finn), sunshine (amira) | Two hashes cracked by plain words |
| amira, dev and finn in --show | dev shared amira's hash, so fell with it |
| 3 password hashes cracked, 3 left | ben, chloe and erin held |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsRules and masks follow human habits
Rules change each word the way people do: a capital first, a digit or a year on the end, a letter swapped for a symbol. Masks try a pattern you suspect, character by character.
?d is any digit and [Ss] is S or s. A season and a year is a pattern worth a mask. Neither mode is clever: each just follows the habits people share.
Count the guesses the rules make
docker exec john sh -c "john --wordlist=words.txt --rules --stdout | wc -l"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Try the word list with rules
docker exec john john --format=raw-sha256 --wordlist=words.txt --rules hashes/fast.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Try a season and a year
docker exec john john --format=raw-sha256 --mask="[Ss]ummer20?d?d" hashes/fast.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think a capital letter and a digit on a word make it safe. John's default rules made 274,381 guesses from 97 words and found Liverpool1 among the first five thousand. A pattern is only safe if attackers do not guess it, and they guess the common ones first.
Check
Have a go
Check
3 questionsTry it: rules by hand
# A rule turns one word into many guesses.
word = "liverpool"
guesses = [word, word.capitalize()]
for digit in range(10):
guesses.append(word.capitalize() + str(digit))
print(len(guesses), "guesses from one word")
print(guesses[:4])
# Add the year 2026 on the end of the capitalised word too, then press Run.
Make a free account to save your work and track your progress.
A slow, salted hash makes every guess cost
bcrypt.txt holds the same passwords with bcrypt. Each account has its own salt, so a guess must be hashed once per account. The cost, 256 here, is the number of rounds of slow setup in each hash.
The word list still finds the three passwords on it. But 274,381 rule guesses would now mean 1,646,286 slow hashes, six salts each, instead of 274,381 fast ones.
Try the word list on bcrypt
docker exec john john --format=bcrypt --wordlist=words.txt hashes/bcrypt.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Show what bcrypt gave up
docker exec john john --show --format=bcrypt hashes/bcrypt.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
The fix, and how to detect a theft
Fix: store passwords with a slow, salted scheme made for them: Argon2id, scrypt or bcrypt, with a cost tuned to your server. Refuse passwords on a breached list, and ask for MFA so a cracked password is not enough.
Detect: offline cracking is invisible, so watch for the theft. Alert on bulk reads of the users table. Plant a honey account that nobody uses: a sign-in to it means the table has leaked.
Check
Have a go
Check
3 questionsAssignment: a cracker with rules
Write a small cracker for unsalted SHA-256 hashes, the lab's fast.txt in miniature. sha(text) returns the SHA-256 of the text as lowercase hex. variants(word) returns 22 guesses in this order: the word, the word with its first letter capitalised, the word followed by each digit 0 to 9, then the capitalised word followed by each digit 0 to 9. crack(table, words) takes a dictionary from a name to a hash and a list of words, tries every variant of every word in order, and returns a dictionary from each cracked name to its password. Keep the first password found for a name.
import hashlib
def sha(text):
return ""
def variants(word):
return [word]
def crack(table, words):
return {}
Make a free account to save your work and track your progress.
Exit quiz
Have a go