Module 3 · Cryptography and PKI · Lesson 28 of 42
Lab: cracking Linux password hashes with John the Ripper
Hands-on in Kali Linux: read /etc/passwd and /etc/shadow, combine them with unshadow, and recover weak passwords from a wordlist using John the Ripper.
In this lesson · about 18 minutes
- Find where Linux stores account information and password hashes
- Combine /etc/passwd and /etc/shadow with the unshadow command
- Run John the Ripper against a wordlist and read the cracked passwords
- State the authorization a password-cracking test requires
Linux keeps account details in two files that work together. /etc/passwd lists each account (username, home directory, shell) but not the password hash. The hash lives in /etc/shadow, which only root can read. Separating them means ordinary programs can look up account info without ever touching the hashes.
John the Ripper is a free password cracker built into Kali. To use it you first merge the two files with the unshadow command, then point John at a wordlist such as rockyou.txt (a famous list of millions of leaked passwords that ships with Kali). In this lab you'll crack a deliberately weak account called user1.
Hands-on lab (simulated terminal)
Crack a weak account with John the Ripper
You're logged in to Kali as the kali user. Reading /etc/shadow and running the tools needs sudo, and the first time you use it sudo asks for your password: on the default Kali image it's kali. Nothing appears while you type it, just like a real terminal.
Step 1 of 6. Type each command and press Enter. Nothing runs on your computer.
1. Show the last 10 lines of the account file /etc/passwd.
Notice how fast this was, and why: both passwords were simple, common and sitting in the wordlist (even Pa$$w0rd, with its symbol-for-letter swaps, is a well-known pattern that wordlists include). The whole attack also depended on first getting hold of the hashes, which here meant root access to /etc/shadow. The lesson for defenders is the one from the previous lesson: enforce long, non-dictionary passwords (so they're not in any wordlist), rely on salting and strong key stretching, and protect the hash files in the first place.
Check your understanding0 of 4 correct
Quiz score: 0 of 4
Noviq Academy is free and for learning. This course is independent and is not affiliated with or endorsed by CompTIA. CompTIA and Security+ are trademarks of CompTIA, Inc. Exam details such as price and policies change; confirm them on CompTIA's website before you book.