One password, four ways in
A college's staff sign in with a password. An attacker does not need to break the encryption on the page. They can guess at the sign-in form or copy the password table and guess offline. They can try passwords leaked from another site, or ask for the password with a fake email.
Each of those is stopped by a different defence. This lesson sorts them out.
By the end of this lesson
Note
I can match each way a password is broken to the defence that stops it.
Key words
| Word | What it means | Example |
|---|---|---|
| Online attack | guessing at the real sign-in form | |
| Offline attack | guessing against a stolen copy of the hashes | |
| Credential stuffing | trying pairs leaked from another site | |
| Phishing | tricking a person into typing their password | |
| Keyspace | how many passwords of a given shape exist | 26 ** 8 |
| Salt | a random value stored with each hash |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsFour ways a password is broken
An online attack guesses at the real form, so the site sees every try and can slow it down. An offline attack guesses against a stolen copy of the hashes, at whatever speed the attacker's computers manage.
Credential stuffing needs no guessing: it replays pairs leaked elsewhere, betting that people reuse passwords. Phishing and malware steal the password itself, so its strength does not matter at all.
Worked example: each way and what stops it
| Way in | What the attacker needs | What stops it |
|---|---|---|
| Online guessing | The sign-in form | Rate limits, a blocklist of common passwords |
| Offline cracking | A copy of the password table | A slow, salted hash and long passwords |
| Credential stuffing | Pairs leaked from another site | Breached-password checks, MFA, no reuse |
| Phishing | A believable fake page | Phishing-resistant sign-in such as passkeys |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsMatch each attack to its defence
Have a go
Loading…
Your answers are marked here and are not kept. An account keeps your marks.
People choose passwords that can be guessed
The keyspace of 8 lowercase letters is about 209 billion. That sounds large, but people do not pick at random. They pick words, names, teams and years, so a list of a few thousand common choices covers a large share of real accounts.
Four random words from a list of 7,776 give a far bigger keyspace than 8 mixed symbols. They are easier to remember, too.
The start of the word list
docker exec john head -3 words.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Count the keyspace of five shapes
docker exec john python3 steps/guesses.py 1000000000Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Worked example: what guesses.py printed
| Shape | Keyspace |
|---|---|
| 8 lowercase letters | 208,827,064,576 |
| 8 letters, digits and symbols | 6,634,204,312,890,625 |
| 4 words from a 7,776-word list | 3,656,158,440,062,976 |
| 3 words from a 7,776-word list | 470,184,984,576 |
| This lab's word list | 97 words |
| 8 lowercase at a billion guesses a second | 208 seconds at most |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think a capital letter and a symbol make a password strong. They only help if the password is random. Liverpool1 and P@ssw0rd follow patterns every cracking tool tries first, so length and randomness matter far more than the mix.
Check
Have a go
Check
3 questionsTry it: keyspaces
# How many passwords of each shape are there?
letters = 26 ** 8
mixed = 95 ** 8
words = 7776 ** 4
print("8 lowercase:", letters)
print("8 of 95 symbols:", mixed)
print("4 random words:", words)
# Add a line for 15 lowercase letters, then press Run.
Make a free account to save your work and track your progress.
A stolen table gives away reuse
The lab stores six made-up accounts' passwords three ways. fast.txt is unsalted SHA-256: two accounts with one password have one hash, so the table shows the reuse before any guess.
shadow.txt is SHA-512 crypt, the scheme Linux used for years. Each line holds the scheme, a salt and the hash, so equal passwords look different. Running the same scheme with the same salt makes the same line again.
Read the unsalted table
docker exec john cat hashes/fast.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Read two salted lines
docker exec john head -2 hashes/shadow.txtShown here, not run. Press Start lab to type it into your own lab’s terminal.
Make amira's salted line again
docker exec john openssl passwd -6 -salt Qm4tR8vLwZ2c sunshineShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsAssignment: a guess budget
Write three functions. keyspace(symbols, length) returns how many passwords of that length can be made from that many symbols. worst_seconds(space, rate) returns how many whole seconds it takes to try every password at rate guesses a second, rounded down. on_list(passwords, words) takes a dictionary from a name to a password and a list of lowercase words, and returns the names whose password, in lower case, is on the list, in the order the dictionary gives them.
def keyspace(symbols, length):
return 0
def worst_seconds(space, rate):
return 0
def on_list(passwords, words):
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go