John the Ripper¶
1. Basic Syntax¶
Command Structure:
-
john→ Runs John the Ripper -
[options]→ Flags that control cracking mode, wordlists, formats, etc. -
[file path]→ File containing the hash you want to crack (no path needed if in same directory).
Example:
2. Automatic Cracking¶
Uses a given wordlist to try passwords against the hash file.
Syntax:
Example:
3. Identifying Hashes¶
Sometimes John cannot detect hash type automatically.
Tool: hash-identifier (Python-based).
Usage:
Enter hash → tool suggests possible hash types.
Example Output:
4. Format-Specific Cracking¶
If you know the hash type, specify it using --format.
Syntax:
Example:
Tip:
List all formats:
5. NTHash / NTLM Cracking¶
-
Used by Windows in
SAMdatabase orNTDS.dit. -
Can be cracked or used in Pass-the-Hash attacks.
Syntax:
6. Cracking /etc/shadow Passwords¶
/etc/shadow → Stores hashed passwords (root-only access).
Requires combining with /etc/passwd using unshadow.
Unshadow Command¶
Example:
Cracking the Unshadowed File¶
7. Single Crack Mode & Word Mangling¶
-
Uses username and GECOS field info to generate guesses.
-
Mangling = changing words slightly (adding numbers, symbols, case change).
Syntax:
File Format:
Instead of:
Write:
Example:
8. Custom Rules¶
Rules define password patterns John should try.
Location: /etc/john/john.conf or /opt/john/john.conf
Example Rule: For passwords like Polopassword1!
-
c→ Capitalise first letter -
Az→ Append characters -
[0-9]→ Any number -
[!£$%@]→ Any listed symbol
Run with Rule:
9. Cracking Archive Files¶
ZIP Files – zip2john¶
Convert ZIP to John-readable hash:
Crack:
RAR Files – rar2john¶
Convert RAR to hash:
Crack:
10. Cracking SSH Private Key Passwords¶
ssh2john¶
Convert id_rsa private key to hash:
Crack:
11. Summary Table of Commands¶
| Purpose | Conversion Tool | Example Command |
|---|---|---|
| Crack basic hash | – | john --wordlist=rockyou.txt hash.txt |
| Format-specific cracking | – | john --format=raw-md5 --wordlist=rockyou.txt hash.txt |
| Unshadow Linux hashes | unshadow |
unshadow passwd shadow > file.txt |
| Crack ZIP file | zip2john |
zip2john file.zip > hash.txt |
| Crack RAR file | rar2john |
rar2john file.rar > hash.txt |
| Crack SSH private key | ssh2john |
ssh2john id_rsa > hash.txt |
| Single crack (word mangling) | – | john --single --format=raw-sha256 file.txt |
| Use custom rules | – | john --wordlist=rockyou.txt --rule=RuleName file.txt |