Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

John the Ripper Cheatsheet

Basic Syntax

john [options] <hash_file>

Cracking Modes

ModeOptionDescriptionExample
Single--singleRule-based cracking using username/GECOS datajohn --single passwd
Wordlist--wordlist=FILEDictionary attack with wordlistjohn --wordlist=rockyou.txt hashes.txt
Incremental--incrementalBrute-force using Markov chainsjohn --incremental hashes.txt

Common Options

OptionDescriptionExample
--format=FORMATSpecify hash formatjohn --format=raw-md5 hashes.txt
--wordlist=FILEUse wordlist for dictionary attackjohn --wordlist=passwords.txt hashes.txt
--rulesApply word mangling rulesjohn --wordlist=words.txt --rules hashes.txt
--showDisplay cracked passwordsjohn --show hashes.txt
--pot=FILESpecify pot file locationjohn --pot=custom.pot hashes.txt
--session=NAMEName the session for restorejohn --session=crack1 hashes.txt
--restore=NAMERestore a previous sessionjohn --restore=crack1

Common Hash Formats

FormatOptionDescription
MD5--format=raw-md5Raw MD5 hashes
SHA1--format=raw-sha1Raw SHA1 hashes
SHA256--format=raw-sha256Raw SHA256 hashes
SHA512--format=raw-sha512Raw SHA512 hashes
SHA512crypt--format=sha512cryptLinux $6$ hashes
MD5crypt--format=md5cryptLinux $1$ hashes
bcrypt--format=bcryptBlowfish-based hashes
NT--format=ntWindows NT hashes
LM--format=LMLAN Manager hashes
NTLM--format=netntlmNTLM network hashes
NTLMv2--format=netntlmv2NTLMv2 network hashes
Kerberos 5--format=krb5Kerberos 5 hashes
MySQL--format=mysql-sha1MySQL SHA1 hashes
MSSQL--format=mssqlMS SQL hashes
Oracle--format=oracle11Oracle 11 hashes

2john Conversion Tools

ToolDescription
zip2johnConvert ZIP archives
rar2johnConvert RAR archives
pdf2johnConvert PDF documents
ssh2johnConvert SSH private keys
keepass2johnConvert KeePass databases
office2johnConvert MS Office documents
putty2johnConvert PuTTY private keys
gpg2johnConvert GPG keys
wpa2johnConvert WPA/WPA2 handshakes
truecrypt_volume2johnConvert TrueCrypt volumes
bitlocker2johnConvert BitLocker volumes
7z2john.plConvert 7-Zip archives

Usage:

<tool> <file_to_crack> > file.hash
john file.hash

Useful Examples

Crack Linux Shadow File

john --single passwd

Dictionary Attack with Rules

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

Crack Specific Format

john --format=raw-md5 --wordlist=passwords.txt md5_hashes.txt

Show Cracked Passwords

john --show hashes.txt

Crack ZIP File

zip2john protected.zip > zip.hash
john --wordlist=rockyou.txt zip.hash

Crack SSH Private Key

ssh2john id_rsa > ssh.hash
john --wordlist=passwords.txt ssh.hash

Incremental Mode (Brute Force)

john --incremental hashes.txt

Resume a Session

john --restore=session_name

Hunting for Encrypted Files

Find common encrypted file types

for ext in $(echo ".xls .xls* .xltx .od* .doc .doc* .pdf .pot .pot* .pp*"); do
  echo -e "\nFile extension: " $ext
  find / -name *$ext 2>/dev/null | grep -v "lib\|fonts\|share\|core"
done

Find SSH private keys

grep -rnE '^\-{5}BEGIN [A-Z0-9]+ PRIVATE KEY\-{5}$' /* 2>/dev/null

Check if SSH key is encrypted

ssh-keygen -yf ~/.ssh/id_rsa
# If encrypted, prompts for passphrase

Cracking Protected Files

Crack Encrypted SSH Key

ssh2john.py SSH.private > ssh.hash
john --wordlist=rockyou.txt ssh.hash
john ssh.hash --show

Crack Office Document

office2john.py Protected.docx > protected-docx.hash
john --wordlist=rockyou.txt protected-docx.hash
john protected-docx.hash --show

Crack PDF File

pdf2john.py PDF.pdf > pdf.hash
john --wordlist=rockyou.txt pdf.hash
john pdf.hash --show

Cracking Protected Archives

Crack ZIP File

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

Crack OpenSSL Encrypted GZIP

# Check file type
file GZIP.gzip
# Output: openssl enc'd data with salted password

# Brute-force with loop (errors expected, file extracts on success)
for i in $(cat rockyou.txt); do
  openssl enc -aes-256-cbc -d -in GZIP.gzip -k $i 2>/dev/null | tar xz
done

Crack BitLocker Drive

bitlocker2john -i Backup.vhd > backup.hashes
grep "bitlocker\$0" backup.hashes > backup.hash
john --wordlist=rockyou.txt backup.hash

Mounting BitLocker Drives (Linux)

# Install dislocker
sudo apt-get install dislocker

# Create mount points
sudo mkdir -p /media/bitlocker /media/bitlockermount

# Mount and decrypt
sudo losetup -f -P Backup.vhd
sudo dislocker /dev/loop0p2 -u<password> -- /media/bitlocker
sudo mount -o loop /media/bitlocker/dislocker-file /media/bitlockermount

# Unmount when done
sudo umount /media/bitlockermount
sudo umount /media/bitlocker