22.3 John the Ripper: Cracking Hashes
John the Ripper ("John") cracks captured hashes offline. It auto-detects many hash types.
# Linux: combine passwd and shadow into one file John understands (root/lab only)
sudo unshadow /etc/passwd /etc/shadow > hashes.txt
# wordlist attack
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
# with mutation rules
john --wordlist=/usr/share/wordlists/rockyou.txt --rules hashes.txt
# show cracked results
john --show hashes.txt
# tell John the format if it guesses wrong
john --format=sha512crypt --wordlist=rockyou.txt hashes.txt
John also has helper tools such as zip2john file.zip > zip.hash and ssh2john id_rsa > key.hash to turn protected files and keys into crackable hashes (lab only).
Ravindra Bagale's Tip
John keeps running in the background, and students press Ctrl+C to stop it, then say "nothing happened". Use john --show to see earlier results, and while it is running, pressing any key shows the status – it does not stop. Be patient.
Ravindra Bagale's Tip – मराठी
John background मध्ये चालू असतो आणि students Ctrl+C दाबून बंद करतात, मग "काही झालं नाही" म्हणतात. john --show ने आधीचे results बघा, आणि चालू असताना कोणतीही key दाबली तर status दिसतो – बंद होत नाही. Patience ठेवा.
Ravindra Bagale's Tip – हिंदी
John background में चलता रहता है और students Ctrl+C दबाकर बंद कर देते हैं, फिर कहते हैं "कुछ नहीं हुआ". john --show से पुराने results देखो, और चलते समय कोई भी key दबाओ तो status दिखता है – वह बंद नहीं होता. Patience रखो.
Lab
On Metasploitable 2 (or your own lab Linux VM), run sudo unshadow and crack the hashes with John using rockyou.txt and --rules. List which accounts cracked and how long each took. Then set a long random password on one account and confirm John cannot crack it quickly.
John as a defender's lab tool
Cracking hashes from your own password dump (exported from a lab app) shows you which users chose weak passwords. Then you force a reset and teach better policy.
- Export hashes only from a lab database you own.
- Run John offline on your Kali VM.
- List cracked passwords.
- Add policy: minimum length, breached-password check (Have I Been Pwned API), and 2FA.
Real examples
Indian company (sample): an HR portal forced resets for 180 accounts whose hashes cracked in under a minute. Global: NIST and NCSC password guidance favour length and screening against known-breached passwords over frequent forced rotation.
Common mistakes
- Cracking hashes stolen from somewhere else. That is illegal.
- Sharing cracked password lists.
Recap
- Crack only your lab hashes.
- Use the result to improve policy, not to attack people.
Defender's worksheet (do this today)
- Write the lesson title and date in your notebook.
- List three systems you own (VMs, personal projects, or lab apps) where this lesson applies.
- Run one safe command or checklist item from the lesson on a lab system only.
- Paste the command and its output under an Evidence heading.
- Write one fix you would give a teammate in two sentences.
- Write one mistake students make with this topic and how to avoid it.
More real-world pictures
Indian workplace (sample data)
Suppose we are a junior analyst at Tech Mahindra supporting a client SOC. After reading this lesson you add one detection or one hardening item to the team weekly checklist, with the owner name and a due date. That is how learning becomes operations.
Global practice
Public bodies such as CERT-In (India), CISA (US) and NCSC (UK) publish advisories that map to the same ideas: patch, least privilege, logging and user awareness. Bookmark one advisory feed and read it every Monday.
Home and family
Explain this lesson to a family member in four sentences without jargon. If they can repeat the main warning back to you, you understand it well enough to teach.
Connect to earlier chapters
Parts 1 to 9 built Linux, web servers, databases and cloud pieces. This lesson only makes sense when you can point to a concrete config file, package name or architecture box from those parts. If you cannot, revisit the matching earlier chapter before you practise any tool command.
Common mistakes
- Skipping written permission just for a quick scan.
- Practising on hostel or office Wi-Fi targets without authorisation.
- Collecting tool output without writing the fix.
- Copying exploit commands onto production to verify. Verification for defenders means checking versions and patches, not firing modules.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Teach one other person the warning from this lesson.