learning-it by example

#282 How it works, by example 6.4 min

5 Password Attacks and the Defence for Each

Brute force: 6 of 6 guesses through, then 2 of 6 once the lockout was on.

1. In a toy Python login, six brute-force guesses came one second apart from six different addresses against one account, with a lockout that doubles each time. How many reached the password check with the defence on?
2. Why does a per-account lockout fail to stop a password spray from one address?
3. With the per-address counter on, what did the spray of one password against 3 accounts give in the password attacks demo?
4. Why does giving every user a different salt help when an attacker steals the password table and runs a wordlist?
5. In a toy login brute-force demo, a doubling lockout let 2 of 6 guesses through. What caveat is stated about that result?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. Spread out the brute force

    Copy the code folder first. In attacks.py, in the brute_force function, change site.clock.tick(1) to site.clock.tick(60), then run python run.py. Predict how many of the 6 guesses reach the password check with the lockout on. You should see 6 of 6, so the lockout only helps when guesses come quickly.

    A hint

    A lockout is a time in seconds. Compare it with the gap between guesses.

  2. Move the weak account first

    In server.py reorder USERS so that chloe comes first, then amina, then ben. Run python run.py and look at the spray in section 4. Predict the result with the per-address counter on. You should see ['ok', 'wrong', 'wrong'] even with the defence on, because the weak account is tried before the counter blocks anything. Put USERS back in the original order afterwards, because the next exercise quotes results for the original order.

    A hint

    The spray tries the accounts in the order they appear in the store.

  3. Change the address limit

    In login.py change IP_LIMIT from 2 to 1, and run python run.py. Predict the spray result with the defence on. Then change it to 3 and predict again. You should see ['wrong', 'ip blocked', 'ip blocked'] for 1 and ['wrong', 'wrong', 'ok'] for 3. Which value is a better defence, and what does a very low limit do to honest users?

    A hint

    The limit is how many failures one address may have before it is blocked.

  4. Put the strong password on the wordlist

    In attacks.py add the text river-copper-29 to the end of WORDLIST, then run python run.py. Predict the list of cracked accounts and the count of slow hashes. You should see all three accounts cracked using 15 slow hashes. The printed message still says amina is not found, because that text is fixed in run.py. Fix it so it prints the real result.

    A hint

    The video says a strong password is simply not in the list, so this exercise shows what changes when it is.

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

Every user, password and list is a made-up toy for defence teaching; thresholds and hash cost are toy values, far below real guidance.

Up next in How it works, by example

More in How it works, by example

All How it works, by example videos

Related videos