| name | john |
| description | John the Ripper — cracking de mots de passe CPU, formats de hash, modes d'attaque (single/wordlist/incremental), règles de mutation, unshadow, zip2john, et workflows de pentest. |
John the Ripper — Guide Complet
Présentation
John the Ripper (JtR) est un cracker de mots de passe open-source optimisé pour le CPU. Complémentaire à Hashcat (GPU).
Éditions :
- Community (
john) — version open-source standard
- Pro (
john-pro) — version commerciale (plus de formats)
- Jumbo (
john-jumbo) — version communauté avec tous les formats
Installation :
sudo apt install john
sudo apt install john-data
git clone https://github.com/openwall/john.git
cd john/src && ./configure && make -s clean && make -sj4
Modes d'attaque
Mode Single (crack simple)
john --single hash.txt
Mode Dictionnaire (wordlist)
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
john --wordlist=rockyou.txt --rules hash.txt
john --wordlist=rockyou.txt --rules=best64 hash.txt
john --wordlist=rockyou.txt --rules=KoreLogicRules hash.txt
john --wordlist=rockyou.txt --rules=Jumbo hash.txt
john --wordlist=dict1.txt hash.txt
john --wordlist=dict2.txt hash.txt
Mode Incremental (bruteforce)
john --incremental hash.txt
john --incremental=LowerNum hash.txt
john --incremental=All hash.txt
john --incremental --min-length=6 --max-length=8 hash.txt
Mode Markow (probabiliste)
john --markov hash.txt
Mode masque (comme Hashcat)
john --mask='?l?l?l?l?l?d?d' hash.txt
john --mask='?u?l?l?l?l?d?d?d' hash.txt
Formats de hash
Formats courants
john --list=formats | tr ',' '\n' | grep -i nt
john --list=formats | tr ',' '\n' | grep -i md5
raw-md5
raw-sha1
raw-sha256
nt
lm
descrypt
bsdicrypt
md5crypt
sha256crypt
sha512crypt
bcrypt
krb5tgs
krb5asrep
mscash2
Spécifier le format
john --format=raw-md5 hash.txt
john --format=nt hash.txt
john --format=krb5tgs hash.txt
john --format=sha512crypt hash.txt
Outils de conversion (2john)
unshadow /etc/passwd /etc/shadow > hashes_unshadowed.txt
zip2john archive.zip > zip_hash.txt
rar2john archive.rar > rar_hash.txt
rar2john -5 archive.rar > rar5_hash.txt
pdf2john document.pdf > pdf_hash.txt
ssh2john id_rsa > ssh_hash.txt
keepass2john database.kdbx > keepass_hash.txt
d2john office.docx > office_hash.txt
office2john office.docx > office_hash.txt
bitlocker2john image.dd > bitlocker_hash.txt
truecrypt_volume2john volume.tc > tc_hash.txt
keychain2john login.keychain > keychain_hash.txt
androidfde2john footer.bin > android_hash.txt
pfx2john certificate.pfx > pfx_hash.txt
ls /usr/share/john/*2john*
ls /opt/john/run/*2john*
Règles de mutation
Règles intégrées
john --list=rules | head -20
john --wordlist=rockyou.txt --rules=best64 hash.txt
john --wordlist=rockyou.txt --rules=d3ad0ne hash.txt
john --wordlist=rockyou.txt --rules=T9X hash.txt
john --wordlist=rockyou.txt --rules=Jumbo hash.txt
Syntaxe des règles
[List.Rules:monRule]
$1$2$3
c$!
sa4
se3
so0
ss5
d
T1
$2$0$2$4
Tester les règles
john --wordlist=test.txt --rules=monRule --stdout
Gestion des sessions
Sauvegarde et restauration
john --restore
john --restore=monNomDeSession
john --status
john --session=projet1 --wordlist=rockyou.txt hash.txt
Fichier POT (résultats trouvés)
john --show hash.txt
john --show --format=nt hash.txt
john --pot=/path/potfile.txt ...
john --show=left hash.txt
Optimisation CPU
Options de performance
john --fork=8 hash.txt
john --max-memory=2048 hash.txt
john --wordlist=rockyou.txt --fork=$(nproc) hash.txt
Profilage
john --test=0
john --test --format=raw-md5
john --incremental --max-candidates=1000000 hash.txt
Wordlist mangling (Loopback)
john --wordlist=rockyou.txt hash.txt
john --loopback --rules hash.txt
External Mode (scripts custom)
[List.External:FilterNumbers]
void filter()
{
int i, c;
i = 0;
while (c = word[i++]) {
if (c >= '0' && c <= '9')
return; // Skip words with numbers
}
}
john --external=FilterNumbers hash.txt
Unicode / Non-ASCII
john --encoding=utf8 hash.txt
john --wordlist=rockyou.txt --rules --encoding=utf8 hash.txt
Scénarios de pentest
1. Unix /etc/shadow complet
unshadow /etc/passwd /etc/shadow > unshadowed.txt
john --single unshadowed.txt
john --wordlist=rockyou.txt unshadowed.txt
john --wordlist=rockyou.txt --rules unshadowed.txt
john --show unshadowed.txt
2. Windows NTLM
impacket-secretsdump DOMAIN/user:password@192.168.1.10
john --format=nt --wordlist=rockyou.txt ntlm_hashes.txt
john --format=lm lm_hashes.txt
john --show --format=lm lm_hashes.txt
3. Kerberoasting (AD)
impacket-GetUserSPNs DOMAIN/user:password@dc.local -outputfile kerb_hashes.txt
john --format=krb5tgs --wordlist=rockyou.txt kerb_hashes.txt
john --format=krb5tgs --wordlist=rockyou.txt --rules kerb_hashes.txt
4. AS-REP Roasting
impacket-GetNPUsers DOMAIN/ -dc-ip 192.168.1.10 -request -format john
john --format=krb5asrep --wordlist=rockyou.txt asrep_hashes.txt
5. Document protégé
zip2john document.zip > zip.hash
john --wordlist=rockyou.txt zip.hash
pdf2john document.pdf > pdf.hash
john --wordlist=rockyou.txt pdf.hash
keepass2john database.kdbx > kp.hash
john --wordlist=rockyou.txt kp.hash
6. SSH Private Key
ssh2john id_rsa > ssh.hash
john --wordlist=rockyou.txt ssh.hash
john --show ssh.hash
Différences clés Hashcat vs John
| Fonctionnalité | Hashcat | John |
|---|
| Hardware | GPU (très rapide) | CPU (optimisé) |
| Format output | Format spécifique | 2john scripts |
| Rules | Fichier .rule distinct | Config john.conf |
| Sessions | --session | --restore |
| Loopback | --loopback | --loopback |
| Incremental | Masque -a 3 | --incremental |
| Unicode | Bof | Bon support |
| Format 2john | Outils séparés | Intégré (jumbo) |
| Performance NTLM | 100 GH/s (RTX 4090) | 100 MH/s (32 cores) |
| bcrypt | 50 KH/s | 5 KH/s |
Dépannage
| Problème | Solution |
|---|
| "No password hashes loaded" | Vérifier le format : --format=nt |
| "Unknown format" | Utiliser la version Jumbo (plus de formats) |
| "Too few characters" | Réduire min-length |
| "Session expired" | john --restore pour reprendre |
| Décès / Ctrl+C | La session est automatiquement sauvegardée |
Antisèche rapide
john hash.txt
john --wordlist=rockyou.txt hash.txt
john --wordlist=rockyou.txt --rules hash.txt
john --show hash.txt
unshadow passwd shadow > unshadowed.txt
zip2john archive.zip > hash.txt
ssh2john id_rsa > hash.txt
john --format=nt --wordlist=rockyou.txt hashes.txt
john --fork=$(nproc) --wordlist=rockyou.txt hash.txt
john --incremental --min-length=6 --max-length=8 hash.txt
john --loopback --rules hash.txt