WarFi Labs

john the ripper

password auditing ยท GPLv2

Prove how weak a password really is, before someone with worse intentions does. The classic cracker, strong on format breadth and CPU work.

Authorized use only. Run these only on systems you own or have explicit written permission to test. Full notice at the foot of the page.

01What john is for

John the Ripper cracks password hashes: you give it hashes, it gives you back the passwords that produced them. Its particular strengths are format breadth (it understands an enormous range of hash types and can often detect them for you) and a clever default mode that applies smart rules automatically. Where hashcat is the GPU speed champion, john is the flexible, format-aware workhorse, and the jumbo build adds a huge library of hash formats and helper tools for extracting hashes from files.

↑ contents

02Install the jumbo build

You want john-the-ripper jumbo, not the bare core, because jumbo carries the extra formats and the *2john helper scripts that extract hashes from files. Most distributions package it.

$ sudo emerge app-crypt/johntheripper-jumbo # Gentoo (jumbo build)

$ sudo apt install john # Debian / Ubuntu / Kali

$ sudo dnf install john # Fedora / RHEL

03Getting hashes into a file

john reads hashes from a file, one per line, often in the format user:hash. The jumbo build includes dozens of *2john tools that pull a crackable hash out of something: a ZIP, a PDF, an SSH key, a KeePass database. This is how you audit the strength of a password protecting a file.

$ zip2john secret.zip > ziphash.txt

$ ssh2john id_rsa > keyhash.txt

$ sudo unshadow /etc/passwd /etc/shadow > linuxhashes.txt

$ cat ziphash.txt secret.zip:$pkzip2$1*2*2*0*2b*1c*...*$/pkzip2$:secret.docx $ head -1 linuxhashes.txt labuser:$6$xQ9KpR2a$3Hn8r9Jd...truncated...:1001:1001::/home/labuser:/bin/bash

04The default crack

Run john on the file with no mode and it does something smart: single-crack mode (using the username and GECOS as hints), then wordlist with its default rules, then incremental. For many weak passwords this one command is enough. Point --wordlist at a specific list to control it.

$ john linuxhashes.txt

$ john --wordlist=/usr/share/wordlists/rockyou.txt linuxhashes.txt

Using default input encoding: UTF-8 Loaded 3 password hashes with 3 different salts (sha512crypt) Press 'q' or Ctrl-C to abort, almost any other key for status summer2019 (alice) P@ssw0rd! (bob) 2g 0:00:01:14 33% (ETA 15:48) 0.02691g/s 4821p/s 9642c/s

05Seeing what cracked

Cracked passwords go into a pot file, so you do not re-crack them. --show reads the pot against your hash file and prints the recovered passwords, which is how you get the results out after a run.

$ john --show linuxhashes.txt

alice:summer2019 bob:P@ssw0rd! 2 password hashes cracked, 1 left

06Wordlist rules, the force multiplier

Real passwords are rarely a bare dictionary word; they are a word mangled: a capital, a year, a bang on the end. Rules describe those mutations so one wordlist becomes thousands of variations. john ships rule sets; --rules=jumbo is a strong, broad default that catches the human habits people actually use.

$ john --wordlist=rockyou.txt --rules=jumbo linuxhashes.txt

Using default input encoding: UTF-8 Loaded 3 password hashes with 3 different salts (sha512crypt, crypt(3) $6$) Press 'q' or Ctrl-C to abort, almost any other key for status Spring2024! (labuser) P@ssw0rd2023 (svc-backup) 2g 0:00:04:11 42% (ETA 16:58) 0.007942g/s 3120p/s 3360c/s 3360C/s

» Rules are why a 14-million-word list cracks far more than 14 million passwords: Password becomes Password1, P@ssword, Password2019, and so on.

↑ contents

07Telling john the format

john usually detects the hash type, but when a format is ambiguous you specify it with --format. --list=formats shows what it supports. Getting the format right matters, because the wrong guess cracks nothing.

$ john --list=formats | tr ',' '\n' | grep -i ntlm

$ john --format=nt ntlmhashes.txt

nt $ john --format=nt ntlmhashes.txt Loaded 2 password hashes with no different salts (NT [MD4 128/128 AVX 4x3]) Winter2024 (administrator) 1g 0:00:00:02 DONE

08When to switch to hashcat

john is CPU-first and format-rich; hashcat is GPU-first and raw-speed king. For a few hashes, file formats, or quick audits, john is often the faster path start to finish. For slow hashes at volume where you have a GPU, convert your approach to hashcat. Knowing both and picking the right one per job is the real skill.

» Use john for breadth and convenience, hashcat for GPU-scale throughput. See the hashcat guide for the latter.

09What a successful crack tells you

Run john against your own hashes and whatever falls quickly is a password that must change, and often a policy that must change with it. The point of auditing is to find the weak ones before an attacker does, and to prove to users and management, concretely, why length and uniqueness matter.

» Any password john cracks from rockyou plus rules was never strong; require length (a passphrase) over complexity theatre.

» Slow, salted hashes (bcrypt, argon2, sha512crypt) buy time; fast unsalted ones (raw MD5, NTLM) fall instantly. Store passwords with a slow, salted algorithm.

» Audit periodically; a password that was fine may appear in next year's breach wordlist.

Only crack hashes from systems you own or are authorized to assess.

↑ contents

Authorized use only

The tools and techniques in these guides are for defending, testing, and understanding systems you own or have explicit written permission to assess. Unauthorized access to computers, networks, accounts, or data is a criminal offense in nearly every jurisdiction, and the penalties are real.

A few of the laws that apply, by way of example:

Wherever you are, the rule is the same: get authorization in writing, stay within the agreed scope, and never touch a system that is not yours to test. If you are unsure whether something is permitted, treat it as not permitted until you have clear authorization.

This is general information, not legal advice.