bastion

Password and Credential Attacks

Build this skill

Compare brute force, dictionary attacks, credential stuffing and password spraying, and estimate how password length and character set change guessing time.

Four ways to get past a password without knowing it

Mrs. Lata Gokhale logs in to the Tulsi Health app every month to reorder her blood-pressure tablets. Her account shows her address, her prescriptions and her saved UPI ID. An attacker who wants that account has no need to break any encryption. It is far easier to get her password: by guessing it, by reusing one she leaked somewhere else, or by tricking or watching her into giving it away.

These are called credential attacks, where a credential is anything that proves who you are, most often a username and password pair. There are four main guessing styles and one family of stealing methods. Each works for a different reason, and each is stopped by a different defence, so it pays to tell them apart.

Brute force every combination, one door 0 0 0 2 0000 ✕ 0001 ✕ 0002 ✕ … 7351 ✓ 4 digits = 10,000 tries Dictionary likely choices first Common passwords password ✕ Pune@123 ✕ india2024 ✕ qwerty ✕ Tulsi@123 ✓ people choose alike Credential stuffing a leaked pair, new doors Leaked from a shop site lata.g : Gokhale72 ravi.k : ravi@99 … 50,000 more ✓ ✕ ✕ App Mail Bank one password, many sites Password spraying one guess, every account 1234✕ 1234✕ 1234✕ 1234✕ 1234✕ 1234✕ 1234✕ 1234✓ open 1234✕ one try per locker, so no lockout trips gym lockers, one PIN

Brute force tries everything on one door, a dictionary attack tries likely choices first, credential stuffing reuses a leaked pair on new doors, and spraying tries one common guess on every door.

Brute force: try every combination

A three-digit lock on a college bag has 1,000 possible settings, from 000 to 999. A patient person can try them all in an evening. Trying every possible combination until one works is called a brute-force attack, and against computers it is done by software that can make millions or billions of guesses.

The number of combinations depends on two things: how many symbols each position can take (the character set) and how many positions there are (the length). The count is the character-set size multiplied by itself once for each position. Ten digits over four positions give \(10^4 = 10{,}000\) PINs. Twenty-six lowercase letters over eight positions give \(26^8\), about 209 billion. On average an attacker finds the answer halfway through, so the expected time is half the combinations divided by the guessing speed.

Speed depends on where the guessing happens. Guessing online means typing guesses into the real login screen, where Tulsi Health's app can slow attackers down with account lockout: after five wrong tries the account freezes for fifteen minutes, which limits an attacker to about 20 guesses an hour. Guessing offline happens when attackers have stolen the company's stored password records, which are kept as scrambled fingerprints rather than plain passwords. They can test guesses against those fingerprints on their own computers with no lockout at all, at billions of guesses a second for a badly chosen scrambling method. Defenders plan for the offline case, because it is the worst one.

The optional cell below does this arithmetic for four password shapes, assuming a stolen copy and ten billion guesses a second. You can press Run without knowing any Python. Before you do, predict which lasts longer: eight characters using every key on the keyboard, or twelve plain lowercase letters. Afterwards, change the length of the twelve-letter password, marked with a comment, and watch how quickly the days grow.

python · runs in your browser

Expected output:

text
8 characters, any keyboard key: 6,095,689,385,410,816 combinations, about 4 days offline
12 lowercase letters: 95,428,956,661,682,176 combinations, about 55 days offline
16 lowercase letters: 43,608,742,899,428,874,059,776 combinations, about 25,236,541 days offline
5 random words from 7,776: 28,430,288,029,929,701,376 combinations, about 16,453 days offline
Line What it does
guesses_per_second = 10000000000 The attacker's speed: ten billion guesses a second against a stolen copy
shapes = [...] Four kinds of password. Each line holds a description, how many symbols each position can take, and how many positions there are
for name, symbols, length in shapes: Repeats the three indented lines once for each shape
symbols ** length ** means "to the power of": the number of symbols multiplied by itself once for each position
/ 2 / guesses_per_second / 86400 Takes half the combinations (the average), divides by the speed to get seconds, then by 86,400, the seconds in a day
print(...) Shows each count with commas and the days rounded to a whole number

Twelve lowercase letters (about 55 days) beat eight characters drawn from the whole keyboard (about 4 days), because each extra position multiplies the work by the full character-set size; sixteen lowercase letters take about 25 million days, roughly 69,000 years. Five random words chosen from a 7,776-word list take about 16,000 days, around 45 years, and they are far easier to remember and type than a jumble of symbols. On the real login screen, lockout changes the picture: at 20 guesses an hour, even a four-digit PIN takes about 10 days on average (5,000 guesses at 20 an hour is 250 hours), while offline the same PIN falls instantly.

4-digit PIN10,000 · instant8 lowercase209 billion · 10 seconds8 any keyboard key6.1 × 10¹⁵ · 4 days12 lowercase9.5 × 10¹⁶ · 55 days16 lowercase4.4 × 10²² · 69,141 yearsBar length = digits in the number of combinations. Each extra digit is ten timesmore guessing.

Length wins. Adding symbols to an eight-character password helps far less than adding four or eight more plain letters.

Dictionary attacks: try what people actually choose

Real people do not pick passwords at random. They choose words, names, cricketers, cities and years, then make the same small tweaks: a capital first letter, @ for a, 123 or the current year at the end. A dictionary attack tries a list of such likely passwords first, ordered from most to least common. A password like Pune@2024 looks strong because it has a capital, a symbol and digits, but it sits near the top of every such list and falls within seconds.

The defence is unpredictability, not decoration. A password that no list would contain, such as several unrelated random words, is safe from a dictionary attack because the dictionary has to fall back to brute force. Good systems also check every new password against lists of commonly used and previously leaked passwords, and refuse the ones they find.

Credential stuffing: one leak, many doors

Using the same key for your house, your office cupboard and your cycle lock is convenient until you lose it once. Then every lock it fits is open. Passwords reused across websites behave the same way. When a shopping site is breached and its customers' emails and passwords are published, attackers feed those pairs automatically into other sites' login pages. This is credential stuffing, and it works whenever the same person used the same password in both places.

Suppose Mrs. Gokhale used Gokhale72 on a small shopping website that was breached last year. Nobody needs to guess anything; the pair simply works on the Tulsi Health app. Lockout does not help either, because the attacker is right on the first try. The defences are a unique password for every site (a password manager, an app that creates and remembers them, makes this practical), a second login step such as a one-time code, and alerts when one place suddenly attempts thousands of logins.

Password spraying: one guess, many accounts

Picture a gym with 200 lockers, each with a four-digit lock. A thief who tries 1234 on every locker, once each, will probably open a few, and no locker sees more than one wrong attempt. Password spraying works the same way: the attacker tries one or two very common passwords, such as Tulsi@123 or Welcome@1, against every account in an organisation, staying below the lockout limit on each one.

Spraying is aimed at workplaces, where 130 staff accounts follow one email pattern and new joiners are often given a predictable first password. The tell-tale sign is many accounts each failing once, all from the same few places within a short time. Defences are banning common passwords, forcing a change of the first password, a second login step, and monitoring that looks at failures across all accounts rather than one at a time.

Brute forceGuesses: every combinationAccounts: usually oneStopped by: length, lockoutDictionaryGuesses: likely words + tweaksAccounts: one or a fewStopped by: random, banned listsCredential stuffingGuesses: pairs leaked elsewhereAccounts: thousandsStopped by: unique passwords, 2FAPassword sprayingGuesses: one common passwordAccounts: every account, onceStopped by: banned lists, 2FA

The attacks differ in what is guessed and how many accounts are tried. A second login step (2FA) appears under three of them because it makes a correct password not enough on its own.

Stealing instead of guessing

The fifth route skips guessing entirely. Credential theft means obtaining the real password directly: a fake login page reached from a phishing message, hidden software that records keystrokes, a password on a sticky note under the counter laptop, someone watching over a shoulder as it is typed, or a browser's saved passwords copied from an unlocked computer. A long, random password is no protection against theft, because the attacker receives the exact answer.

That is why the strongest single defence against all five routes is two-factor authentication (2FA): a second proof, such as a code sent to a phone or an approval in an app, that is required along with the password. A stolen or guessed password alone is then not enough to log in. Tulsi Health turned it on for every staff email account after Neha noticed a wave of failed logins from abroad.

Try the guessing arithmetic yourself below. Change the length, the character set and where the guessing happens, and complete the mission Neha set for customer passwords.

Now sort real attack descriptions by type. Each card below describes what Neha might see in Tulsi Health's login records; put it in the bucket of the attack that produces that pattern.

Follow your curiosity.

↑ ↓ to explore · Enter to open · Escape to close