Hashcat and John the Ripper are the two most powerful password cracking tools used in penetration testing and CTF challenges. Hashcat is GPU-accelerated for maximum speed, while John the Ripper is versatile and excellent for quick command-line cracking. This guide covers hash identification, wordlist attacks, rule-based attacks, mask attacks, and hybrid cracking strategies for both tools.
Hash Identification
Before cracking, identify the hash type. Use hashid or hashcat’s example hashes page to determine the mode number needed.
# Identify hash type
hashid '$2y$10$...' # bcrypt
hashid '5d41402abc4b2a76b9719d911017c592' # MD5
# Common hash formats
# MD5: 32 hex chars hashcat -m 0
# SHA1: 40 hex chars hashcat -m 100
# SHA256: 64 hex chars hashcat -m 1400
# bcrypt: $2a$... or $2y$... hashcat -m 3200
# NTLM: 32 hex chars (Windows) hashcat -m 1000
# NTLMv2: starts with user:: hashcat -m 5600
# Kerberos TGS (Kerberoast): $krb5tgs$23$* hashcat -m 13100
# AS-REP: $krb5asrep$23$* hashcat -m 18200Hashcat Attack Modes
# Wordlist attack (-a 0)
hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt
# Wordlist + rules (-a 0 with -r)
hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule
hashcat -m 1000 ntlm_hashes.txt rockyou.txt -r rules/d3ad0ne.rule
# Brute-force mask attack (-a 3)
hashcat -m 0 hash.txt '?u?l?l?l?d?d?d' # e.g. Abcd123
hashcat -m 0 hash.txt '?a?a?a?a?a?a?a?a' # 8 chars all
# ?l=lowercase ?u=uppercase ?d=digit ?s=special ?a=all
# Hybrid: wordlist + mask (-a 6)
hashcat -m 0 hash.txt rockyou.txt '?d?d?d'
# Combination attack (-a 1)
hashcat -m 0 hash.txt wordlist1.txt wordlist2.txt
# Show cracked results
hashcat -m 0 hashes.txt --showJohn the Ripper
# Auto-detect format and crack
john hashes.txt
john hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt
# Specify hash format
john --format=NT hashes.txt --wordlist=rockyou.txt
john --format=sha512crypt shadow.txt --wordlist=rockyou.txt
# Extract hashes from files
pdf2john document.pdf > pdf_hash.txt
zip2john archive.zip > zip_hash.txt
ssh2john id_rsa > ssh_hash.txt
7z2john archive.7z > 7z_hash.txt
# Then crack
john pdf_hash.txt --wordlist=rockyou.txt
# Show cracked passwords
john --show hashes.txtCracking Strategy: Methodology
Start with the fastest techniques and move to slower ones: 1) Quick rockyou.txt wordlist, 2) rockyou with best64 rules, 3) Mask attack for known password patterns, 4) Targeted wordlists based on company/username, 5) PRINCE attack or combination.
References
See Hashcat Wiki and MITRE ATT&CK T1110.002 (Password Cracking).