Password Cracking Workshop


A 2-Hour Hands-On Introduction to Offline Password Recovery

A 2-hour hands-on workshop covering the full pipeline: background and theory, installing tools, cracking hashes with dictionary attacks, masks, rules, and gathering hashes from real systems.

Disclaimer

The content of this workshop is for educational use only. I do not condone the use of this information for illegal or unethical purposes. Use it only with explicit permission from the owner of the data. Don’t be a Script Kiddie.


What You Need

  • A Linux machine (Kali, Ubuntu, or any Debian-based distro recommended)
  • hashcat and john (installed during the workshop)
  • rockyou.txt (usually at /usr/share/wordlists/rockyou.txt on Kali)
  • A terminal

Part 1 — Background and History [0:00 – 0:20]

Where This All Started

Password cracking has been around as long as password hashing. Early Unix systems in the 1970s stored passwords as DES-based crypt hashes — at the time, this was considered sufficient. As computing power grew, so did the ability to crack those hashes. By the 1990s, Windows systems were shipping with LAN Manager (LM) hashes, a notoriously weak scheme that split passwords into two 7-character chunks — making a 14-character password no harder to crack than two 7-character ones. Tools like L0phtCrack (1997) made LM cracking trivial.

The watershed moment for modern password cracking is the 2009 RockYou breach. RockYou, a social media app company, stored 32 million user passwords in plaintext. When attackers exfiltrated the database, the security community got an unprecedented look at how real people actually choose passwords:

  • 123456
  • password
  • iloveyou
  • sunshine
  • Names, birthdays, sports teams

That dump became rockyou.txt — the wordlist we use to this day. It is devastatingly effective precisely because it reflects real human behavior.

Today, major breaches happen constantly. HaveIBeenPwned.com tracks billions of compromised credentials. The passwords in those breaches end up in wordlists, which makes weak passwords weaker over time.

How Passwords Are Stored

When you log into a website, your password is almost never stored directly. Instead, it goes through a hash function — a one-way mathematical operation that turns your password into a fixed-length string called a digest.

"hunter2"  →  MD5  →  2ab96390c7dbe3439de74d0c9b0b1767
"hunter2"  →  SHA1 →  f3bbbd66a63d4bf1747940578ec3d0103530e21d
"hunter2"  →  SHA256 → f52fbd32b2b3b86ff88ef6c490628285f482af15ddcb29541f94bcf526a3f6c7

Key properties:

  • Deterministic — the same input always gives the same output
  • One-way — you cannot reverse a hash to get the original password
  • Avalanche effect — changing one character changes the entire hash

Since hashes can’t be reversed, we crack them by working forward: hash a candidate password, compare the result to the target hash, repeat.

rockyou.txt line: "hunter2"
        ↓
    MD5 hash: 2ab96390c7dbe3439de74d0c9b0b1767
        ↓
  Does it match our target hash?  → YES → Password found!
                                  → NO  → Try next word

Salting — Why Stolen Hashes Aren’t Instant Access

Modern systems add a random salt — a unique string appended to each password before hashing. The same password produces a different hash for every user:

"password" + salt "x9aB"  →  $6$x9aB$<long hash>
"password" + salt "mQ2k"  →  $6$mQ2k$<different long hash>

This defeats precomputed attack tables (rainbow tables) and means each hash must be cracked individually. Older or misconfigured systems often skip salting — which is why old MD5 and NTLM databases crack so quickly.

The Defender’s Goal

The goal is not to make cracking impossible. It’s to make cracking computationally impractical.

If cracking your password would take longer than the heat death of the universe, it doesn’t matter that it’s theoretically possible. Strong, long, unique passwords with proper hashing algorithms buy that time.


Part 2 — Setup [0:20 – 0:35]

Install Hashcat

Hashcat is the industry-standard GPU-accelerated password cracker supporting 300+ hash types.

# Debian / Ubuntu / Kali
sudo apt install hashcat

# Arch
sudo pacman -S hashcat

# macOS
brew install hashcat

# Verify
hashcat --version

Install John the Ripper (Jumbo Edition)

John the Ripper (JtR) is another major cracker with strong auto-detection and single-crack mode. Install the Jumbo fork for full feature support including the mask attack.

# Debian / Ubuntu / Kali
sudo apt install john

# Arch
sudo pacman -S john

# macOS
brew install john

# Verify
john --version

Get rockyou.txt

On Kali Linux it’s already included:

ls /usr/share/wordlists/
# You should see rockyou.txt.gz — unzip it if needed:
sudo gzip -d /usr/share/wordlists/rockyou.txt.gz

On other systems, download it:

wget https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt

Check it:

wc -l rockyou.txt     # Should show ~14.3 million lines
head -20 rockyou.txt  # Take a look at the top passwords

Create a Workshop Directory

mkdir ~/pcworkshop && cd ~/pcworkshop

Part 3 — Hash Identification [0:35 – 0:45]

Before you can crack a hash you have to know what kind it is. Hash length is often the first clue:

Length (chars) Common Algorithm
32 MD5
40 SHA1
56 SHA224
64 SHA256
96 SHA384
128 SHA512
32 (uppercase) NTLM

Hashcat uses hash modes (-m) to identify the algorithm. Key ones to memorize:

Mode Algorithm Example Hash
0 MD5 5f4dcc3b5aa765d61d8327deb882cf99
100 SHA1 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
1000 NTLM 8846F7EAEE8FB117AD06BDD830B7586C
1400 SHA256 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
1800 SHA512crypt ($6$) $6$52450745$k5ka2p8bFuSmoVT1tzOyyuaREkkKBcCNkRKfl.7.k/pjsA.TCFbFm3aLZVHt7K2.yQE8tVFnMk63X8UiZuBJr/
3200 bcrypt ($2*$) $2a$05$LhayLxezLhK1LhWvKxCyLOj0j1u.Kj0jZ0pEmm134uzrQlFvQJLF6

Try It: Generate Your Own Hashes

# MD5
echo -n "password" | md5sum

# SHA256
echo -n "password" | sha256sum

# SHA1
echo -n "password" | sha1sum

Compare your output to the table above. The lengths should match.

Online Identification

When you receive an unknown hash, paste it into hashes.com/en/tools/hash_identifier. It will give you a ranked list of likely algorithms.


Part 4 — Dictionary Attacks with rockyou [0:45 – 1:10]

Dictionary attacks are the fastest and most effective first move. You hash every line in a wordlist and compare it to your target.

Workshop Hashes — Set 1

Create this file:

cat > ~/pcworkshop/hashes1.txt << 'EOF'
5f4dcc3b5aa765d61d8327deb882cf99
e10adc3949ba59abbe56e057f20f883e
d8578edf8458ce06fbc5bb76a58c5ca4
25f9e794323b453885f5181f1b624d0b
0d107d09f5bbe40cade3de5c71e9e9b7
EOF

These are all MD5 hashes. Before running anything, make a prediction: what kind of passwords end up in rockyou?

Run the Dictionary Attack

hashcat -m 0 -a 0 ~/pcworkshop/hashes1.txt /usr/share/wordlists/rockyou.txt

Flag breakdown:

  • -m 0 — hash mode MD5
  • -a 0 — attack mode dictionary
  • hashes1.txt — your target hashes
  • rockyou.txt — the wordlist

View Results

hashcat -m 0 -a 0 ~/pcworkshop/hashes1.txt /usr/share/wordlists/rockyou.txt --show

You should see:

5f4dcc3b5aa765d61d8327deb882cf99:password
e10adc3949ba59abbe56e057f20f883e:123456
d8578edf8458ce06fbc5bb76a58c5ca4:qwerty
25f9e794323b453885f5181f1b624d0b:12345678
0d107d09f5bbe40cade3de5c71e9e9b7:letmein

All five in seconds. These are the top 5 passwords in rockyou.

John the Ripper — Same Attack

# Create a copy for John
cp ~/pcworkshop/hashes1.txt ~/pcworkshop/hashes1_john.txt

john --format=Raw-MD5 --wordlist=/usr/share/wordlists/rockyou.txt ~/pcworkshop/hashes1_john.txt

# Show results
john --show --format=Raw-MD5 ~/pcworkshop/hashes1_john.txt

John auto-detects many hash types, but it’s always safer to specify with --format to avoid guessing wrong.

Workshop Hashes — Set 2 (SHA256)

cat > ~/pcworkshop/hashes2.txt << 'EOF'
d5cec0a4dab34d51eaa57c97adf7a3262c43a2f1c17369ceb11b40e06714f087
f1da9421394e4892f3ed37287493ec319f321d23c1fa6c4dba10fbdda95186a3
becedec1e34ba27a9684af85e6e49c5e4e5124520b6ba059820f8b4bb60c328f
3684ef64d82e08cf5cac8c8a206498b67d12971a8721a5519a0e2c9d2f3ee151
d0a5e64798ce47fddd565cbe02e22ffeda835dd819b15528dd62e80e45328a75
EOF

These are SHA256. Note the length difference from Set 1. Use mode 1400:

hashcat -m 1400 -a 0 ~/pcworkshop/hashes2.txt /usr/share/wordlists/rockyou.txt
hashcat -m 1400 -a 0 ~/pcworkshop/hashes2.txt /usr/share/wordlists/rockyou.txt --show

Expected results:

d5cec0a4...:secureme123
f1da9421...:catlovermeme
becedec1...:securityadmin284650
3684ef64...:mypasswordistooshort
d0a5e647...:loveredbull

Notice that securityadmin284650 and mypasswordistooshort cracked from rockyou — real people used these passwords in real breaches.


Part 5 — Mask and Hybrid Attacks [1:10 – 1:35]

Dictionary attacks fail when the password is not in your wordlist. Masks let you describe the shape of a password rather than guessing individual words.

Mask Syntax

Hashcat mask characters:

Placeholder Charset
?l abcdefghijklmnopqrstuvwxyz
?u ABCDEFGHIJKLMNOPQRSTUVWXYZ
?d 0123456789
?s «space»!"#$%&'()*+,-./:;<=>?@[\]^_\{
?a ?l?u?d?s (all printable)
?h 0123456789abcdef
?H 0123456789ABCDEF

Workshop Hashes — Set 3 (Masks)

cat > ~/pcworkshop/hashes3.txt << 'EOF'
0a2b4ed7fecd8a31c7f2fa91da7d67a4
2a4f5b65b7aba3e97cd80e2ab73aeeb3
EOF

These are the MD5 hashes of hacker2002 and 9001hacker. The pattern is a known word with 4 digits either appended or prepended.

Mask Attack

# "hacker" followed by 4 digits
hashcat -m 0 -a 3 ~/pcworkshop/hashes3.txt "hacker?d?d?d?d"

# 4 digits followed by "hacker"
hashcat -m 0 -a 3 ~/pcworkshop/hashes3.txt "?d?d?d?dhacker"

Flag: -a 3 is brute force / mask mode.

In John

john --format=Raw-MD5 --mask="hacker?d?d?d?d" ~/pcworkshop/hashes3.txt
john --format=Raw-MD5 --mask="?d?d?d?dhacker" ~/pcworkshop/hashes3.txt
john --show --format=Raw-MD5 ~/pcworkshop/hashes3.txt

Hybrid Attacks — Dictionary + Mask

Hybrid attacks combine a wordlist and a mask. This is perfect for passwords like Summer2024! or fluffy2023.

Workshop hashes — Set 4:

cat > ~/pcworkshop/hashes4.txt << 'EOF'
1d06f250bea546b9862fab4751a6f056
12169d5a079252c9ba59973f163c4018
46eb1366c2330cf43708fac464ee621a
bbdc19c246e4af6b5de0398200f0b273
4c4f00ea90364c4b288090b1855de5f7
EOF

These hashes follow the pattern FirstName + 4-digit year. Create a names wordlist:

cat > ~/pcworkshop/names.txt << 'EOF'
Steve
Mary
Joseph
Susan
Tommy
Sarah
Alex
Emily
Frank
Ashley
EOF

Hybrid attack — mask after wordlist (-a 6):

hashcat -m 0 -a 6 ~/pcworkshop/hashes4.txt ~/pcworkshop/names.txt "?d?d?d?d"
hashcat -m 0 -a 6 ~/pcworkshop/hashes4.txt ~/pcworkshop/names.txt "?d?d?d?d" --show

Expected:

1d06f250...:Steve1951
12169d5a...:Mary1976
46eb1366...:Joseph1980
bbdc19c2...:Susan1907
4c4f00ea...:Ashley2008

For mask before wordlist (-a 7):

hashcat -m 0 -a 7 ~/pcworkshop/hashes_prepend.txt "?d?d?d?d" ~/pcworkshop/names.txt

Combinator Attacks

Combinator takes two wordlists and concatenates every permutation. Great for coloranimal or adjectivefood style passwords:

cat > ~/pcworkshop/colors.txt << 'EOF'
red
blue
green
orange
yellow
pink
indigo
white
EOF

cat > ~/pcworkshop/animals.txt << 'EOF'
dog
cat
fox
cow
frog
goose
pony
bison
squirrel
EOF

Workshop hashes — Set 5:

cat > ~/pcworkshop/hashes5.txt << 'EOF'
013c17dfad9f7825409dd056dcf5e23f
20f016fb1b49fc30be42b16681095894
92bd80147f593124b29284f5f86a1a33
3645dd1e88f1a094bac6d77e1ef78e98
b4bc74022136b55bc2292808cc262f1a
EOF
hashcat -m 0 -a 1 ~/pcworkshop/hashes5.txt ~/pcworkshop/colors.txt ~/pcworkshop/animals.txt
hashcat -m 0 -a 1 ~/pcworkshop/hashes5.txt ~/pcworkshop/colors.txt ~/pcworkshop/animals.txt --show

Expected: greencow, redgoose, pinksquirrel, bluedog, indigofrog


Part 6 — Rules [1:35 – 1:50]

Rules are transformation instructions applied to each word in a wordlist. Instead of storing every variation of a word, you describe the mutation pattern and let hashcat generate them on the fly.

Why Rules Matter

A password policy that requires at least one capital letter, one number, and one special character predictably results in passwords like:

  • Password1!
  • Summer2024!
  • Qwerty123#

Rules encode exactly these human habits.

Built-in Rules

Hashcat ships with several production-ready rule files:

ls /usr/share/hashcat/rules/

Key ones:

  • best64.rule — 64 common transformations, fast
  • rockyou-30000.rule — 30,000 rules derived from rockyou analysis
  • dive.rule — extremely thorough, slow

Common Rule Syntax

Rule Effect Example
l lowercase all Password → password
u uppercase all password → PASSWORD
c capitalize password → Password
r reverse password → drowssap
d duplicate password → passwordpassword
$X append X password → password1
^X prepend X password → 1password
sXY substitute X with Y password → p@ssword
{ rotate left password → asswordp

Rules can be chained:

  • c $1 $! → Password1!
  • sa@ se3 si1 so0 → p@ssw0rd (1337speak)

Apply Rules to rockyou

# Use best64 rules against our first hash set
hashcat -m 0 -a 0 ~/pcworkshop/hashes1.txt /usr/share/wordlists/rockyou.txt \
  -r /usr/share/hashcat/rules/best64.rule

# Stack multiple rules (both applied in sequence)
hashcat -m 0 -a 0 ~/pcworkshop/hashes1.txt /usr/share/wordlists/rockyou.txt \
  -r /usr/share/hashcat/rules/best64.rule \
  -r /usr/share/hashcat/rules/toggles1.rule

Write a Custom Rule

cat > ~/pcworkshop/workshop.rule << 'EOF'
:
c
$1
$!
c $1 $!
c $1 $2 $3
sa@ se3 si1 so0
c sa@ se3 si1 so0 $1 $!
EOF

Each line is a separate rule. : means “no change” (test the word as-is). Apply it:

hashcat -m 0 -a 0 ~/pcworkshop/hashes1.txt /usr/share/wordlists/rockyou.txt \
  -r ~/pcworkshop/workshop.rule

Part 7 — Gathering Hashes [1:50 – 2:05]

Cracking requires hashes. Here’s where they come from in authorized assessments and CTF scenarios.

Linux: /etc/shadow

Linux stores password hashes in /etc/shadow. Each line follows this format:

username:$algorithm$salt$hash:lastchanged:min:max:warn:inactive:expire:

Common algorithms:

  • $1$ — MD5crypt (legacy)
  • $5$ — SHA256crypt
  • $6$ — SHA512crypt
  • $y$ / $7$ — yescrypt (modern Kali default)

To read the shadow file you need root. On a machine you own for testing:

sudo cat /etc/shadow

Combining passwd and shadow with unshadow

John’s unshadow tool merges /etc/passwd and /etc/shadow into a format John can read directly:

sudo unshadow /etc/passwd /etc/shadow > ~/pcworkshop/combined.txt
john --wordlist=/usr/share/wordlists/rockyou.txt ~/pcworkshop/combined.txt
john --show ~/pcworkshop/combined.txt

For SHA512crypt ($6$) in hashcat, use mode 1800:

# Extract just the hash lines
sudo grep -v ':\*:' /etc/shadow | grep -v ':!:' > ~/pcworkshop/shadow_hashes.txt
hashcat -m 1800 -a 0 ~/pcworkshop/shadow_hashes.txt /usr/share/wordlists/rockyou.txt

Create a Test Hash

To practice without a real system:

# Generate a SHA512crypt hash of "testpassword"
openssl passwd -6 -salt "randomsalt" "testpassword"
# Output: $6$randomsalt$<hash>

# Put it in a file
echo '$6$randomsalt$<hash from above>' > ~/pcworkshop/test_shadow.txt
hashcat -m 1800 -a 0 ~/pcworkshop/test_shadow.txt /usr/share/wordlists/rockyou.txt

Windows: NTLM Hashes

Windows stores passwords as NTLM hashes in the SAM database. NTLM is MD4 of the UTF-16LE encoded password — fast to crack, no salt.

In authorized red team engagements, NTLM hashes come from:

  • PWDUMP output (offline SAM extraction)
  • Mimikatz (from memory on a live box)
  • Responder (from network captures)

A PWDUMP line looks like this:

username:RID:LM_hash:NTLM_hash:::

Example hashes from a test PWDUMP:

cat > ~/pcworkshop/ntlm.txt << 'EOF'
58a478135a93ac3bf058a5ea0e8fdb71
e6f80a6cbf0607a00ad93f85542c2802
a3a685f89364d4a5182b028fbe79ac38
EOF

Crack with hashcat mode 1000:

hashcat -m 1000 -a 0 ~/pcworkshop/ntlm.txt /usr/share/wordlists/rockyou.txt
hashcat -m 1000 -a 0 ~/pcworkshop/ntlm.txt /usr/share/wordlists/rockyou.txt --show

NTLM is unsalted and extremely fast to crack — a GPU can test billions of NTLM candidates per second. This is why you should never use weak Windows passwords.

Rainbow Tables: Ophcrack

For older Windows systems (XP, Vista, 7) using LM or NTLM hashes, rainbow tables offer a precomputed lookup approach. Ophcrack implements this.

sudo apt install ophcrack

Rainbow tables are precomputed hash chains — essentially a giant hash → password lookup table. They trade computation time for storage space. Download tables from ophcrack.sourceforge.io/tables.php.

Limitations:

  • Only works on unsalted hashes
  • Ineffective against modern systems (SHA512crypt, bcrypt, Argon2)
  • Requires large storage (gigabytes to terabytes)

Modern password storage uses salting specifically to defeat rainbow tables.

Generating Hashes for Practice

You can make your own practice targets at any time:

# MD5
echo -n "YourPassword" | md5sum | awk '{print $1}'

# SHA256
echo -n "YourPassword" | sha256sum | awk '{print $1}'

# SHA1
echo -n "YourPassword" | sha1sum | awk '{print $1}'

# NTLM (requires python3-impacket or similar)
python3 -c "import hashlib; print(hashlib.new('md4', 'YourPassword'.encode('utf-16le')).hexdigest())"

Part 8 — Final Challenge [2:05 – 2:15]

You’re a security consultant. A client has provided you with hashes extracted during a recent assessment. They don’t know what password policies were in place. Figure out the patterns and crack them all.

Challenge Hash File

cat > ~/pcworkshop/challenge.txt << 'EOF'
1d06f250bea546b9862fab4751a6f056
013c17dfad9f7825409dd056dcf5e23f
d5cec0a4dab34d51eaa57c97adf7a3262c43a2f1c17369ceb11b40e06714f087
0a2b4ed7fecd8a31c7f2fa91da7d67a4
bbdc19c246e4af6b5de0398200f0b273
EOF

These are a mix of MD5 and SHA256 from across the workshop. Different attack types are needed. Hints:

  • Not all hashes are the same algorithm — check the lengths
  • Some will crack with rockyou alone
  • Some need a mask or hybrid approach
  • Think about what patterns humans use

When you think you have them all, compare with the results from earlier in the workshop.


Wrap-Up and Takeaways [2:15 – 2:20]

What You Covered Today

  • How hash functions work and why they’re used for passwords
  • Dictionary attacks with rockyou against MD5, SHA1, SHA256
  • Mask attacks for patterned passwords (word + digits, digits + word)
  • Hybrid attacks combining wordlists with masks
  • Combinator attacks for concatenated-word passwords
  • Hashcat rules to apply human mutation patterns at scale
  • Extracting hashes from Linux /etc/shadow using unshadow
  • NTLM hashes from Windows environments
  • Rainbow tables and why salting defeats them

Key Lessons for Defenders

  • Short passwords with complexity are weak. P@ss1! has the same effective entropy as pass1 — the rules are predictable. Hashcat’s rule engine covers every common substitution.
  • Length is the strongest defense. A random 5-word passphrase (correct-horse-battery-staple) resists brute force far better than Tr0ub4dor&3.
  • Use a password manager. It generates truly random, unique passwords for every site. You only need to remember one strong master password.
  • Enable MFA everywhere. Even a cracked password is useless without the second factor.
  • Argon2, bcrypt, or scrypt — modern applications should use these intentionally slow algorithms. They add thousands of milliseconds per attempt, turning GPU crackers from a threat into a non-issue.

Further Learning

Topic Resource
Custom rules deep-dive hashcat wiki — Rule-based Attack
More wordlists weakpass.com — sorted by effectiveness
Real breach databases HaveIBeenPwned.com
NTLM in-depth harmj0y’s blog
Next course PC1510 – Intro to Hashcat

Questions? Find me on GitHub or after the workshop.


See also