Crack Password Hashes with John the Ripper

Learn to crack password hashes using John the Ripper — Ethical Hacking lesson 43 covers core concepts, step-by-step walkthrough, troubleshooting, and what to study next.

Focus: crack password hashes using john the ripper

Sponsored

Picture this: You've just captured a set of password hashes from a compromised Linux server — the kind of trophy every penetration tester dreams of. But now what? Staring at a wall of $6$salt$hash isn't progress; it's a dead end unless you can turn those hashes back into plaintext passwords. That's exactly where John the Ripper (John) earns its keep. It's the Swiss Army knife of password cracking, designed to take those unreadable hashes and methodically grind them down to the original passwords, letting you prove — with undeniable evidence — just how weak that 'secure' infrastructure really is. In this lesson, you'll move from paralysis to action: you'll master how to crack password hashes using John the Ripper, whether they're from Linux shadow files, Windows SAM dumps, or even ZIP archives, and you'll do it with the precision of a professional ethical hacker.

The problem this lesson solves

Most modern systems don't store passwords in plaintext — they store hashes. A hash is a one-way cryptographic function that takes any input (like a password) and produces a fixed-size string of gibberish. The problem? When you, as an ethical hacker, find a dump of hashes, they're worthless unless you can reverse the process. But hashing is mathematically irreversible — you can't 'decode' a hash back to the password. So what's a hacker to do?

The answer is cracking. You take a guess at a password, hash it, and compare it to the target hash. If it matches, you've found the password. The pain point is speed and efficiency: doing this manually is impossible, and even a naive script can be too slow with millions of combinations. John the Ripper solves this with optimized cracking modes, GPU support, and support for dozens of hash types. This lesson is your hands-on guide to cracking password hashes using John the Ripper, turning a static hash dump into a clear, actionable finding for your penetration test report.

Core concept / mental model

Think of a hash as a padlock on a treasure chest. Every password is a key that could unlock it, but you don't have the original key. Cracking is like trying every key you can find or make until one turns the lock. John the Ripper is your automated keymaker and tester — it doesn't break cryptography; it just tries huge numbers of keys faster than any human.

Here's the mental model to keep in mind:

  • Hash: The locked chest — a fixed-length string that looks random.
  • Wordlist: A collection of likely keys — common passwords, leaked lists, dictionary words.
  • Rules: Transformations applied to wordlist entries to create more keys (e.g., appending '123', capitalizing the letter).
  • Mangling: The process of applying rules to words to generate new guesses.
  • Mode: The strategy John uses to generate guesses — from a wordlist, permutations, or brute force.

John's genius is that it doesn't just throw wordlist passwords at the hash; it mangles them. For example, if 'admin' is in the wordlist, John will try 'admin', 'Admin', 'admin1', 'admin!', '.admln', and thousands more, based on rules. This dramatically expands your attack surface without needing a massive list.

How it works step by step

  1. Identify the hash format. John needs to know how to interpret the hash string. Common formats: $6$ for SHA-512 (Linux shadow), $1$ for MD5 (older systems), $2y$ for bcrypt, and NTLM for Windows.
  2. Prepare a hash file. You must put the hashes in a format John understands. For a single hash, you can typically paste it into a file with a username prefix if needed.
  3. Choose a cracking mode. John has two primary modes: - Wordlist mode: Uses --wordlist=file.txt to feed John a list of candidate passwords. It applies rules to each word. - Incremental mode (brute-force): Uses --incremental to try all possible combinations of characters up to a length. This is much slower but catches passwords not in any list.
  4. Run John. The basic command is john --format=<hash-type> --wordlist=<wordlist> hashfile. John automatically detects the format in many cases, but specifying it speeds up the process.
  5. Wait and watch. John outputs cracked passwords to the console and stores them in the ~/.john/john.pot file. You can press Enter to see current status.
  6. Show results. Use john --show hashfile to display all cracked hashes along with their plaintext passwords.

Let's break it down with a concrete example in the next section.

Hands-on walkthrough

Let's crack a real-world shadow hash. In this example, we have a hypothetical shadow file line:

root:$6$salt123$abcdefghijklmnopqrstuvwxyz1234567890:

Save it to hash.txt. Now, we'll use John with the --format flag and a standard wordlist. On Kali Linux, the default wordlist is rockyou.txt, located at /usr/share/wordlists/rockyou.txt (extract it first if needed).

# Extract rockyou if not already done
sudo gunzip /usr/share/wordlists/rockyou.txt.gz

# Run John with wordlist mode
john --format=sha512crypt --wordlist=/usr/share/wordlists/rockyou.txt hash.txt

Expected output (when cracked):

Loaded 1 password hash (sha512crypt [SHA512 256/256 AVX2 4x])
Press 'q' or Ctrl-C to abort, almost any other key for status
password123      (root)
1g 0:00:00:05 DONE (2023-01-01 12:00) 0.2000g/s 12345p/s 12345c/s 12345C/s password..secrets
Use the "--show" option to display all of the cracked passwords reliably

To view cracked passwords later:

john --show hash.txt

Now, what if your hash is a Windows NTLM hash? You'd use --format=nt. Here's a second example:


# Create a file with NTLM hash
cat > ntlm_hash.txt << EOF
administrator:550e8400e29b41d4a716446655440000
EOF

john --format=nt --wordlist=/usr/share/wordlists/rockyou.txt ntlm_hash.txt

And for older MD5 crypt (usually found on older Unix):

john --format=md5crypt --wordlist=/usr/share/wordlists/rockyou.txt md5_hashes.txt

Pro tip: If you don't specify a format, John tries to guess it, but explicit is faster. Use john --list=formats to see all supported formats.

Compare options / when to choose what

John the Ripper isn't the only game in town. Two major alternatives are Hashcat and CrackStation (online). Here's a comparison:

Tool Speed Hash Support GPU Use Stealth Best For
John the Ripper Fast (CPU), moderate GPU 100+ formats Yes (with build) High (CLI, no cloud) Local, offline cracking; direct integration with Unix tools
Hashcat Very fast (GPU-optimized) 300+ formats Excellent High High-speed GPU cracking, large wordlists/rules
Online services (e.g., CrackStation) Instant for known hashes Limited N/A Low (hashes sent off-site) Quick lookup of common hashes, no setup

When to choose John: When you need a reliable tool that's preinstalled on Kali, works over SSH easily, and you have a mix of hash types John recognizes. It's also fantastic for quick and dirty cracking of small sets.

When to choose Hashcat: When you have a powerful GPU rig and need to crack complex hashes fast. Hashcat's rule engine is more flexible, and it can leverage multiple GPUs.

When to avoid online services: Always. Sending hashes to third parties is a security risk — a breach inside their service could leak sensitive data. Also, it's against the principle of controlled testing.

Troubleshooting & edge cases

John says "No password hashes loaded"

  • Check the hash format: Ensure the hash is in a format John can parse. For shadow files, use the unshadow tool to combine passwd and shadow before feeding to John. For NTLM from SAM, use secretsdump.py to extract in the correct format.
  • Verify the file encoding: John expects lines like username:hash. If there's no username, it might still work, but provide one to be safe.
  • Use --format to skip detection: John might fail to auto-detect. Explicitly set --format=sha512crypt or --format=nt.

Cracking is too slow

  • Switch to incremental mode: Try --incremental if you suspect the password is short (less than 8 chars).
  • Enable GPU: If your John build supports it, use --device=0 to offload to GPU. This can be 100x faster.
  • Add rules: Wordlist mode with rules increases password coverage. Use --rules=All (John’s default). For more aggressive, try --rules=Jumbo if available.
  • Limit character set: For incremental mode, specify --incremental=Digits or --incremental=Lower to reduce search space.

John prints "Use the --show option" — where are the results?

  • John saves cracked passwords to the john.pot file (in ~/.john/). Use john --show hashfile to see them. It's a best practice to always review with --show.

Hash is unsupported

  • Run john --list=formats to check if the hash is supported. If not, consider converting it with tools like hashcat's hash-type detection, or using a specific John package like Jumbo (which supports many more formats).

Encountering "Could not open file" permission errors

  • Ensure you have read/write permissions on the hash file and wordlist. Use chmod or run with sudo only if necessary — but be careful about shell history.

What you learned & what's next

You've now got the power to crack password hashes using John the Ripper. You understand the core concept of hashing vs. cracking, how to prepare hashes for John, run a wordlist attack, and interpret the results. You can also compare John with other tools and troubleshoot common issues. You've met both learning objectives: explaining the core idea and completing a practical exercise.

Where to go next? In the next lesson in this track, you'll likely move into post-exploitation — maybe learning to pivot or maintain access. Or you might explore cracking other types of passwords like ZIP or RAR archives with John, or even extend your wordlist with custom rules. Also, consider reading the john man page (man john) for more advanced options like --external modes and loopback attacks. Your journey into ethical hacking continues — keep cracking, but always ethically!

Practice recap

Grab a sample SHA-512 hash from the shadow file of your own test VM and crack it with rockyou.txt. Then, try extracting a hash from a test ZIP file using zip2john and crack that. Finally, run john --show to review all cracked passwords and reflect on how John's speed improves your testing efficiency.

Common mistakes

  • Forgetting to use unshadow for Linux shadow files: John requires a username:hash pair, and unshadow passwd shadow > hashes.txt combines them correctly.
  • Not specifying a format: John auto-detection fails on unusual hash types, leading to 'No password hashes loaded.' Always use --format when possible.
  • Using an empty wordlist or not extracting rockyou.txt.gz before running, which causes a 'cannot open wordlist' error.
  • Expecting brute-force to be fast: Without GPU, John is CPU-bound; incremental mode with long passwords takes eons. Use wordlists and rules first.

Variations

  1. Use Hashcat as an alternative: It offers GPU acceleration and supports more hash types, but requires a separate tool and more manual configuration.
  2. Try John's incremental mode (--incremental) instead of wordlists for short passwords, but beware of time complexity.
  3. Leverage John's rule engine with custom rules (--rules=Common) to expand wordlist coverage without loading huge files.

Real-world use cases

  • Penetration testing a corporate network: Extract NTLM hashes from a Windows domain and crack them to demonstrate weak password policies to the client.
  • Auditing Unix server security: Use unshadow and John to test whether system accounts have easily guessable passwords, then advise on hardening.
  • Recovering a lost password from an encrypted ZIP file: Export the hash with zip2john and crack it to regain access to an archived dataset.

Key takeaways

  • Cracking is not breaking hashes; it's trying many guesses and matching hashes — speed and wordlist quality matter.
  • Always identify the hash type and use the correct --format flag to avoid load failures.
  • Wordlist mode with rules is the first approach; incremental mode is a last resort due to time.
  • John stores cracked passwords in john.pot; use --show to retrieve them reliably.
  • Compare John, Hashcat, and online services carefully; offline tools with local control are safer for testing.
  • Ethics matter: only crack hashes you own or have explicit permission to test.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.