John the Ripper

The John the Ripper cheat sheet covers hash formats, attack modes (wordlist, incremental, mask, rules), *2john extraction tools, session management, performance tuning, and practical attack chains for Linux shadow, Windows/AD, and archive cracking.

#Quick Reference

#One-liner Workflow

# 1. Auto-detect format and crack with rockyou
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt

# 2. Auto-detect + rules in one shot
john --wordlist=/usr/share/wordlists/rockyou.txt --rules=Best64 hashes.txt

# 3. Show all cracked passwords
john --show hashes.txt

# Full pipeline: extract -> crack -> show
zip2john secret.zip > zip.hash && john --wordlist=/usr/share/wordlists/rockyou.txt zip.hash && john --show zip.hash

#Common Wordlist Paths

Distro / Location Path
Kali / Parrot rockyou /usr/share/wordlists/rockyou.txt
SecLists top passwords /usr/share/seclists/Passwords/
John built-in password.lst /usr/share/john/password.lst
John built-in (Kali) /usr/share/john/
CrackStation wordlist ~/wordlists/crackstation.txt
Weakpass mirror ~/wordlists/weakpass_3.txt

#Attack Mode Advisor

John the Ripper Attack Advisor

Answer each step to build the right john command for your situation.

#Hash Formats

#Unix / Linux

Format Flag Description Prefix
descrypt Traditional DES crypt 13-char
bsdicrypt BSDI extended DES _
md5crypt MD5 Unix (FreeBSD) $1$
bcrypt Blowfish (OpenBSD) $2a/b/y$
sha256crypt SHA-256 Unix $5$
sha512crypt SHA-512 Unix $6$
sunmd5 Solaris SunMD5 $md5
yescrypt yescrypt (modern) $y$
scrypt scrypt $7$

#Windows / Active Directory

Format Flag Description Example / Notes
NT NTLM (MD4) 32-char hex
LM LM hash (legacy) split halves
netntlm NTLMv1 C/R from Responder
netntlmv2 NTLMv2 C/R from Responder
mscash DCC (Domain Cache) M$user#hash
mscash2 DCC2 (Vista+) $DCC2$...
mschapv2 MS-CHAPv2 VPN/RADIUS
krb5asrep Kerberos AS-REP AS-REP Roasting
krb5tgs Kerberos TGS Kerberoasting
dpapi DPAPI masterkey Windows secrets

#Web / Database

Format Flag Description Notes
raw-md5 Plain MD5 hex string
raw-sha1 Plain SHA-1 hex string
raw-sha256 Plain SHA-256 hex string
raw-sha512 Plain SHA-512 hex string
raw-md4 Plain MD4 hex string
md5ns Netscreen MD5
mysql-sha1 MySQL 4.1+ double SHA-1
mssql MS SQL Server
mssql05 MS SQL 2005+
oracle11 Oracle 11g S:... prefix
oracle12c Oracle 12c+ PBKDF2
postgres PostgreSQL md5
phpass PHPass (WordPress) $P$ / $H$
phps PHPS $PHPS$
django Django PBKDF2
mediawiki MediaWiki MD5
ipb2 Invision PB 2

#Network / Protocols

Format Flag Description Notes
netlm LM C/R challenge/response
netlmv2 LMv2 C/R
nethalflm Half-LM C/R
mskrb5 MS Kerberos 5 AS-REQ pre-auth
krb4 Kerberos v4 TGT
krb5 Kerberos v5 TGT
wpapsk WPA/WPA2-PSK needs ESSID
wpapsk-pmk WPA PMK
hdaa HTTP Digest Auth
apop APOP MD5
hmac-md5 HMAC-MD5
hmac-sha1 HMAC-SHA-1
sip SIP digest

#Encryption / Containers

Format Flag Description Notes
zip ZIP (classic) PKZIP
zip2 ZIP AES-256 WinZip
rar RAR3 slow
rar5 RAR5 AES
7z 7-Zip AES-256 very slow
pdf PDF (up to v1.7)
office MS Office 2007+ OOXML
oldoffice MS Office 97-03 RC4
ssh SSH private key PEM passphrase
keepass KeePass 1.x/2.x .kdbx
gpg GPG private key
luks LUKS disk header
bitlocker BitLocker VMK
dmg macOS DMG
truecrypt TrueCrypt volume
veracrypt VeraCrypt volume

#LDAP / Directory

Format Flag Description Prefix
nsldap Netscape LDAP SHA {SHA}
ssha Salted SHA-1 (LDAP) {SSHA}
ssha256 Salted SHA-256 (LDAP) {SSHA256}
ssha512 Salted SHA-512 (LDAP) {SSHA512}
ldap-md5 LDAP MD5 {MD5}

#Specifying Format

# Explicit format (avoids mis-detection)
john --format=NT hashes.txt --wordlist=rockyou.txt
john --format=bcrypt hashes.txt --wordlist=rockyou.txt
john --format=netntlmv2 --wordlist=rockyou.txt hashes.txt
john --format=krb5tgs --wordlist=rockyou.txt spn_hashes.txt
john --format=krb5asrep --wordlist=rockyou.txt asrep_hashes.txt

# WPA requires ESSID embedded (use hcxtools or wpapcap2john)
john --format=wpapsk --wordlist=rockyou.txt wpa.hash

# List all formats
john --list=formats
john --list=formats | grep -i kerberos
john --list=formats | grep -i opencl

#*2john Extraction Tools

#Archive & Document Tools

Tool Input Example
zip2john ZIP archive zip2john file.zip > zip.hash
rar2john RAR archive rar2john file.rar > rar.hash
7z2john.pl 7-Zip archive 7z2john.pl file.7z > 7z.hash
pdf2john.pl PDF document pdf2john.pl file.pdf > pdf.hash
office2john.py MS Office 2007+ office2john.py doc.docx > office.hash
oldoffice2john Office 97-2003 built into office2john
pwsafe2john.py Password Safe pwsafe2john.py db.psafe3 > ps.hash
keepass2john KeePass 1/2 keepass2john db.kdbx > kp.hash
keychain2john.py macOS Keychain keychain2john.py login.keychain > kc.hash

#System & Key Tools

Tool Input Example
ssh2john SSH private key ssh2john id_rsa > ssh.hash
gpg2john GPG private key gpg2john key.asc > gpg.hash
luks2john LUKS header luks2john /dev/sdb > luks.hash
bitlocker2john BitLocker VMK bitlocker2john -i disk.img > bl.hash
truecrypt2john.py TrueCrypt vol truecrypt2john.py vol.tc > tc.hash
dmg2john macOS DMG dmg2john image.dmg > dmg.hash
mozilla2john.py Firefox/Thunderbird mozilla2john.py ~/.mozilla/firefox/*.default/
filezilla2john.py FileZilla XML filezilla2john.py sitemanager.xml > fz.hash

#Crypto Wallet & Password Manager Tools

Tool Input Example
bitcoin2john.py Bitcoin Core wallet bitcoin2john.py wallet.dat > btc.hash
ethereum2john.py Ethereum UTC key ethereum2john.py UTC--... > eth.hash
electrum2john.py Electrum wallet electrum2john.py default_wallet > el.hash
blockchain2john.py Blockchain.com wallet blockchain2john.py wallet.aes.json > bc.hash
bitwarden2john.py Bitwarden export bitwarden2john.py data.json > bw.hash
lastpass2john.py LastPass export lastpass2john.py export.xml > lp.hash
dashlane2john.py Dashlane backup dashlane2john.py backup.aes > dl.hash
1password2john.py 1Password vault 1password2john.py *.agilekeychain > op.hash
keepass2john KeePass KDBX keepass2john db.kdbx > kp.hash

#Network & Auth Tools

Tool Input Example
wpapcap2john WPA pcap wpapcap2john capture.pcap > wpa.hash
hccap2john hccap file hccap2john file.hccap > wpa.hash
cisco2john.pl Cisco enable hash cisco2john.pl config.txt > cisco.hash
oracle2john.py Oracle password
ccache2john.py Kerberos ccache ccache2john.py admin.ccache > krb.hash
apop2john.py APOP challenge
androidfde2john.py Android FDE androidfde2john.py image.img > afde.hash
androidbackup2john.py Android backup androidbackup2john.py backup.ab > ab.hash

#Attack Modes

#Wordlist Attack

# Basic wordlist
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt

# Wordlist with default rules
john --wordlist=rockyou.txt --rules hashes.txt

# Named rulesets
john --wordlist=rockyou.txt --rules=Best64 hashes.txt
john --wordlist=rockyou.txt --rules=Jumbo hashes.txt
john --wordlist=rockyou.txt --rules=KoreLogic hashes.txt
john --wordlist=rockyou.txt --rules=All hashes.txt

# Combine multiple wordlists via stdin
cat list1.txt list2.txt | john --stdin --rules hashes.txt

# Deduplicate a wordlist first
john --wordlist=combined.txt --stdout | unique cleaned.txt

#Single Crack Mode

Uses login names, GECOS fields, and home directory info to generate candidates. Run this first - it is the fastest mode.

john --single hashes.txt
john --single --format=raw-md5 hashes.txt

# Feed username:hash format for best results
john --single --format=NT user_ntlm.txt
# File format: username:hash
# echo "alice:5f4dcc3b..." >> targets.txt

#Incremental (Brute Force) Mode

# Full ASCII brute force (all printable)
john --incremental hashes.txt

# Charset modes
john --incremental=ASCII hashes.txt    # all printable ASCII
john --incremental=Alnum hashes.txt   # a-z A-Z 0-9
john --incremental=Alpha hashes.txt   # a-z A-Z
john --incremental=Lower hashes.txt   # a-z only
john --incremental=Upper hashes.txt   # A-Z only
john --incremental=Digits hashes.txt  # 0-9 only

# Limit length range
john --incremental=Alnum --min-length=6 --max-length=8 hashes.txt

#Mask Attack (john-jumbo)

# Charset codes
# ?l = a-z  ?u = A-Z  ?d = 0-9  ?s = symbols  ?a = all printable
# ?h = 0-9a-f  ?H = 0-9A-F  ?b = 0x01-0xff

# Common patterns
john --mask='?u?l?l?l?d?d?d?d' hashes.txt        # Pass1234
john --mask='?u?l?l?l?l?s?d?d' hashes.txt        # mixed complexity
john --mask='?d?d?d?d?d?d' hashes.txt             # 6 digits (PIN)
john --mask='pass?d?d?d?d' hashes.txt             # passNNNN
john --mask='?u?l?l?l?l?l?d?d?d?d' hashes.txt    # Worddddd (10 chars)

# Custom charset slots -1 through -9
john --mask='?1?2?2?2?d?d?d?s' -1='[A-Z]' -2='[aeiou]' hashes.txt

# Hybrid: wordlist word as base (?w), append mask
john --wordlist=rockyou.txt --mask='?w?d?d?d?d' hashes.txt
john --wordlist=rockyou.txt --mask='?w?s?d?d' hashes.txt

# Length range with mask
john --mask='?a?a?a?a?a?a' --min-length=4 --max-length=6 hashes.txt

#External Mode (C-like scripting)

# Use a pre-defined external mode from john.conf
john --external=double hashes.txt
john --external=Strip hashes.txt

# External as a word filter (filter mode)
john --wordlist=rockyou.txt --external=Uppercase hashes.txt

#Built-in Rule Sets

#Rules Reference

Rule Description
--rules Default (Wordlist section in john.conf)
--rules=Single Single crack rules (aggressive mangling)
--rules=Wordlist Standard wordlist rules (good start)
--rules=Best64 64 top-performing rules (fast)
--rules=Extra Extended set, more transforms
--rules=Jumbo Full Jumbo ruleset
--rules=KoreLogic KoreLogic: corporate password patterns
--rules=T0XlC Long brute-force-style rules
--rules=d3ad0ne d3ad0ne rules
--rules=All All rules combined (very slow)
# 1. Single mode (account metadata - username mangling)
john --single --format=<format> hashes.txt

# 2. Wordlist baseline (no rules)
john --wordlist=rockyou.txt --format=<format> hashes.txt

# 3. Wordlist + Best64 (fast, high yield)
john --wordlist=rockyou.txt --rules=Best64 --format=<format> hashes.txt

# 4. Wordlist + KoreLogic (medium, broader coverage)
john --wordlist=rockyou.txt --rules=KoreLogic --format=<format> hashes.txt

# 5. Wordlist + Jumbo (slow, extensive mutations)
john --wordlist=rockyou.txt --rules=Jumbo --format=<format> hashes.txt

# 6. Mask attack (known pattern, e.g. Season+Year)
john --mask='?u?l?l?l?l?l?d?d?d?d' --format=<format> hashes.txt

# 7. Incremental (brute force - fast hashes only)
john --incremental=Alnum --format=<format> hashes.txt

#Custom Rules

#Rule Syntax Quick Reference

Command Description Example output (word: pass)
l Lowercase all pass
u Uppercase all PASS
c Capitalize Pass
C Lowercase, uppercase rest pASS
t Toggle all case PASS / pass
TN Toggle char at position N T0 -> Pass
r Reverse ssap
d Duplicate passpass
f Reflect (mirror) passssap
{ Rotate left assp
} Rotate right spas
[ Delete first char ass
] Delete last char pas
DN Delete char at position N D1 -> pss
$X Append char X $1 -> pass1
^X Prefix char X ^A -> Apass
iNX Insert char X at position N i2! -> pa!ss
oNX Overstrike position N with X o0A -> Aass
xNM Extract M chars from pos N x04 -> pass
'N Truncate to N chars '3 -> pas
AN"STR" Insert string at position N A0"!" -> "!pass"
sXY Substitute X with Y sa@ -> p@ss
S Shift all (l33t)
V Vowel-shift
p Pluralize (add s) passs
P Add past tense (add ed) passed
<N Reject if length < N filter
>N Reject if length > N filter
/X Reject if no char X filter
!X Reject if char X present filter
=NX Reject if pos N != X filter

#Writing Custom Rules (john.conf)

Add custom rules to /etc/john/john.conf or ~/.john/john.conf under a named section:

# Corporate password policy: Word + Year (e.g., Summer2024)
[List.Rules:Corporate]
# Capitalize + append 4-digit years 2020-2024
c$2$0$2$[0-4]
# Capitalize + append year + !
c$2$0$2$[0-4]$!
# Capitalize + append season + year
# (use wordlist with seasons, append digits)
c Az"20" $[0-9] $[0-9]

# Leet-speak + number suffix
[List.Rules:L33t]
s a@ s e3 s o0 s i! $[0-9]
sa@ se3 so0 si! $[0-9] $[0-9]

# Common corporate patterns: Word+Number+Symbol
[List.Rules:CorpSuffix]
c $[0-9] $[0-9] $!
c $[0-9] $[0-9] $[0-9] $!
c Az"!" $[0-9] $[0-9]
# Use custom rule from john.conf
john --wordlist=seasons.txt --rules=Corporate hashes.txt
john --wordlist=company_words.txt --rules=CorpSuffix hashes.txt

# Generate wordlist candidates to stdout (for piping/testing)
john --wordlist=rockyou.txt --rules=Corporate --stdout | head -20
john --wordlist=rockyou.txt --rules=KoreLogic --stdout | wc -l

#Season+Year Pattern Rules

# /etc/john/john.conf  -- add under [List.Rules:SeasonYear]
[List.Rules:SeasonYear]
# append 2-digit year range 20-24
c $2 $[0-4]
c $2 $[0-4] $!
# append 4-digit year
c Az"20" $[2-4]
c Az"20" $[2-4] $!
# e.g. Summer2023, Winter2022!, Spring2024
# Create seasons wordlist
echo -e "Spring\nSummer\nFall\nWinter\nAutumn\nJanuary\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember" > seasons.txt

john --wordlist=seasons.txt --rules=SeasonYear hashes.txt

# Company name + number pattern
echo "CompanyName" > company.txt
john --wordlist=company.txt --rules=CorpSuffix hashes.txt

#Wordlist Generation & Manipulation

#Stdout & Piping

# Output candidates to stdout (for piping to other tools)
john --wordlist=rockyou.txt --rules=Best64 --stdout
john --wordlist=rockyou.txt --rules=KoreLogic --stdout | wc -l

# Pipe directly into hashcat
john --wordlist=rockyou.txt --rules=Best64 --stdout | \
  hashcat -m 1000 hashes.txt -

# Generate incremental candidates to file
john --incremental=Alnum --stdout --max-length=6 > alnum6.txt

# Mask to stdout
john --mask='?u?l?l?l?d?d?d?d' --stdout > mask_candidates.txt

#Wordlist Tools

# Remove duplicates from wordlist (john built-in)
john --wordlist=combined.txt --stdout | unique deduped.txt

# Make a charset file from a sample (for incremental mode)
john --make-charset=custom.chr

# Reference custom charset in john.conf:
# [Incremental:Custom]
# File = $JOHN/custom.chr
# MinLen = 6
# MaxLen = 10
# CharCount = 62

# Sort wordlist for optimal performance with salted hashes
sort wordlist.txt > sorted_wordlist.txt

#Combining & Filtering

# Merge and dedup multiple wordlists
cat rockyou.txt custom.txt | sort -u | unique merged.txt

# Filter to a specific length
john --wordlist=rockyou.txt --stdout --min-length=8 --max-length=12 > filtered.txt

# Pipe crunch candidates directly (install crunch)
crunch 8 10 abcdefghijklmnopqrstuvwxyz0123456789 | john --stdin hashes.txt

# Use cewl to generate target-specific wordlist
cewl -d 3 -m 5 https://target.com -w target_words.txt
john --wordlist=target_words.txt --rules=KoreLogic hashes.txt

#Linux / Unix Shadow Files

#Unshadow & Crack

# Combine /etc/passwd and /etc/shadow
unshadow /etc/passwd /etc/shadow > unshadowed.txt

# Crack combined file (auto-detects format)
john --wordlist=/usr/share/wordlists/rockyou.txt unshadowed.txt

# Crack sha512crypt explicitly
john --format=sha512crypt --wordlist=rockyou.txt unshadowed.txt

# Single crack mode first (fast)
john --single unshadowed.txt

# Show cracked passwords with usernames
john --show unshadowed.txt

# Show only uncracked (remaining targets)
john --show=left unshadowed.txt

#Windows / Active Directory Cracking

#NTLM & NetNTLM

# Crack NTLM hashes (from secretsdump, hashdump, mimikatz)
# Format: username:RID:LMhash:NThash:::
john --format=NT --wordlist=rockyou.txt ntlm.txt

# Crack NetNTLMv2 (captured with Responder / Inveigh)
john --format=netntlmv2 --wordlist=rockyou.txt netntlmv2.txt

# Crack NTLMv1 (legacy)
john --format=netntlm --wordlist=rockyou.txt ntlmv1.txt

# Rules greatly help NTLM (fast hash, can afford it)
john --format=NT --wordlist=rockyou.txt --rules=KoreLogic ntlm.txt

#Kerberos & DCC2

# Kerberoasting (TGS-REP hashes from GetUserSPNs)
john --format=krb5tgs --wordlist=rockyou.txt spn_hashes.txt
john --format=krb5tgs --wordlist=rockyou.txt --rules spn_hashes.txt

# AS-REP Roasting (AS-REP hashes, no pre-auth required)
john --format=krb5asrep --wordlist=rockyou.txt asrep_hashes.txt

# Domain Cached Credentials v2 (DCC2, very slow)
# Only wordlist mode is practical
john --format=mscash2 --wordlist=rockyou.txt dcc2.txt

# DCC2 format: $DCC2$10240#username#hash

#Full Responder -> John Chain

# Step 1: Capture NTLMv2 with Responder (on attacker machine)
sudo responder -I eth0 -wrf

# Step 2: Hashes saved to /usr/share/responder/logs/
ls /usr/share/responder/logs/SMB-NTLMv2-SSP-*.txt

# Step 3: Crack with john
john --format=netntlmv2 \
     --wordlist=/usr/share/wordlists/rockyou.txt \
     /usr/share/responder/logs/SMB-NTLMv2-SSP-192.168.1.10.txt

# Step 4: Show results
john --show /usr/share/responder/logs/SMB-NTLMv2-SSP-192.168.1.10.txt

#Archive & Key Cracking

#Extract & Crack

# ZIP archive
zip2john protected.zip > zip.hash
john --wordlist=rockyou.txt zip.hash
john --show zip.hash

# RAR archive (rar3/rar5 auto-detected)
rar2john protected.rar > rar.hash
john --wordlist=rockyou.txt rar.hash

# 7-Zip (slow due to AES + many iterations)
7z2john.pl archive.7z > 7z.hash
john --wordlist=rockyou.txt 7z.hash

# PDF document
pdf2john.pl protected.pdf > pdf.hash
john --wordlist=rockyou.txt pdf.hash

# MS Office 2007+ (docx, xlsx, pptx)
office2john.py document.docx > office.hash
john --wordlist=rockyou.txt office.hash

# SSH private key (passphrase-protected)
ssh2john id_rsa > ssh.hash
john --wordlist=rockyou.txt ssh.hash

# KeePass database
keepass2john database.kdbx > kp.hash
john --wordlist=rockyou.txt kp.hash
# With keyfile:
keepass2john -k keyfile.key database.kdbx > kp.hash

# GPG private key
gpg2john private.key > gpg.hash
john --wordlist=rockyou.txt gpg.hash

# LUKS encrypted partition
luks2john /dev/sdb > luks.hash
john --wordlist=rockyou.txt luks.hash

# BitLocker VMK (from disk image)
bitlocker2john -i encrypted.vhd > bl.hash
john --format=bitlocker --wordlist=rockyou.txt bl.hash

#Session Management

#Session Commands

# Start named session (automatically resumable)
john --session=corp_ntlm --wordlist=rockyou.txt hashes.txt

# Restore interrupted session
john --restore=corp_ntlm

# Restore default session
john --restore

# Check status of running session (send SIGUSR1 or use flag)
john --status=corp_ntlm
# Or press 'q' / send signal to running john process:
kill -USR1 $(pgrep john)

# List session/pot files
ls ~/.john/
# john.pot  -- all cracked hashes (persistent)
# *.rec     -- session recovery files

# Use alternate pot file (avoid polluting main pot)
john --pot=./ctf.pot --wordlist=rockyou.txt hashes.txt
john --show --pot=./ctf.pot hashes.txt

#Show & Output

# Show all cracked passwords
john --show hashes.txt

# Show cracked for specific format
john --show --format=NT hashes.txt

# Show remaining (not yet cracked)
john --show=left hashes.txt

# Count cracked vs total
john --show hashes.txt 2>&1 | tail -1

# Output to file (redirect)
john --show hashes.txt > cracked.txt

#Performance Optimization

#CPU Parallelism

# Fork N processes (uses N CPU cores)
john --wordlist=rockyou.txt --fork=4 hashes.txt
john --wordlist=rockyou.txt --rules --fork=$(nproc) hashes.txt

# OpenMP (built-in parallelism for some formats)
# Enabled by default if john compiled with OpenMP
OMP_NUM_THREADS=8 john --wordlist=rockyou.txt hashes.txt

# Save memory when cracking large hash files
john --save-memory=1 hashes.txt   # some tables not preloaded
john --save-memory=2 hashes.txt   # more savings, slower
john --save-memory=3 hashes.txt   # maximum savings

# Limit run time (useful in scripts)
john --max-run-time=3600 --wordlist=rockyou.txt hashes.txt

# Target specific cost (filter hard hashes out)
john --costs=t=10..12 --wordlist=rockyou.txt hashes.txt

#Distributed Cracking (--node)

# Split work across M machines (node M of N total)
# Machine 1 of 4:
john --node=1/4 --wordlist=rockyou.txt hashes.txt
# Machine 2 of 4:
john --node=2/4 --wordlist=rockyou.txt hashes.txt
# Machine 3 of 4:
john --node=3/4 --wordlist=rockyou.txt hashes.txt
# Machine 4 of 4:
john --node=4/4 --wordlist=rockyou.txt hashes.txt

# Range of nodes (for running multiple on one machine)
john --node=1-2/4 --wordlist=rockyou.txt hashes.txt

# Works with all attack modes
john --node=1/3 --incremental=Alnum hashes.txt
john --node=1/3 --mask='?a?a?a?a?a?a?a?a' hashes.txt

# Combine fork + node for local + distributed
john --node=1/4 --fork=8 --wordlist=rockyou.txt hashes.txt

#GPU Acceleration (OpenCL)

# GPU formats require explicit -opencl suffix
john --format=sha512crypt-opencl --wordlist=rockyou.txt hashes.txt
john --format=bcrypt-opencl --wordlist=rockyou.txt hashes.txt
john --format=sha256crypt-opencl --wordlist=rockyou.txt hashes.txt
john --format=NT-opencl --wordlist=rockyou.txt hashes.txt
john --format=mscash2-opencl --wordlist=rockyou.txt hashes.txt
john --format=wpapsk-opencl --wordlist=rockyou.txt wpa.hash
john --format=raw-sha512-opencl --wordlist=rockyou.txt hashes.txt
john --format=md5crypt-opencl --wordlist=rockyou.txt hashes.txt

# List all available OpenCL formats
john --list=formats --format=opencl

# Tune GPU work sizes (larger = better GPU utilization)
john --format=sha512crypt-opencl --lws=64 --gws=4096 \
     --wordlist=rockyou.txt hashes.txt

# Multi-GPU: select device
john --format=bcrypt-opencl --dev=0 --wordlist=rockyou.txt hashes.txt
john --format=bcrypt-opencl --dev=1 --wordlist=rockyou.txt hashes.txt

# Temperature is monitored automatically (default limit: 95°C)
Setting Usage
--format=X-opencl Enable GPU for format X
--dev=N Select GPU device N (0-based)
--lws=N Local work size (tune for GPU)
--gws=N Global work size (tune for GPU)
--fork=N + --dev Multi-GPU parallelism

#Hash Identification

#Identify Before Cracking

# John's own format detection (try and see)
john --list=formats | grep -i md5
john --list=formats | grep -i kerberos
john --list=formats | grep -i sha

# External identification tools
hash-identifier '$2y$10$...'
hashid '$1$salt$hash'
name-that-hash -t '$6$salt$hash'

# hashid with john format output
hashid -j '$6$rounds=5000$...'

# Identify from file
name-that-hash -f hashes.txt

#Hash Format Prefixes

Prefix Format John Flag
$1$ MD5-crypt md5crypt
$2a$ / $2b$ / $2y$ bcrypt bcrypt
$5$ SHA-256-crypt sha256crypt
$6$ SHA-512-crypt sha512crypt
$y$ yescrypt yescrypt
$7$ scrypt scrypt
$md5 SunMD5 sunmd5
$P$ / $H$ PHPass phpass
$DCC2$ MS DCC2 mscash2
$krb5tgs$ Kerberos TGS krb5tgs
$krb5asrep$ Kerberos AS-REP krb5asrep
{SHA} LDAP SHA nsldap
{SSHA} LDAP SSHA ssha
32-char hex MD5 or NTLM raw-md5 or NT

#Practical Attack Chains

#CTF Hash Workflow

# Step 1: Identify the hash
name-that-hash -t 'HASHVALUE'
hashid -j 'HASHVALUE'

# Step 2: Try john auto-detect first
echo 'HASHVALUE' > hash.txt
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt

# Step 3: Explicit format if auto-detect fails
john --format=raw-sha256 --wordlist=rockyou.txt hash.txt
john --format=raw-sha256 --wordlist=rockyou.txt --rules hash.txt

# Step 4: Brute-force short hashes
john --format=raw-md5 --incremental hash.txt

# Step 5: Show result
john --show --format=raw-sha256 hash.txt

#AD Credential Cracking Chain

# 1. Dump hashes (post-exploitation)
python3 secretsdump.py domain/[email protected] -just-dc-ntlm

# 2. Extract NT hashes (field 4 of secretsdump output)
awk -F: '{print $4}' secretsdump.txt | sort -u > nt_hashes.txt

# 3. Crack NTLM
john --format=NT --wordlist=rockyou.txt nt_hashes.txt
john --format=NT --wordlist=rockyou.txt --rules=KoreLogic nt_hashes.txt

# 4. Kerberoasting
GetUserSPNs.py domain/user:pass -dc-ip 10.10.10.1 -request -outputfile spns.txt
john --format=krb5tgs --wordlist=rockyou.txt spns.txt

# 5. AS-REP Roasting
GetNPUsers.py domain/ -usersfile users.txt -dc-ip 10.10.10.1 -no-pass -format john
john --format=krb5asrep --wordlist=rockyou.txt asrep_hashes.txt

#WPA/WPA2 Cracking Chain

# Step 1: Capture handshake (airodump-ng / hcxdumptool)
airodump-ng -c 6 --bssid AA:BB:CC:DD:EE:FF -w capture wlan0mon

# Step 2: Convert pcap to john format
wpapcap2john capture-01.cap > wpa.hash
# OR use hcxtools:
hcxpcapngtool -o hash.hc22000 capture-01.pcapng
# (for john, wpapcap2john is better)

# Step 3: Crack (ESSID is embedded in hash)
john --format=wpapsk --wordlist=rockyou.txt wpa.hash
john --format=wpapsk-opencl --wordlist=rockyou.txt wpa.hash  # GPU

# Step 4: Targeted wordlist with rules
john --format=wpapsk --wordlist=rockyou.txt --rules=Best64 wpa.hash

#John vs Hashcat Comparison

#When to Use John

Scenario Reason
Extracting & cracking in one workflow *2john tools + crack pipeline
SSH key / KeePass / archive cracking Built-in extraction tools
Single crack mode (GECOS/username) No hashcat equivalent
Quick CPU-based wordlist attack Fast to set up, no GPU needed
Custom rule writing (complex logic) Richer rule syntax than hashcat
Distributed cracking (--node) Simple multi-machine splitting
Low hash count, slow hashes CPU often fine for 1-10 bcrypt

#When to Use Hashcat

Scenario Reason
Massive hash lists (10k+ NTLM) GPU throughput far exceeds CPU
bcrypt / scrypt / argon2 at scale GPU gives 10-50x speedup
Rule-based attacks on GPU Hashcat runs rules natively on GPU
Prince attack (--attack-mode=6) Not available in john
Combination attack (2 wordlists) Hashcat -a 1
Permutation attack Hashcat --attack-mode=7
Large charset mask attacks GPU mask is significantly faster
WPA at scale Hashcat -m 22000 + GPU

#Performance Reality Check

Hash Type John CPU Hashcat GPU (RTX 3090) Use
NTLM ~1 GH/s (8 cores) ~60 GH/s hashcat for bulk
MD5 ~800 MH/s ~50 GH/s hashcat for bulk
SHA-512crypt ~50k H/s ~1.5M H/s john-opencl or hashcat
bcrypt ($2b$, cost 10) ~3k H/s ~100k H/s hashcat GPU preferred
NetNTLMv2 ~500 MH/s ~3 GH/s hashcat for bulk
Kerberos TGS ~250 MH/s ~1.5 GH/s hashcat for bulk
ZIP (AES-256) ~50k H/s ~300k H/s either

#Miscellaneous Options

#Useful Flags

# Benchmark a format (measure H/s on your hardware)
john --test --format=bcrypt
john --test=60 --format=sha512crypt   # run for 60 seconds

# Target specific users from a shadow/dump file
john --users=root,admin --wordlist=rockyou.txt unshadowed.txt

# Target by UID range
john --uid-min=1000 --uid-max=1999 unshadowed.txt

# Select only salts appearing N+ times (optimize salt reuse)
john --salts=2 hashes.txt       # only salts with 2+ accounts
john --salts=-5 hashes.txt      # only salts with 5 or fewer accounts

# Use custom config file
john --config=/path/to/john.conf --wordlist=rockyou.txt hashes.txt

# Encoding support (non-ASCII passwords)
john --encoding=utf-8 --wordlist=unicode_words.txt hashes.txt
john --encoding=koi8-r --wordlist=russian.txt hashes.txt

#Filters & Selectors

# Filter by minimum/maximum password length candidates
john --min-length=8 --max-length=16 --wordlist=rockyou.txt hashes.txt

# Only crack hashes of specific format in mixed file
john --format=bcrypt --wordlist=rockyou.txt mixed_hashes.txt

# Reject short wordlist candidates during rules
# (add to rule: >7  means reject if len < 8)

# Show pot file contents directly
cat ~/.john/john.pot

# Clear pot file (start fresh)
> ~/.john/john.pot

#Also See

#Cyber Aurelien Guidi