Skip to content

john - John the Ripper Password Cracker ​

John the Ripper is a fast password cracker, currently available for many flavors of Unix, Windows, DOS, and OpenVMS. Its primary purpose is to detect weak Unix passwords, but it supports various password hash types and can be extended with custom modules.

🎯 Purpose ​

  • Password Auditing: Test password strength in organizations
  • Hash Cracking: Crack various password hash formats
  • Security Assessment: Identify weak passwords in systems
  • Forensic Analysis: Recover passwords from evidence

πŸš€ Basic Usage ​

Basic Password Cracking ​

bash
# Crack shadow file
john /etc/shadow

# Crack with specific wordlist
john --wordlist=/usr/share/wordlists/rockyou.txt /etc/shadow

# Show cracked passwords
john --show /etc/shadow

Hash Format Detection ​

bash
# Auto-detect hash format
john hashfile.txt

# Specify hash format
john --format=MD5 hashes.txt

# List available formats
john --list=formats

πŸ”§ Attack Modes ​

Dictionary Attack ​

bash
# Basic dictionary attack
john --wordlist=passwords.txt hashes.txt

# External wordlist
john --wordlist=/usr/share/wordlists/rockyou.txt --format=MD5 hashes.txt

# Multiple wordlists
john --wordlist=dict1.txt,dict2.txt hashes.txt

Incremental Mode (Brute Force) ​

bash
# Default incremental mode
john --incremental hashes.txt

# Specific character set
john --incremental=alpha hashes.txt

# Custom incremental mode
john --incremental=digits --min-length=4 --max-length=8 hashes.txt

Rule-Based Attack ​

bash
# Use built-in rules
john --wordlist=passwords.txt --rules hashes.txt

# Specific rule set
john --wordlist=passwords.txt --rules=jumbo hashes.txt

# Custom rules
john --wordlist=passwords.txt --rules=single hashes.txt

🎯 Common Hash Formats ​

Unix/Linux Systems ​

bash
# Traditional DES crypt
john --format=DES /etc/shadow

# MD5 crypt
john --format=MD5crypt /etc/shadow

# SHA-256 crypt
john --format=SHA256crypt /etc/shadow

# SHA-512 crypt
john --format=SHA512crypt /etc/shadow

Windows Systems ​

bash
# LM hashes
john --format=LM ntlm.txt

# NTLM hashes
john --format=NT ntlm.txt

# Extract from SAM
samdump2 SYSTEM SAM > sam.txt
john sam.txt

Application Hashes ​

bash
# MySQL passwords
john --format=mysql mysql_hashes.txt

# PostgreSQL passwords
john --format=postgres postgres_hashes.txt

# ZIP archives
zip2john encrypted.zip > zip.hash
john zip.hash

# PDF files
pdf2john encrypted.pdf > pdf.hash
john pdf.hash

πŸ“ Installation ​

Debian/Ubuntu ​

bash
sudo apt update
sudo apt install john

From Source (Jumbo Community Version) ​

bash
git clone https://github.com/openwall/john.git
cd john/src
./configure
make
sudo make install

Snap Package ​

bash
sudo snap install john-the-ripper

βš™οΈ Configuration ​

Custom Rules ​

Create custom rules in john.conf:

ini
[List.Rules:Custom]
# Append numbers 0-99
$[0-9]$[0-9]
# Capitalize first letter
c
# Add year
$2$0$2$3

Character Sets ​

bash
# Define custom character sets
[Incremental:Custom]
File = $JOHN/custom.chr
MinLen = 4
MaxLen = 8
CharCount = 62

πŸ’‘ Pro Tips ​

Hash Extraction ​

bash
# Extract hashes from various file types
unshadow /etc/passwd /etc/shadow > combined.txt
rar2john encrypted.rar > rar.hash
office2john document.docx > office.hash

Session Management ​

bash
# Save session
john --session=mysession hashes.txt

# Restore session
john --restore=mysession

# Status check
john --status=mysession

Optimization ​

bash
# Use all CPU cores
john --fork=4 hashes.txt

# Show statistics
john --test

# Benchmark formats
john --test --format=MD5

Combining with Other Tools ​

bash
# Use with hashcat potfile
john --pot=hashcat.potfile --show hashes.txt

# Generate wordlists
john --stdout --wordlist=base.txt --rules > generated.txt

πŸ”§ Advanced Features ​

Custom Wordlist Generation ​

bash
# Generate passwords from base words
echo "password" | john --stdout --rules=jumbo > custom_wordlist.txt

# Create targeted wordlist
john --stdout --incremental=digits --min-length=4 --max-length=8 > digits.txt

Mask Attack (Community Version) ​

bash
# Mask-based attack
john --mask='?a?a?a?a?a?a' hashes.txt

# Custom mask
john --mask='password?d?d?d' hashes.txt

External Mode ​

bash
# Use external mode for complex generation
john --external=AutoAbort hashes.txt

🚨 Important Notes ​

  • Legal Authorization: Only test passwords you own or have explicit permission to audit
  • Resource Usage: Incremental mode can be very CPU intensive
  • Time Management: Some attacks may run for days or weeks
  • Backup Results: Regularly save cracked passwords using --show
  • Format Detection: Always verify the correct hash format is being used

πŸ“Š Performance Tips ​

  • Use --fork for multi-core systems
  • Start with dictionary attacks before brute force
  • Use rules to maximize wordlist effectiveness
  • Monitor progress with --status
  • Consider hybrid approaches combining multiple tools

Part of the HackerHub.me tool documentation series