𓂀
𓋹

PASSWORD CRACKING SIMULATION

Lesson 2 of 5
~7 hrs
WARMUP: Guess the Password Game

Think of a 4-digit PIN. How many guesses would it take someone to crack it if they started at 0000 and tried every combination? That's 10,000 possibilities — but a computer can test them in milliseconds!

4 digits = 104 = 10,000 combinations

CORE CONCEPTS

A brute force attack tries every possible combination until it finds the right one. Python is perfect for automating this.

def brute_force_pin(target): for i in range(10000): attempt = str(i).zfill(4) if attempt == target: return f"Cracked! PIN is {attempt}" return "Not found" print(brute_force_pin("5732"))

A dictionary attack uses a list of common passwords instead of trying every combination — much faster!

# Dictionary attack simulation common_passwords = ["123456", "password", "qwerty", "letmein", "admin"] def dict_attack(target): for pwd in common_passwords: if pwd == target: return f"Found: {pwd}" return "Not in dictionary"

That's why you should NEVER use common passwords!

Password entropy measures how unpredictable a password is. Higher entropy = harder to crack.

def calc_entropy(length, charset_size): return length * (charset_size ** 0.5) # Compare: # "cat" = 3 lowercase letters (26^3 = 17,576 combos) # "C@t" = mixed case + symbols (94^3 = 830,584 combos) print("Simple:", calc_entropy(3, 26)) print("Complex:", calc_entropy(3, 94))
MINI CHALLENGE: Crack the 3-Digit PIN

How fast can your Python script find a 3-digit PIN? Only 1,000 combinations to check!

# Your mission: write a brute-force function # that finds any 3-digit PIN (000-999) # Time yourself — can you do it under 1 second?
Extension: Add a counter to show how many attempts it took.
MAIN PROJECT: Password Strength Checker

Build a Python algorithm that evaluates password strength based on length, character variety, and common patterns.

1

Check password length (min 8, ideal 12+)

2

Detect uppercase, lowercase, numbers, symbols

3

Check against a list of common passwords

4

Output: Weak / Moderate / Strong rating

QUIZ: Password Security

Test your knowledge of password cracking and defense.

1. What attack tries every possible combination?

Brute force
Dictionary attack
Phishing

2. Which password has the highest entropy?

abc123
password
k#7G!pQ9

3. What is the main advantage of a dictionary attack over brute force?

It's more accurate
It's much faster
It works offline