Lab 11: Password Security
🎯 Objective
Understand password strength requirements, implement proper password hashing with salting, demonstrate how weak passwords are cracked using dictionary attacks, and learn about modern password security practices.
📚 Background
Passwords remain the primary authentication mechanism despite being inherently weak. The biggest problems: users choose weak passwords (dictionary words, personal info, short strings), reuse passwords across sites, and never change them. When databases are breached, plaintext or weakly-hashed passwords are immediately usable by attackers.
Password hashing transforms passwords before storage — ideally with purpose-built functions like bcrypt, scrypt, or argon2 that are computationally expensive by design. A bcrypt hash with work factor 12 takes ~250ms to compute — slow for one verification but makes brute-forcing 250ms per attempt, meaning 1 billion guesses would take 7 years on a single machine.
Password cracking tools like John the Ripper and Hashcat use wordlists (like rockyou.txt with 14 million real-world passwords), rules (l33t substitutions, appended numbers), and brute-force to crack hashes. Modern GPU rigs can test billions of MD5 hashes per second — making MD5 passwords essentially broken.
MFA (Multi-Factor Authentication) is the most effective defense against credential compromise. Even if a password is stolen, MFA (TOTP apps, hardware keys, push notifications) prevents login. Security keys (FIDO2/WebAuthn) are phishing-proof.
⏱️ Estimated Time
40 minutes
📋 Prerequisites
Lab 5 (Hashing) completed
Docker with
innozverse-cybersecimage
🛠️ Tools Used
john— John the Ripper password crackerhashcat— GPU-accelerated hash crackingopenssl passwd— Generate password hashespython3— Password analysis scripts
🔬 Lab Instructions
Step 1: Password Strength Analysis
📸 Verified Output:
💡 What this means: "correct-horse-battery-staple" (the famous XKCD password) scores STRONG despite missing uppercase/numbers/specials — because its LENGTH gives 176 bits of entropy. Entropy measures unpredictability. Each additional character multiplies the guessing difficulty. Long random passphrases beat short complex passwords.
Step 2: Generate Password Hashes
📸 Verified Output:
💡 What this means: The MD5 hash
482c811da5d5b4bc6d497ffa98491e38for "password123" is instantly recognizable in any online hash database. The$6$randomsalt$...format includes algorithm (6=SHA-512), salt, and hash — much better. Modern systems should use$y$(yescrypt) or$2b$(bcrypt) formats.
Step 3: John the Ripper — Dictionary Attack
📸 Verified Output:
💡 What this means: John cracked "password123" in milliseconds using the rockyou.txt wordlist. The rockyou.txt list contains 14+ million real passwords from a 2009 breach. "409600p/s" means 409,600 password attempts per second on CPU alone. GPU-accelerated hashcat does billions per second. This is why MD5 for passwords is completely broken.
Step 4: Hashcat — GPU Hash Cracking
📸 Verified Output:
💡 What this means: Hashcat found "password123" instantly. The different hash modes show why bcrypt (-m 3200) is important: bcrypt is intentionally designed to be slow — a GPU that cracks 10 billion MD5 hashes/second can only crack ~10,000 bcrypt hashes/second. That's a 1 million times speed reduction for attackers.
Step 5: Password Salting Deep Dive
📸 Verified Output:
💡 What this means: Three users with the same weak password produce three different hashes with salting. An attacker who steals the database must brute-force each hash individually — with a random unique salt, no precomputed rainbow table can help. This transforms a mass crack into millions of individual slow operations.
Step 6: Password Policy Implementation
📸 Verified Output:
💡 What this means: "correct-horse-battery-staple-2024" passes despite having only lowercase letters — because its length (36 chars) gives massive entropy. NIST's current recommendation (SP 800-63B) focuses on length over complexity: minimum 8 chars, allow all characters, check against known-breached password lists, but don't require complex rules that lead to predictable patterns.
Step 7: Password Manager Benefits
📸 Verified Output:
💡 What this means: These 20-character random passwords would take longer than the age of the universe to brute-force. Password managers are THE most important security improvement for most users — the Verizon DBIR consistently shows credentials as the #1 breach vector. Using a password manager eliminates credential stuffing vulnerability.
Step 8: Multi-Factor Authentication (MFA)
📸 Verified Output:
💡 What this means: TOTP (Time-based One-Time Password) generates codes based on a shared secret and the current time. The code changes every 30 seconds. Even if an attacker intercepts a code, it's invalid 30 seconds later. Google's internal switch to hardware security keys in 2017 resulted in ZERO successful phishing attacks on employees.
Step 9: Have I Been Pwned — Check Breach Exposure
📸 Verified Output:
💡 What this means: Troy Hunt's Have I Been Pwned (HIBP) service has 14+ billion compromised passwords. The k-anonymity API lets you check if your password is known without revealing the actual password — brilliant privacy-preserving design. NIST recommends checking passwords against known-breached lists during creation. Most password managers integrate HIBP checking.
Step 10: Building a Secure Authentication System
📸 Verified Output:
💡 What this means: A secure auth system has multiple layers: PBKDF2/bcrypt for slow hashing (defeats brute-force at the hash level), account lockout after N failures (defeats online brute-force), and rate limiting (defeats rapid attempts). In production, also add: MFA, device fingerprinting, login notifications, and impossible travel detection.
✅ Verification
📸 Verified Output:
🚨 Common Mistakes
Using MD5/SHA1 for passwords: These are general-purpose hash functions — too fast for password storage. Use bcrypt, argon2, or scrypt.
Not using unique salts: Without per-user salts, users with the same password get the same hash — rainbow tables crack them all at once.
No account lockout: Without lockout, attackers can try millions of passwords online. Even rate limiting (1 attempt/second) greatly reduces attack speed.
📝 Summary
Weak passwords (short, dictionary words, no complexity) are cracked in seconds with tools like John the Ripper and Hashcat using rockyou.txt wordlist
Always use purpose-built password hashing functions (bcrypt, argon2, scrypt) with unique random salts — never MD5 or SHA1 directly
MFA is the most effective defense against credential compromise — even stolen passwords are useless without the second factor
Password managers enable unique strong passwords per service, eliminating credential stuffing vulnerability
🔗 Further Reading
Last updated
