Protego field desk

Authentication, Passwords and Privilege Escalation · PTES: Exploitation

L17. Password Attacks and Defenses

Explain online and offline password attacks, practice a wordlist crack against a sample hash you created, and apply modern password storage guidance.

Lesson 17 of 21 · About 35 minutes including the lab

By the end of this lesson you can

  • Contrast online guessing with offline hash cracking.
  • Generate and crack a sample MD5 hash with hashcat in your lab.
  • Apply NIST SP 800-63B length and blocklist guidance.
  • Recommend modern password storage (salted slow hashes or a password manager API).
Video transcript

A file of password hashes leaks. How fast can they be cracked? A password hash is a one way fingerprint. Attackers guess passwords and compare the hashes. Slow, salted hashing makes every guess expensive. Hashcat hashes each word in the list and compares it with the target hash. An unsalted MD5 hash of a common password falls almost instantly. Argon2id, bcrypt and scrypt are designed to make each guess slow and costly. Fast to compute, so fast to crack. Each guess costs time, and every user gets a unique salt. Crack only hashes you created, or that a lab gave you. Recommend multi factor authentication and rate limits. Check how the app stores passwords. Strong storage buys defenders time. Test yourself in the knowledge check.

Course outlineLesson 17 of 21

Lesson notes

Online attacks guess passwords against a live login form. They are noisy and should be rate-limited by the application. Offline attacks start from stolen password hashes and can try billions of guesses per second, so hash strength matters.

Never crack hashes obtained from unauthorized systems. In this lesson you create a sample hash yourself and crack that. On TryHackMe or Hack The Box you crack hashes the lab gives you.

MD5 and unsalted SHA-1 are obsolete for password storage. They are fine for teaching because they crack quickly. Real systems should use a slow, salted algorithm designed for passwords, such as Argon2id, bcrypt or scrypt, as described in the OWASP Password Storage Cheat Sheet.

NIST SP 800-63B-4 requires passwords used as a single factor to be at least 15 characters, allows shorter passwords (minimum eight) only when used as part of multi-factor authentication, forbids arbitrary composition rules (such as “must include a number and a symbol”), forbids periodic password changes without evidence of compromise, and requires screening against a blocklist of common and breached passwords.

For users, a password manager and MFA beat clever memorized passwords. For applications, prefer passkeys or a well-maintained authentication service over inventing your own.

Commands and expected output

Create a sample MD5 hash of a password you chose

echo -n 'password123' | md5sum

Output

482c811da5d5b4bc6d497ffa98491e38  -

Real output. echo -n avoids hashing a trailing newline. This is a sample you created; it is not a stolen hash.

Crack the sample hash with a tiny wordlist (hashcat mode 0 = MD5)

echo 482c811da5d5b4bc6d497ffa98491e38 > hash.txt
printf 'letmein\nqwerty\npassword123\n' > words.txt
hashcat -m 0 -a 0 hash.txt words.txt --potfile-disable --force

Output

482c811da5d5b4bc6d497ffa98491e38:password123
...
Status...........: Cracked

Real hashcat output (trimmed). Mode 0 is MD5; -a 0 is a straight wordlist attack. --potfile-disable keeps the result out of your default potfile. Use this pattern only on hashes you are authorized to crack.

Hands-on labs

Practice only on these legal targets: your own local lab or machines a platform assigns to you. Never use these techniques on systems you do not have written permission to test.

Practice task

Create a hash of a password only you know, crack it with a wordlist that contains it, and write three recommendations for a developer storing passwords, citing NIST SP 800-63B and OWASP.

Key takeaways

  • Online guessing hits a live login; offline cracking hits stolen hashes.
  • Practice cracking only on hashes you created or a lab gave you.
  • Store passwords with Argon2id/bcrypt/scrypt, never MD5 or unsalted SHA-1.
  • NIST SP 800-63B-4: prefer long passwords, blocklists, no arbitrary complexity rules, no periodic resets without cause.
Knowledge Check

1. What is the difference between an online and an offline password attack?

2. According to NIST SP 800-63B-4, what is the minimum length for a password used as a single-factor authenticator?

3. Which storage choice is appropriate for password hashes in a modern application?

4. You find a password hash on a system you are not authorized to test. What should you do?