Skip to content
Tutorials Center
My learning

Topics

Lesson 23 of 38 ยท Exploitation Concepts

Password Attacks and Credential Auditing

Learn how online guessing, spraying and offline hash cracking work, why salting and slow hashes matter, and how to audit credential strength safely and legally.

Passwords remain the most common way into a network. Weak, reused or default credentials appear in an enormous share of real breaches, so credential testing is a standard part of a penetration test. The goal is not to "crack as many as possible" but to show the client how easily their credentials could be abused and to measure how well their defenses (lockout, monitoring, hashing, multi-factor authentication) work.

You may only test credentials you are authorized to test, in the systems named in the scope. Never use passwords obtained from other breaches against accounts outside the engagement, and handle any password you recover as confidential data. The examples here use made-up users and hashes created inside the lesson.

Online versus offline attacks

Online attack Offline attack
Where Against a live login service On a copy of password hashes
Speed limit Server speed, lockouts, rate limits Hardware speed only
Visibility Leaves login failures in logs Silent once the hashes are stolen
Defense Lockout, throttling, MFA, monitoring Strong slow hashing, salts, long passwords

Three online techniques come up in test plans:

  • Brute force: try many passwords for one account. Easily stopped by lockout.
  • Dictionary attack: try likely passwords from a list (words, names, leaked favourites).
  • Password spraying: try one or two very common passwords against many accounts, staying under the lockout threshold. It is quiet per account but obvious as a pattern across accounts.
  • Credential stuffing: replay username and password pairs leaked elsewhere, relying on reuse.

Spray versus brute force

Brute force One account, many passwords
Spraying Many accounts, one password
Defense MFA, lockout, banned passwords

Different shapes in the logs need different alerts.

1 / 2

What the defender's logs look like

Defenders detect these attacks by shape. The stand-in below parses invented authentication log lines and flags both patterns. This is also a useful thing to show a client in the report: "here is what your SIEM should alert on".

Python Spot brute force and spraying in logs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first pattern is many failures on one account; the second is one source touching many accounts a single time. A lockout policy catches only the first, which is why spraying is popular and why multi-factor authentication and banned-password lists matter more than lockout alone.

Offline cracking and why hashing choices matter

Systems should store a hash of each password, never the password. If an attacker steals the hash table (from a database leak or an Active Directory copy), they can guess passwords offline by hashing candidates and comparing.

Two properties decide how fast that goes:

  1. Salt: a unique random value mixed into each hash. Without salts, identical passwords give identical hashes and one guess tests every user at once; precomputed tables work. With salts, each account must be attacked separately.
  2. Work factor: purpose-built password hashes (bcrypt, scrypt, Argon2, PBKDF2) are deliberately slow and memory-hungry. A fast hash like plain SHA-256 or MD5 lets hardware test billions of guesses per second.

In an authorized test you may be given hashes or capture them legitimately, then run a strength audit with a wordlist to see what share falls quickly. The demonstration below builds its own tiny database with a fast unsalted hash and a salted iterated one, then audits both with a small wordlist. It uses only the Python standard library, and the "slow" hash is a labelled stand-in loop (Pyodide has no PBKDF2).

Python Audit a toy password database

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Both databases lose the weak passwords (Summer2024, letmein), because no hash can save a password that is on every wordlist. But the strong random password survived both, the salted design made identical passwords look different and cost the attacker work per user, and a real slow hash multiplies that cost by many orders of magnitude. The report recommendation writes itself: long unique passwords or passphrases, a banned-password check, a slow salted hash and MFA.

Policy checks to include in a test

  • Default and shared credentials on devices, printers and admin panels.
  • Password reuse between privileged and ordinary accounts.
  • Password policy: minimum length of 12 to 14 or more beats forced complexity; forced rotation encourages predictable changes like Summer2024 becoming Autumn2024.
  • Lockout and throttling behaviour, tested gently on a test account.
  • Storage: where hashes live, who can read them and which algorithm is used.
  • MFA coverage, especially for VPN, email and admin portals.
Python Check candidate passwords against a policy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is password spraying?

    Spraying spreads attempts across accounts so no single account hits the lockout threshold.
  2. 2. Why do unique salts matter for stored password hashes?

    Salts stop precomputed tables and stop one guess from testing every user with the same password.
  3. 3. Which is the best hashing choice for storing passwords?

    Slow, memory-hard hashes make each guess expensive. Fast hashes let attackers test billions per second.
  4. 4. Which control reduces the damage of both spraying and stolen passwords the most?

    A stolen or guessed password is not enough when a second factor is required.
  5. 5. What is the correct handling of passwords you recover during an authorized test?

    Recovered credentials are sensitive client data. Mask them in reports and follow the engagement's retention rules.

Summary

  • Online attacks are limited by the service; offline attacks are limited only by hardware, so storage choices matter.
  • Brute force, spraying and stuffing leave different shapes in logs; detection should cover all of them.
  • Use unique salts and a slow password hash; length and banned-password lists beat complexity rules.
  • MFA is the strongest single mitigation; audit coverage as part of the test.
  • Only test what you are authorized to test, and protect recovered credentials.

Next: Social engineering assessments