Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Password Cracking Basics

The whole lesson is free and interactive. Read it here, or press Start lab to run it for real in a live lab, with no account needed.

Container lab9 min read5 commands

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

What does a thief do with a stolen password table?

A website should never store your password, only a hash of it: a fingerprint that cannot be turned back. A thief who copies the table cannot reverse a hash, but can guess: hash likely passwords and look for a match. This lab lets you do that to six made-up accounts and see which ones fall.

The one rule

Warning

Crack only the hashes this lab made. Every account and password here is made up, and your copy has no way out to the internet. Never try passwords against an account or system that is not yours without written permission: in the UK that is a crime under the Computer Misuse Act 1990.

By the end of this lesson

Note

I can use John the Ripper to show which stored passwords are weak.

Key words

  • Hash: a fixed-length fingerprint of some text.
  • Salt: a random value stored beside a hash, different for each account.
  • Word list: a file of likely passwords to try.
  • Rules: changes John makes to each word, such as a capital letter or a digit on the end.
  • Cracked: a hash whose password has been found by guessing.

Starter: what you already know

Note

Answer in your head. 1. Can you work a password out from its hash directly? 2. Two accounts have the same password. With no salt, are their hashes the same? 3. Which is easier to guess: a short common word or a long random phrase? Answers: no, a hash only goes one way; yes; the short common word.

Before you start

Note

Press Start the lab on the bar at the top of this lesson and wait until it says it is running. John the Ripper is in a service called john, and the hashes are in its hashes folder. Each Run button below types its command into your lab's terminal, one after another in the same session. To watch them, or to type your own, press Open terminal on the bar.

1. Look at the stolen table

The file holds six accounts and an unsalted SHA-256 hash of each password. Look at amira and dev: their hashes are the same, both starting a941a4c4. With no salt, the same password always gives the same hash, so the table already tells a thief that two people chose the same password.

Command
docker exec john cat hashes/fast.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

2. Guess from a word list

John hashes each of the 97 words and compares. It says it loaded 5 password hashes, not 6, because two were the same, and it cracks two at once: dragon for finn and sunshine for amira. The second Run shows every cracked account, dev included: 3 password hashes cracked, 3 left.

Command
docker exec john john --format=raw-sha256 --wordlist=words.txt hashes/fast.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Command
docker exec john john --show --format=raw-sha256 hashes/fast.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

3. Change the words with rules

Rules turn each word into many: a capital letter, a digit added, letters swapped. From 97 words John now tries hundreds of thousands, and finds Liverpool1 for ben. A capital and a digit on a common word add almost nothing.

Command
docker exec john john --format=raw-sha256 --wordlist=words.txt --rules hashes/fast.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

4. The same words against a slow, salted hash

bcrypt.txt stores the same passwords with bcrypt. John says 6 different salts: every account has its own salt, so each guess must be hashed six times. It says the cost is 256: each guess takes 256 rounds of a slow setup. The word list still finds amira, dev and finn, because their passwords are on it, but every guess costs far more.

Command
docker exec john john --format=bcrypt --wordlist=words.txt hashes/bcrypt.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Exit check

Tip

Answer without looking back. 1. Why did John load 5 hashes from 6 accounts in fast.txt? 2. Which password did the rules find? 3. What did bcrypt give every account? 4. Which account was never cracked, and why? Answers: amira and dev had the same unsalted hash; Liverpool1; a salt of its own and a cost of 256 rounds; erin, whose long phrase of random words is on no list.

For teachers

Tip

This lesson is a small example of a lesson worked in a lab: the steps and the Run buttons are the lesson, and the lab is each student's own copy. The lab is two small services, and nothing here marks itself: the student hands in a short report on their own copy, with which passwords fell to which mode, why erin's held, what credential stuffing did to the site before and after its defences, and a sign-in chosen for staff, none of which this lesson does for them. Key learning points: 1. A hash is guessed, not reversed. 2. A word list and rules find common passwords quickly. 3. A salt and a slow hash make every guess cost more, but cannot save a password that is on the list. Common mistake: thinking a capital letter and a digit make a password strong; Liverpool1 fell to the default rules. Equipment: the lab and its terminal. Tip: ask students to predict which of the six will fall before the first Run. The module Passwords, MFA and passkeys goes further in six lessons. Copy it into your own module and change it, or build one from scratch with the Lab menu in the lesson builder.

Teaching a class? Set these lessons for your students with marking and a lab for every student.