black electronics

John the Ripper

John the Ripper is a powerful password-cracking tool designed for security professionals to test password strength. It supports various encryption formats, detects weak passwords, and helps enhance security by identifying vulnerabilities in authentication systems. John the Ripper is a go-to password-cracking tool for pentesters, enabling efficient testing of password strength and uncovering weak credentials across various formats.

Installation and Setup

From Package Managers

Kali Linux: Pre-installed. Run directly with john.

Debian/Ubuntu
sudo apt update && sudo apt install john
MacOS
brew install john-jumbo

From Source

Terminal window
git clone https://github.com/openwall/john -b bleeding-jumbo john-jumbo
cd john-jumbo/src
./configure && make -s clean && make -sj4
cd ../run
./john --help

Updating John the Ripper

From source
cd john-jumbo && git pull && cd src && make clean && make -sj4
From package manager
sudo apt update && sudo apt upgrade john

Basic Commands

Terminal window
john hashfile.txt #Crack hashes with default settings
john --wordlist=wordlist.txt hashfile.txt #Use a custom wordlist
john --rules --wordlist=wordlist.txt hashfile.txt #Enable rules for advanced mutations
john --incremental hashfile.txt #Incremental brute force attack
john --mask=?d?d?d?d hashfile.txt #Mask attack for 4-digit PINs
john --show hashfile.txt #Display cracked passwords
john --restore=session_name #Resume a saved session
john --session=my_session hashfile.txt #Save progress with a session name

Format Detection and Specification

Terminal window
john --list=formats #List all supported hash formats
john --format=raw-md5 hashfile.txt #Specify hash format

External Wordlists

Terminal window
john --wordlist=/usr/share/wordlists/rockyou.txt hashfile.txt
john --wordlist=custom_list.txt hashfile.txt --rules

Performance Tuning

Terminal window
john --fork=4 hashfile.txt #Multi-threading with 4 processes
john --format=nt --fork=8 hashfile.txt #Combine format and threading
john --max-run-time=3600 hashfile.txt #Stop after 1 hour

Custom Masks and Incremental Modes

Terminal window
john --mask=?u?l?l?l?d hashfile.txt #Uppercase, lowercase, and digit mask
john --mask=?d?d?d?d?d --incremental hashfile.txt #Incremental 5-digit PIN
john --incremental=digits hashfile.txt #Incremental mode for digits
john --incremental=alnum hashfile.txt #Incremental alphanumeric
john --mask=?a?a?a?a?a hashfile.txt #Any printable ASCII character

File-Specific Cracking

ZIP Files

Terminal window
zip2john file.zip > zip_hash.txt #Convert ZIP to hash
john zip_hash.txt --wordlist=wordlist.txt #Crack ZIP password

SSH Private Keys

Terminal window
ssh2john id_rsa > ssh_hash.txt #Convert SSH key to hash
john ssh_hash.txt --wordlist=wordlist.txt #Crack SSH password

PDF Files

Terminal window
pdf2john.pl file.pdf > pdf_hash.txt #Convert PDF to hash
john pdf_hash.txt --wordlist=wordlist.txt #Crack PDF password

Windows Hashes

LM/NTLM Cracking

Terminal window
john --format=lm hashfile.txt #Crack LM hashes
john --format=nt hashfile.txt #Crack NTLM hashes

SAM Dump

Terminal window
samdump2 /mnt/windows/System32/config/SAM > sam_hashes.txt
john sam_hashes.txt --format=nt

Session and State Management

Terminal window
john --session=my_session hashfile.txt #Save session with a name
john --restore=my_session #Restore session
john --status=my_session #Check session status
john --nolog hashfile.txt #Run without logging

Cracking Modes

Single Crack Mode

Terminal window
john --single hashfile.txt #Use usernames as guesses

Wordlist Mode

Terminal window
john --wordlist=wordlist.txt hashfile.txt
john --wordlist=wordlist.txt --rules=Jumbo hashfile.txt #Apply advanced rules

Incremental Mode

Terminal window
john --incremental hashfile.txt #Brute force with rules

External Mode

Terminal window
john --external=Filter hashfile.txt #Apply external rules

Custom Rules

Define custom rules in john.conf under [List.Rules:CustomRules]. Example:

[List.Rules:CustomRules]
cAz"123" #Append "123" to each word
Az"!!" #Append "!!"

Run with:

Terminal window
john --rules=CustomRules --wordlist=wordlist.txt hashfile.txt

Some good custom John the Ripper rules:

[List.Rules:Try]
cAz"[0-9]"
cAz"[£!$@#]"
cAz"[0-9][0-9]"
cAz"[0-9][£!$@#]"
cAz"[£!$@#][0-9]"
cAz"[£!$@#][£!$@#]"
cAz"[0-9][0-9][0-9]"
cAz"[£!$@#][0-9][0-9]"
cAz"[0-9][0-9][£!$@#]"
cAz"[0-9][£!$@#][0-9]"
cAz"[£!$@#][£!$@#][£!$@#]"
cAz"[0-9][0-9][0-9][0-9]"
cAz"[0-9][£!$@#][£!$@#][£!$@#]"
cAz"[£!$@#][0-9][£!$@#][£!$@#]"
cAz"[£!$@#][£!$@#][0-9][£!$@#]"
cAz"[£!$@#][£!$@#][£!$@#][0-9]"
cAz"[0-9][0-9][£!$@#][£!$@#]"
cAz"[0-9][£!$@#][0-9][£!$@#]"
cAz"[0-9][£!$@#][£!$@#][0-9]"
cAz"[£!$@#][0-9][£!$@#][0-9]"
cAz"[£!$@#][0-9][0-9][£!$@#]"
cAz"[£!$@#][£!$@#][0-9][0-9]"
cAz"[0-9][0-9][0-9][£!$@#]"
cAz"[0-9][0-9][£!$@#][0-9]"
cAz"[0-9][£!$@#][0-9][0-9]"
cAz"[£!$@#][0-9][0-9][0-9]"
cAz"[£!$@#][£!$@#][£!$@#][£!$@#]"
Az"[0-9]"
Az"[£!$@#]"
Az"[0-9][0-9]"
Az"[0-9][£!$@#]"
Az"[£!$@#][0-9]"
Az"[£!$@#][£!$@#]"
Az"[0-9][0-9][0-9]"
Az"[£!$@#][0-9][0-9]"
Az"[0-9][0-9][£!$@#]"
Az"[0-9][£!$@#][0-9]"
Az"[£!$@#][£!$@#][£!$@#]"
Az"[0-9][0-9][0-9][0-9]"
Az"[0-9][£!$@#][£!$@#][£!$@#]"
Az"[£!$@#][0-9][£!$@#][£!$@#]"
Az"[£!$@#][£!$@#][0-9][£!$@#]"
Az"[£!$@#][£!$@#][£!$@#][0-9]"
Az"[0-9][0-9][£!$@#][£!$@#]"
Az"[0-9][£!$@#][0-9][£!$@#]"
Az"[0-9][£!$@#][£!$@#][0-9]"
Az"[£!$@#][0-9][£!$@#][0-9]"
Az"[£!$@#][0-9][0-9][£!$@#]"
Az"[£!$@#][£!$@#][0-9][0-9]"
Az"[0-9][0-9][0-9][£!$@#]"
Az"[0-9][0-9][£!$@#][0-9]"
Az"[0-9][£!$@#][0-9][0-9]"
Az"[£!$@#][0-9][0-9][0-9]"
Az"[£!$@#][£!$@#][£!$@#][£!$@#]"
[List.Rules:TryHarder]
cAz"[0-9]"
cAz"[£!$@#%?.:^&]"
cAz"[0-9][0-9]"
cAz"[0-9][£!$@#%?.:^&]"
cAz"[£!$@#%?.:^&][0-9]"
cAz"[£!$@#%?.:^&][£!$@#%?.:^&]"
cAz"[0-9][0-9][0-9]"
cAz"[£!$@#%?.:^&][0-9][0-9]"
cAz"[0-9][0-9][£!$@#%?.:^&]"
cAz"[0-9][£!$@#%?.:^&][0-9]"
cAz"[£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&]"
cAz"[0-9][0-9][0-9][0-9]"
cAz"[0-9][£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&]"
cAz"[£!$@#%?.:^&][0-9][£!$@#%?.:^&][£!$@#%?.:^&]"
cAz"[£!$@#%?.:^&][£!$@#%?.:^&][0-9][£!$@#%?.:^&]"
cAz"[£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&][0-9]"
cAz"[0-9][0-9][£!$@#%?.:^&][£!$@#%?.:^&]"
cAz"[0-9][£!$@#%?.:^&][0-9][£!$@#%?.:^&]"
cAz"[0-9][£!$@#%?.:^&][£!$@#%?.:^&][0-9]"
cAz"[£!$@#%?.:^&][0-9][£!$@#%?.:^&][0-9]"
cAz"[£!$@#%?.:^&][0-9][0-9][£!$@#%?.:^&]"
cAz"[£!$@#%?.:^&][£!$@#%?.:^&][0-9][0-9]"
cAz"[0-9][0-9][0-9][£!$@#%?.:^&]"
cAz"[0-9][0-9][£!$@#%?.:^&][0-9]"
cAz"[0-9][£!$@#%?.:^&][0-9][0-9]"
cAz"[£!$@#%?.:^&][0-9][0-9][0-9]"
cAz"[£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&]"
Az"[0-9]"
Az"[£!$@#%?.:^&]"
Az"[0-9][0-9]"
Az"[0-9][£!$@#%?.:^&]"
Az"[£!$@#%?.:^&][0-9]"
Az"[£!$@#%?.:^&][£!$@#%?.:^&]"
Az"[0-9][0-9][0-9]"
Az"[£!$@#%?.:^&][0-9][0-9]"
Az"[0-9][0-9][£!$@#%?.:^&]"
Az"[0-9][£!$@#%?.:^&][0-9]"
Az"[£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&]"
Az"[0-9][0-9][0-9][0-9]"
Az"[0-9][£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&]"
Az"[£!$@#%?.:^&][0-9][£!$@#%?.:^&][£!$@#%?.:^&]"
Az"[£!$@#%?.:^&][£!$@#%?.:^&][0-9][£!$@#%?.:^&]"
Az"[£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&][0-9]"
Az"[0-9][0-9][£!$@#%?.:^&][£!$@#%?.:^&]"
Az"[0-9][£!$@#%?.:^&][0-9][£!$@#%?.:^&]"
Az"[0-9][£!$@#%?.:^&][£!$@#%?.:^&][0-9]"
Az"[£!$@#%?.:^&][0-9][£!$@#%?.:^&][0-9]"
Az"[£!$@#%?.:^&][0-9][0-9][£!$@#%?.:^&]"
Az"[£!$@#%?.:^&][£!$@#%?.:^&][0-9][0-9]"
Az"[0-9][0-9][0-9][£!$@#%?.:^&]"
Az"[0-9][0-9][£!$@#%?.:^&][0-9]"
Az"[0-9][£!$@#%?.:^&][0-9][0-9]"
Az"[£!$@#%?.:^&][0-9][0-9][0-9]"
Az"[£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&][£!$@#%?.:^&]"
[List.Rules:BeBrutal]
cAz"[0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[0-9][0-9]"
cAz"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[0-9][0-9][0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9]"
cAz"[0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[0-9][0-9][0-9][0-9]"
cAz"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
cAz"[0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9]"
cAz"[0-9][0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
cAz"[0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
cAz"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9][0-9]"
cAz"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9][0-9]"
Az"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9][0-9][0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9]"
Az"[0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9][0-9][0-9][0-9]"
Az"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
Az"[0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9]"
Az"[0-9][0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Az"[0-9][0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9]"
Az"[0-9][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][0-9][0-9][0-9]"
Az"[£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*][£!$@#%?.:^&()+_-={}|\[\]\;',/<>`~*]"
Useful LinksPentest PayloadsCheat Sheets