kavklaw@llm ~ /guides/john-hashcat

kavklaw@llm $ cat password-cracking-guide.md

John & Hashcat β€” Password Cracking

🟑 Intermediate

⏱️ 25 min read Β· From hash identification to GPU-accelerated cracking β€” break every password

  • John the Ripper β€” CPU-based cracker with excellent hash extraction utilities (*2john)
  • Hashcat β€” GPU-accelerated cracker, the fastest password cracking tool available
  • hashid β€” hash identification tool
  • A wordlist β€” rockyou.txt comes with Kali at /usr/share/wordlists/rockyou.txt (may need to gunzip it first)

Installation

Kali Linux: Both John and Hashcat come preinstalled. You're good to go.

Debian/Ubuntu:

sudo apt install john hashcat hashid
# rockyou.txt: download from https://github.com/brannondorsey/naive-hashcat/releases

GPU vs CPU: Hashcat shines on GPUs β€” a modern GPU cracks MD5 at ~50 billion hashes/sec vs ~50 million on CPU. If you're running in a VM without GPU passthrough, hashcat falls back to CPU mode (use --force to suppress warnings). In that case, John is often the better choice since it's built for CPU cracking. For serious GPU cracking, install hashcat on a bare-metal host or use cloud GPU instances.

⚑ Quick Start

Found a hash (a scrambled version of a password) and need to crack it NOW? Follow this quick flow. You first identify what type of hash it is, then try common passwords against it until you find a match:

# Step 1: Identify the hash
hashid 'e99a18c428cb38d5f260853678922e03'
# Output: [+] MD5

# Step 2: Try rockyou with hashcat (GPU-accelerated)
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt
# -m 0 = MD5 (see hash type table below)

# Or with John (auto-detects hash type)
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Step 3: If wordlist fails, try with rules
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule

# Step 4: Show cracked passwords
hashcat -m 0 hash.txt --show
john hash.txt --show

πŸ” How Password Hashing Works

Before cracking hashes, you need to understand what they are and why they exist.

A hash function is a one-way mathematical function that converts any input into a fixed-length output. The key properties are:

  • Deterministic: Same input always produces the same output
  • One-way: You can't reverse a hash back to the input
  • Fixed length: MD5 always outputs 32 hex characters, regardless of input length
  • Avalanche effect: A tiny change in input completely changes the output
echo -n "password"  β†’ 5f4dcc3b5aa765d61d8327deb882cf99
echo -n "password1" β†’ 7c6a180b36896a65c4c200547eae19c18
echo -n "Password"  β†’ dc647eb65e6711e155375218212b3964

Tiny changes β†’ completely different hashes. This is the avalanche effect in action.

Why Passwords Are Stored as Hashes

If a database stores passwords in plaintext and gets breached, every user's password is immediately exposed. By storing only the hash, a breach reveals hashes β€” which attackers must still crack. This buys time for users to change passwords and limits the damage. Even the system administrators can't see the actual passwords; they only compare hashes during login.

When websites store passwords, they (should) store the hash, not the plaintext. When you log in, they hash your input and compare it to the stored hash. If they match, you're in.

Password cracking works by hashing candidate passwords and comparing them to the target hash. If hash("password123") == target_hash, you've found the password. We can't reverse the hash, but we can try millions of candidates per second until we find a match.

Hash Speed: Why It Matters

Not all hash algorithms are created equal, and this directly affects your cracking strategy. "Fast" hashes like MD5 and SHA-1 were designed for data integrity (checksums on files), not password storage. A modern GPU can compute 54 billion MD5 hashes per second β€” meaning short or common passwords fall in seconds. This is why MD5 is terrible for passwords: it's too fast to crack.

"Slow" hashes like bcrypt, scrypt, and Argon2 were designed specifically for password storage. They intentionally waste CPU time with each computation β€” bcrypt achieves only about 30,000 hashes per second on the same GPU. A 6-character brute force that takes seconds for MD5 would take months for bcrypt. When you encounter bcrypt, don't waste time on brute force; use small, targeted wordlists.

Attack Types β€” Conceptual Overview

Before learning the specific tool commands, understand the three fundamental cracking strategies:

  • Wordlist (dictionary) attack: Try every word in a list of known passwords. Fast and effective because humans are predictable β€” "password123" and "letmein" appear in every breach. This is your starting point for every hash.
  • Rule-based attack: Take a wordlist and apply transformations β€” capitalize the first letter, append numbers, replace 'a' with '@'. This catches passwords like "Password1!" that aren't in the raw wordlist but follow common human patterns. Rules multiply your coverage without multiplying your wordlist size.
  • Brute force (mask) attack: Try every possible combination of characters for a given length. Guaranteed to find the password eventually, but the keyspace grows exponentially β€” 8 characters of all printable ASCII is 6.6 quadrillion combinations. Only practical for short passwords or when you know the pattern (e.g., 4-digit PINs).

Salting

A salt is random data added to the password before hashing. This means the same password produces different hashes for different users:

# Without salt:
hash("password") β†’ 5f4dcc3b... (same for ALL users with "password")

# With salt:
hash("password" + "x7k9m2") β†’ a1b2c3d4... (unique per user)
hash("password" + "q3r8t5") β†’ e5f6g7h8... (different salt = different hash)

Salting prevents:

  • Rainbow table attacks (pre-built lookup tables of hashβ†’password)
  • Detecting users with the same password
  • Pre-computed hash lookups

πŸ” Hash Identification

Before you can crack a hash, you need to know what type it is. Here are the tools and techniques:

hashid

# hashid identifies hash types from the format
hashid 'e99a18c428cb38d5f260853678922e03'
# [+] MD5
# [+] MD4
# [+] Double MD5

hashid '$2b$12$LJ3m4ys3kCfS5p3/q.z4j.z2nHhVwE1TcP5q'
# [+] bcrypt

hashid '5f4dcc3b5aa765d61d8327deb882cf99:salt123'
# [+] MD5 with salt

hash-identifier

# Interactive hash identification tool
hash-identifier
# Paste the hash, get possible types
# Less accurate than hashid but comes pre-installed on Kali

hashcat --identify (hashcat 6.2.6+)

# Let hashcat identify the hash
hashcat --identify hash.txt
# Shows possible hash modes and their -m numbers

Manual Identification by Format

Learn to recognize hash formats visually:

PatternTypeExample
32 hex charsMD5 or NTLMe99a18c428cb38d5f260853678922e03
40 hex charsSHA-1a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
64 hex charsSHA-2565e884898da28047151d0e56f8dc62927...
128 hex charsSHA-512ba3253876aed6bc22d4a6ff53d840...
Starts with $1$MD5crypt (Linux)$1$salt$BkGKhATF...
Starts with $2b$ / $2a$bcrypt$2b$12$LJ3m4ys3...
Starts with $5$SHA-256crypt (Linux)$5$rounds=5000$salt$hash...
Starts with $6$SHA-512crypt (Linux)$6$salt$hash...
Contains :: segmentsNetNTLMv2user::domain:challenge:hash:blob
$krb5asrep$Kerberos AS-REP$krb5asrep$23$user@domain:hash...
$krb5tgs$Kerberos TGS$krb5tgs$23$*user$domain$spn*$...
🧠 Knowledge Check β€” Hash Identification & Basics
You encounter this hash: $6$rounds=5000$salt$hashvalue.... What type of hash is this?
The $6$ prefix identifies SHA-512crypt, common on many Linux systems. Many modern distributions now default to yescrypt ($y$). $1$ = MD5crypt, $5$ = SHA-256crypt, $6$ = SHA-512crypt, $2b$ = bcrypt. The rounds=5000 specifies iteration count (making brute force slower). In hashcat, use -m 1800 for SHA-512crypt. These are found in /etc/shadow.
What makes a "salted" hash more resistant to cracking than an unsalted hash?
A salt is random data added to the password before hashing. Without salt, hash("password") is always the same β€” attackers can pre-compute billions of hashes once and look up any hash instantly (rainbow tables). With salt, hash("password" + "x7k9m") produces a unique result for each user. You must crack each hash individually, and rainbow tables become useless because every salt creates a different lookup table.
You found a password-protected SSH private key. What tool extracts the hash for cracking?
John's *2john utilities extract hashes from file formats into a crackable format. ssh2john extracts the passphrase hash from encrypted SSH keys. Other essential utilities: zip2john (ZIP files), pdf2john (PDFs), keepass2john (KeePass databases), office2john (Office documents). These are often the critical bridge between "found an encrypted file" and "cracked the password."

πŸ“‹ Common Hash Types

Here's a reference table of hash types you'll encounter most in CTFs and engagements:

Hash TypeHashcat Mode (-m)John FormatSpeedWhere Found
MD50raw-md5Very FastOld web apps, CTFs
SHA-1100raw-sha1Very FastGit, older apps
SHA-2561400raw-sha256FastModern apps, tokens
SHA-5121700raw-sha512FastModern apps
NTLM1000ntVery FastWindows SAM/AD
NetNTLMv25600netntlmv2FastResponder captures
bcrypt3200bcryptVery SlowModern web apps
MD5crypt500md5cryptSlowOld Linux /etc/shadow
SHA-512crypt1800sha512cryptVery SlowModern Linux /etc/shadow
Kerberos TGS13100krb5tgsSlowKerberoasting (extracting crackable hashes from Windows Active Directory)
AS-REP18200krb5asrepSlowAS-REP Roasting (similar to Kerberoasting, targets accounts without pre-authentication)
WPA/WPA222000wpapskVery SlowWiFi handshakes
MySQL 5.x300mysql-sha1Very FastMySQL databases
MSSQL 2012+1731mssql12FastSQL Server
πŸ’‘ Pro Tip: The full hashcat hash type list is at hashcat.net/wiki β€” Example Hashes. Bookmark it. It shows example hashes for every type, which helps with identification.

πŸ”¨ John the Ripper β€” Basics

John the Ripper is a versatile, CPU-based password cracker. It's great for auto-detecting hash types, cracking diverse formats, and working without a GPU.

# Basic usage β€” John auto-detects hash type
john hash.txt

# Specify wordlist
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Force a specific hash format
john hash.txt --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt

# Show cracked passwords
john hash.txt --show

# Show all supported formats
john --list=formats | tr ',' '\n'

# Show format details
john --list=format-details --format=raw-md5

John's Special Utilities

John comes with utilities to extract hashes from various file formats:

# Extract hash from password-protected ZIP
zip2john protected.zip > zip_hash.txt
john zip_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Extract hash from password-protected RAR
rar2john protected.rar > rar_hash.txt
john rar_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Extract hash from SSH private key (passphrase)
ssh2john id_rsa > ssh_hash.txt
john ssh_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Extract hash from KeePass database
keepass2john database.kdbx > keepass_hash.txt
john keepass_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Extract hash from PDF
pdf2john protected.pdf > pdf_hash.txt

# Extract hash from Office documents
office2john protected.docx > office_hash.txt

# Extract hash from 7-Zip
7z2john protected.7z > 7z_hash.txt

# Extract hash from /etc/shadow (combine with /etc/passwd first)
unshadow /etc/passwd /etc/shadow > combined.txt
john combined.txt --wordlist=/usr/share/wordlists/rockyou.txt
πŸ’‘ Pro Tip: John's *2john utilities are irreplaceable. Found a password-protected ZIP in a CTF? zip2john. Found an encrypted SSH key? ssh2john. These are often the critical step between "I found a file" and "I'm in."

John's Cracking Modes

# Single crack mode β€” uses info from the hash file (usernames, etc.)
john hash.txt --single

# Wordlist mode β€” dictionary attack
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Incremental mode β€” brute force all combinations
john hash.txt --incremental

# Incremental with character set
john hash.txt --incremental=digits  # Numbers only
john hash.txt --incremental=alpha   # Letters only

# External mode β€” custom cracking logic
john hash.txt --external=filter_name

⚑ Hashcat β€” Basics

Hashcat is the fastest password cracker around. It uses your GPU to try candidates in parallel β€” a single modern GPU can burn through billions of MD5 hashes per second.

# Basic usage
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt
# -m 0 = MD5 (hash mode number)

# Essential flags:
# -m    Hash mode (see table above)
# -a    Attack mode (0=wordlist, 1=combinator, 3=mask, 6=hybrid)
# -o    Output file for cracked hashes
# -r    Rules file
# --show  Display cracked passwords from potfile
# --force  Force run even with warnings (use on VMs)
# -w    Workload profile (1=low, 2=default, 3=high, 4=nightmare)

# Attack modes:
# -a 0  Straight/wordlist (default)
# -a 1  Combinator (word1 + word2)
# -a 3  Mask/brute force
# -a 6  Hybrid wordlist + mask
# -a 7  Hybrid mask + wordlist

# Show cracked passwords
hashcat -m 0 hash.txt --show

# Show status during cracking
# Press 's' while hashcat is running

# Restore interrupted session
hashcat --restore

# List all supported hash types
hashcat --help | grep -i "hash modes"

Hashcat Output Explained

# During cracking, hashcat shows:
Session..........: hashcat
Status...........: Running
Hash.Mode........: 0 (MD5)
Hash.Target......: hash.txt
Time.Started.....: Thu Jan 25 14:30:00 2024
Time.Estimated...: Thu Jan 25 14:32:00 2024
Kernel.Feature...: Pure Kernel
Guess.Base.......: File (/usr/share/wordlists/rockyou.txt)
Guess.Queue......: 1/1 (100.00%)
Speed.#1.........:  5234.2 MH/s (7.52ms) @ Accel:512 Loops:1
#               ↑ 5.2 BILLION MD5 hashes per second!
Recovered........: 0/1 (0.00%) Digests
Progress.........: 1044480/14344385 (7.28%)
Rejected.........: 0/1044480 (0.00%)
Restore.Point....: 1044480/14344385 (7.28%)

πŸ“– Wordlist Attacks

The most common attack type. Try every word in a dictionary. Most passwords in the real world can be cracked with a good wordlist.

# Basic wordlist attack β€” hashcat
hashcat -m 0 -a 0 hash.txt /usr/share/wordlists/rockyou.txt

# Basic wordlist attack β€” john
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Essential wordlists:
# rockyou.txt            β€” 14 million passwords (THE classic)
# /usr/share/seclists/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt
# /usr/share/seclists/Passwords/Leaked-Databases/
# /usr/share/seclists/Passwords/darkweb2017-top10000.txt

# Multiple wordlists β€” just run multiple sessions
hashcat -m 0 hash.txt wordlist1.txt
hashcat -m 0 hash.txt wordlist2.txt

# Or combine them
cat wordlist1.txt wordlist2.txt | sort -u > combined.txt
hashcat -m 0 hash.txt combined.txt

πŸ“ Rule-Based Attacks

Rules transform wordlist entries to match common password patterns. Instead of just trying "password", rules also try "Password", "password1", "p@ssword", "PASSWORD!", etc.

# Hashcat with rules
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule

# Popular rule files:
# best64.rule        β€” 64 rules, great speed/coverage balance
# rockyou-30000.rule β€” 30,000 rules, very thorough
# d3ad0ne.rule       β€” 34,000 rules, aggressive
# dive.rule          β€” 99,000 rules, exhaustive
# OneRuleToRuleThemAll.rule β€” community favorite, excellent coverage

# John with rules
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt --rules=best64

# John built-in rule sets
john hash.txt --wordlist=wordlist.txt --rules=Single    # Username mangling
john hash.txt --wordlist=wordlist.txt --rules=Wordlist  # Common transformations
john hash.txt --wordlist=wordlist.txt --rules=Extra     # More transformations
john hash.txt --wordlist=wordlist.txt --rules=Jumbo     # Everything

Understanding Rule Syntax

# Hashcat rule syntax (also used by john):
# l    = lowercase all
# u    = uppercase all
# c    = capitalize first letter
# t    = toggle case of all
# $X   = append character X
# ^X   = prepend character X
# r    = reverse
# d    = duplicate
# sXY  = replace X with Y

# Example rules for the word "password":
l          β†’ password        (lowercase)
u          β†’ PASSWORD        (uppercase)
c          β†’ Password        (capitalize)
$1         β†’ password1       (append 1)
$1$2$3     β†’ password123     (append 123)
^1         β†’ 1password       (prepend 1)
sa@        β†’ p@ssword        (replace a with @)
sa@ so0    β†’ p@ssw0rd        (leet speak)
c $!       β†’ Password!       (capitalize + append !)
d          β†’ passwordpassword (duplicate)

# Writing custom rules β€” create a file with one rule per line:
# my_rules.rule:
c $1
c $!
c $1$2$3
sa@ so0 si!
$2$0$2$4
$2$0$2$5
πŸ’‘ Pro Tip: Rules are multiplicative. A 14-million-word rockyou.txt with best64.rule (64 rules) generates 896 million candidates. With dive.rule (99,000 rules), that's 1.4 TRILLION candidates. Start with best64, then escalate to larger rule sets if needed.

🎭 Mask Attacks (Brute Force)

Mask attacks let you define patterns for brute force, which is way smarter than trying every possible combination. The syntax looks weird at first, but it's actually simple once you see the pattern: each ? followed by a letter represents one character position.

# Hashcat mask attack basics
hashcat -m 0 -a 3 hash.txt ?a?a?a?a?a?a
# ?a = all printable ASCII characters (95 chars)
# This tries all 6-character combinations

# Character sets:
# ?l = lowercase letters (a-z)                  26 chars
# ?u = uppercase letters (A-Z)                  26 chars
# ?d = digits (0-9)                             10 chars
# ?s = special characters (!@#$%^&*...)         33 chars
# ?a = all of the above                         95 chars
# ?b = all bytes (0x00-0xff)                    256 chars

# Smart masks based on common patterns:
# "Password1" pattern: Ulllllllld
hashcat -m 0 -a 3 hash.txt ?u?l?l?l?l?l?l?l?d

# "password123" pattern: lllllllllddd
hashcat -m 0 -a 3 hash.txt ?l?l?l?l?l?l?l?l?d?d?d

# "P@ssw0rd!" pattern with custom charsets
hashcat -m 0 -a 3 hash.txt -1 '?l?d?s' ?u?1?1?1?1?1?1?1
# -1 defines custom charset 1 as lowercase + digits + special

# 4-digit PIN
hashcat -m 0 -a 3 hash.txt ?d?d?d?d

# Incrementing length (try 1-8 characters)
hashcat -m 0 -a 3 hash.txt ?a?a?a?a?a?a?a?a --increment --increment-min 1

Mask Attack Math

# Understanding the keyspace:
# ?d?d?d?d     = 10^4      = 10,000 combinations
# ?l?l?l?l?l?l = 26^6      = 308 million combinations
# ?a?a?a?a?a?a = 95^6      = 735 billion combinations
# ?a?a?a?a?a?a?a?a = 95^8  = 6.6 quadrillion combinations

# At 5 billion MD5/sec (modern GPU):
# ?d?d?d?d?d?d     β†’ instant
# ?l?l?l?l?l?l     β†’ 0.06 seconds
# ?a?a?a?a?a?a     β†’ 2.5 minutes
# ?a?a?a?a?a?a?a   β†’ 3.9 hours
# ?a?a?a?a?a?a?a?a β†’ 15 days
# ?a?a?a?a?a?a?a?a?a β†’ 4 years

# For bcrypt at 30,000 hashes/sec:
# ?d?d?d?d?d?d     β†’ 33 seconds
# ?l?l?l?l?l?l     β†’ 2.8 hours
# ?a?a?a?a?a?a     β†’ 283 days
# ↑ Bcrypt was DESIGNED to be slow to crack

πŸ”— Combinator Attacks

Combinator attacks join words from two wordlists. Useful when passwords are two concatenated words like "soccerball" or "bluefish".

# Hashcat combinator attack
hashcat -m 0 -a 1 hash.txt wordlist1.txt wordlist2.txt
# Tries: word1_from_list1 + word1_from_list2
#        word1_from_list1 + word2_from_list2
#        word2_from_list1 + word1_from_list2
#        ... every combination

# Example: animals.txt + colors.txt
# bluecat, bluedog, redcat, reddog, ...

# Hybrid attack: wordlist + mask (append pattern)
hashcat -m 0 -a 6 hash.txt /usr/share/wordlists/rockyou.txt ?d?d?d
# Tries: password000, password001, ..., password999
#        admin000, admin001, ..., admin999
# ... for every word in the list

# Hybrid attack: mask + wordlist (prepend pattern)
hashcat -m 0 -a 7 hash.txt ?d?d?d /usr/share/wordlists/rockyou.txt
# Tries: 000password, 001password, ...

# John combinator (using rules)
# Create a rule that appends another word
john hash.txt --wordlist=wordlist.txt --rules='Az"[0-9][0-9]"'

βš–οΈ John vs Hashcat β€” When to Use Which

Use John the Ripper When:

  • You don't have a GPU β€” John works great on CPU
  • Auto-detecting hash types β€” John's detection is excellent
  • Extracting hashes from files β€” zip2john, ssh2john, pdf2john, etc.
  • Cracking Linux shadow hashes β€” John handles /etc/shadow natively
  • Mixed hash types β€” John can process a file with different hash types
  • Quick one-off cracks β€” Less configuration needed
  • On a VM without GPU passthrough β€” CPU-only environment

Use Hashcat When:

  • You have a GPU β€” Hashcat's GPU support is unmatched
  • Speed matters β€” GPU cracking is 10-100x faster
  • Mask attacks β€” Hashcat's mask syntax is more intuitive
  • Rule attacks at scale β€” GPU-accelerated rule processing
  • Large hash lists β€” Hashcat handles millions of hashes efficiently
  • Specific hash types β€” Hashcat supports 350+ types
  • Session management β€” Better pause/resume/restore

The Typical Workflow

# 1. Use John's *2john to extract hashes
ssh2john id_rsa > hash.txt

# 2. Identify with hashid or hashcat
hashid -m hash.txt  # -m shows hashcat mode number

# 3. Crack with hashcat (GPU) if available
hashcat -m MODE hash.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule

# 4. Fall back to John (CPU) if no GPU
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt --rules=best64

πŸ–₯️ GPU Cracking Setup

GPU cracking with hashcat requires proper driver setup. Here's how to get it working:

# Check your GPU
lspci | grep -i vga
nvidia-smi  # For NVIDIA GPUs

# Install NVIDIA drivers (Ubuntu/Kali)
sudo apt install nvidia-driver-535
# Reboot after installation

# Verify hashcat sees the GPU
hashcat -I
# Shows available devices (GPU, CPU)

# Benchmark your setup
hashcat -b
# Shows speed for every hash type on your hardware

# Sample benchmark output (RTX 3080):
# MD5          : 54000 MH/s (54 billion/sec)
# SHA-256      : 8000 MH/s
# NTLM         : 95000 MH/s
# bcrypt        : 30000 H/s   ← note: H/s not MH/s!
# SHA-512crypt  : 400000 H/s

# Workload profiles (-w)
# -w 1 = Low (desktop still usable)
# -w 2 = Default
# -w 3 = High (desktop may lag)
# -w 4 = Nightmare (desktop unusable, maximum speed)

# Using specific devices
hashcat -d 1 -m 0 hash.txt wordlist.txt    # GPU only
hashcat -d 1,2 -m 0 hash.txt wordlist.txt  # Multiple GPUs
⚠️ Important: If you're running Kali in a VM (VirtualBox/VMware), you won't have GPU access by default. You need PCI passthrough for GPU cracking in VMs. Alternatively, install hashcat on your Windows/Linux host with bare-metal GPU access, or use cloud GPU instances (AWS, Google Cloud).

πŸ“ Custom Wordlists with CeWL

Generic wordlists work for generic passwords, but targeted wordlists work for targeted passwords. CeWL builds custom wordlists from your target's website.

# Basic CeWL usage β€” spider the target website
cewl http://target.htb -d 3 -m 5 -w target_words.txt
# -d 3 = follow links 3 levels deep
# -m 5 = minimum word length 5
# -w   = output file

# Include email addresses
cewl http://target.htb -d 3 -m 5 -w words.txt -e --email_file emails.txt

# CeWL with authentication
cewl http://target.htb --auth_type basic --auth_user admin --auth_pass password123

# Generate username list from names found
cewl http://target.htb -d 2 -m 3 --lowercase -w names.txt

# Combine CeWL output with mutations
# Use hashcat rules on CeWL wordlist for maximum coverage
hashcat -m 0 hash.txt target_words.txt -r /usr/share/hashcat/rules/best64.rule

Other Custom Wordlist Tools

# CUPP β€” Common User Password Profiler
# Interactive tool that builds wordlists from personal info
cupp -i
# Asks for: name, birthdate, partner name, pet name, etc.
# Generates targeted password candidates

# Mentalist β€” GUI-based wordlist generator
# Visual rule creation and wordlist generation

# Crunch β€” generate wordlists by pattern
crunch 8 8 -t @@@@2024 -o wordlist.txt
# @ = lowercase letter
# Generates: aaaa2024, aaab2024, ..., zzzz2024
πŸ’‘ Pro Tip: In CTFs, passwords are often related to the box theme, company name, or characters in the story. A box called "Skynet" might use passwords like "skynet2024", "SkyNet!", or "t800judgment". Build a small custom wordlist with these words and mutate with rules.

🌈 Rainbow Tables

Rainbow tables are pre-computed hash-to-password lookup tables. Instead of hashing each candidate during cracking, you look up the hash in a table.

The concept is simple: pre-compute millions of hash→password mappings and store them in a table. When cracking, just look up the target hash → instant result.

Limitations:

  • Only works for unsalted hashes (salted hashes need unique tables)
  • Tables are HUGE (multiple TB for full coverage)
  • Limited by the character set and length used to generate them

Online rainbow table lookups: CrackStation, hashes.com, cmd5.org

# Generate your own with rtgen (rarely needed)
rtgen md5 loweralpha-numeric 1 8 0 1000 1000 0

In practice, modern GPUs are so fast that rainbow tables are rarely worth the storage space for common hash types. Just use hashcat.

🎯 Real-World Methodology

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             PASSWORD CRACKING DECISION FLOW               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                          β”‚
β”‚  Found a hash                                            β”‚
β”‚      β”‚                                                   β”‚
β”‚      β–Ό                                                   β”‚
β”‚  Identify type ──▢ hashid / hashcat --identify           β”‚
β”‚      β”‚                                                   β”‚
β”‚      β–Ό                                                   β”‚
β”‚  Online lookup ──▢ CrackStation / hashes.com (2 sec)     β”‚
β”‚      β”‚ miss                                              β”‚
β”‚      β–Ό                                                   β”‚
β”‚  rockyou.txt ────▢ hashcat -m MODE hash.txt rockyou.txt  β”‚
β”‚      β”‚ miss                                              β”‚
β”‚      β–Ό                                                   β”‚
β”‚  + Rules ────────▢ -r best64.rule β†’ -r rockyou-30000     β”‚
β”‚      β”‚ miss                                              β”‚
β”‚      β–Ό                                                   β”‚
β”‚  Custom wordlist β–Ά CeWL β†’ target-specific + rules        β”‚
β”‚      β”‚ miss                                              β”‚
β”‚      β–Ό                                                   β”‚
β”‚  Mask attack ────▢ ?u?l?l?l?l?l?d?d (common patterns)   β”‚
β”‚      β”‚ miss                                              β”‚
β”‚      β–Ό                                                   β”‚
β”‚  Hybrid attacks ─▢ wordlist + ?d?d?d (last resort)       β”‚
β”‚                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Here's a systematic approach to cracking any hash you encounter:

Step 1: Identify the Hash (30 seconds)

# Use multiple identification methods
hashid 'the_hash_value'
# Cross-reference with hashcat's example hashes page
# Look at the format (length, prefix, structure)

Step 2: Quick Wins (2 minutes)

# Check online databases first
# Paste hash into crackstation.net or hashes.com
# If it's a common password with a common hash, instant result

# Try rockyou.txt without rules
hashcat -m MODE hash.txt /usr/share/wordlists/rockyou.txt

Step 3: Wordlist + Rules (10-30 minutes)

# Escalate with rules
hashcat -m MODE hash.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule
hashcat -m MODE hash.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/rockyou-30000.rule

Step 4: Custom Wordlist (if you know the target)

# Build from the target
cewl http://target.htb -d 3 -m 5 -w custom.txt
hashcat -m MODE hash.txt custom.txt -r /usr/share/hashcat/rules/dive.rule

Step 5: Mask Attack (if you know the pattern)

# Common password patterns
hashcat -m MODE -a 3 hash.txt ?u?l?l?l?l?l?l?d?d      # Word + 2 digits
hashcat -m MODE -a 3 hash.txt ?u?l?l?l?l?l?l?d?d?d?s   # Word + 3 digits + special
hashcat -m MODE -a 3 hash.txt ?d?d?d?d?d?d              # 6-digit PIN

Step 6: Hybrid Attacks (last resort)

# Wordlist + numbers appended
hashcat -m MODE -a 6 hash.txt /usr/share/wordlists/rockyou.txt ?d?d?d
hashcat -m MODE -a 6 hash.txt /usr/share/wordlists/rockyou.txt ?d?d?d?d
hashcat -m MODE -a 6 hash.txt /usr/share/wordlists/rockyou.txt ?s

⚠️ Common Mistakes

❌ Mistake #1: Wrong hash mode in hashcat.
Using -m 0 (MD5) when the hash is actually NTLM (-m 1000) means hashcat will never crack it. Always identify the hash type first. If unsure, try multiple modes.
❌ Mistake #2: Not using rules.
A plain wordlist attack with rockyou.txt covers 14 million candidates. With best64.rule, you get 896 million. Rules are free performance β€” always use at least best64.rule.
❌ Mistake #3: Forgetting John's *2john utilities.
Found a password-protected file? Don't try to crack it directly. Extract the hash first with zip2john, ssh2john, pdf2john, etc. Then crack the extracted hash.
❌ Mistake #4: Brute forcing bcrypt.
bcrypt is intentionally slow (~30,000 H/s on a GPU vs 54 billion H/s for MD5). Brute force is not feasible for bcrypt. Use targeted wordlists with small rule sets. If it's not in rockyou with basic rules, you're probably not cracking it.
❌ Mistake #5: Not checking online databases first.
CrackStation and hashes.com have billions of pre-cracked hashes. A 2-second lookup might save you hours of GPU time. Always check online first for unsalted hashes.
❌ Mistake #6: Running hashcat in a VM without GPU passthrough.
Hashcat in a VM defaults to CPU mode, which is 100x slower than GPU. Either set up GPU passthrough, install hashcat on the host OS, or use cloud instances.
❌ Mistake #7: Not saving your potfile.
Hashcat saves cracked hashes to ~/.hashcat/hashcat.potfile. Don't delete it! If you encounter the same hash later, hashcat instantly returns the result from the potfile.

πŸ”„ Tool Comparison: John the Ripper vs Hashcat

πŸ”“ John the Ripper

GPU Support
5/10
Hash Types
9/10
Rule Engine
8/10
Speed
6/10
Platform
9/10
Ease of Use
9/10

Best for: Hash extraction (*2john tools are unmatched), auto-detection of hash types, CPU-only environments, and cracking exotic/mixed-format hash files.

⚑ Hashcat

GPU Support
10/10
Hash Types
10/10
Rule Engine
10/10
Speed
10/10
Platform
8/10
Ease of Use
6/10

Best for: Maximum cracking speed with GPU acceleration, mask attacks, session management for long-running cracks, and large-scale hash files.

πŸ“š Further Reading

πŸ† Section Assessment β€” Password Cracking Mastery
Complete this hashcat command to crack an MD5 hash using rockyou.txt with the best64 rule set:
-m 0 sets the hash mode to MD5. The wordlist path follows the hash file. -r specifies the rules file with its full path. Rules transform each wordlist entry β€” best64.rule applies 64 transformations per word (capitalize, append numbers, leet speak, etc.), turning 14 million candidates into 896 million. Always use at least best64 β€” it's free performance with minimal time cost.
Why is brute forcing bcrypt hashes generally impractical?
bcrypt was specifically designed to be slow. The work factor (cost parameter, typically 10-12) means each hash computation requires significant CPU time. At 30,000 hashes/second on a GPU (vs 54 billion/sec for MD5), a 6-character brute force that takes seconds for MD5 would take months for bcrypt. Targeted wordlist attacks with small rule sets are your best bet β€” if the password isn't in rockyou with basic rules, you likely won't crack it.
When should you use John the Ripper instead of Hashcat?
John's killer feature is the *2john family of hash extractors β€” no other tool does this as well. John also auto-detects hash types, handles mixed-format hash files, and works great on CPU. Use Hashcat when you have a GPU and need maximum speed, mask attacks, or session management for long-running cracks. The typical workflow: extract hashes with John's utilities, then crack with Hashcat on GPU.
You encounter the hash e99a18c428cb38d5f260853678922e03. Before firing up hashcat, what should you try first?
Online hash databases like CrackStation and hashes.com contain billions of pre-cracked hashes. A 2-second lookup might save hours of GPU time. This only works for unsalted hashes (MD5, SHA-1, NTLM), since salted hashes produce unique values. The hash e99a18c428cb38d5f260853678922e03 is MD5 of "abc123" β€” CrackStation would return this instantly.
What hashcat attack mode (-a) appends a mask pattern to every word in a wordlist? (e.g., testing "password000" through "password999")
-a 6 is the hybrid wordlist+mask mode. It appends the mask pattern to every word: hashcat -m 0 -a 6 hash.txt rockyou.txt ?d?d?d tries password000, password001, ..., admin000, admin001, etc. -a 7 does the reverse (mask + wordlist = prepends). -a 0 is plain wordlist, -a 1 combines two wordlists, and -a 3 is pure mask/brute force.