Commands / Passwords and hashes

Passwords and hashes

john

Also john the ripper, password cracker, jtr, hash cracker

Cracks a password hash by hashing candidate passwords until one matches, with wordlists and mangling rules.

John the Ripper takes a hash file (from gpg2john, unshadow and many other extractors) and tries candidate passwords against it. --wordlist=FILE reads candidates from a list; --rules mangles each one as it goes — capitalise, append digits, swap letters — so a list of base words covers the shapes people actually use. An inline rule, --rules=:'cAz"2019!"', says: capitalise the word (c) and append the literal 2019! (Az"…"), turning zephyr into Zephyr2019!. john --show FILE prints what has cracked so far. Slow hashes (a gpg S2K) manage only tens of guesses a second, so a small, well-aimed wordlist with the right rule beats a huge generic one. Reach for john on the formats its extractors produce; a raw unsalted hash is hashcat's speed domain.

john command usage

john [--wordlist=FILE] [--rules[=NAME|:INLINE]] [--format=NAME] [--max-candidates=N] HASHFILE
john --show HASHFILE

Options

--wordlist=profiled.txt
read candidate passwords from this file
--rules=:'cAz"2019!"'
an inline mangling rule: capitalise each word, then append 2019!
--show
print the passwords cracked for this hash file so far
--max-candidates=300
stop after this many guesses (bound a slow run)
--format=gpg
force the hash format, when autodetect is ambiguous

john examples

john --wordlist=profiled.txt --rules=:'cAz"2019!"' backup.hash
Cracks the hash with a profiled wordlist, mangling each word into the house pattern.
Zephyr2019!      (finance-FY2019-Q4)
1 password hash cracked
john --show backup.hash
Prints the passphrase john has recovered for the hash.
john --wordlist=/usr/share/wordlists/rockyou.txt backup.hash
Tries the generic rockyou list against the hash.
john --wordlist=/usr/share/wordlists/rockyou.txt --max-candidates=300 backup.hash
Samples the top of rockyou against a slow hash and stops early.

Pitfalls

  • john caches cracked results in its pot file: a second run says No password hashes left to crack and --show reads the earlier hit, not a fresh crack.
  • A $gpg$ hash is john's job, not hashcat's: pick the cracker that supports the format the extractor produced.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab