Unshadow (/etc/passwd and /etc/shadow)
Cracking Hashes from /etc/shadow
The /etc/shadow file is where Linux stores password hashes. It also holds other information, such as the date of the last password change and password expiration data, with one entry per line for each user account. The file is usually only accessible by the root user, so to get your hands on the hashes you need sufficient privileges. With them, there is a chance you can crack some of the hashes.
Unshadowing
John can be very particular about the formats it needs. To crack /etc/shadow passwords, you must combine the file with /etc/passwd so John can understand the data it's given. The John suite includes a tool called unshadow for this. The basic syntax:
unshadow [path to passwd] [path to shadow]
unshadow # Invokes the unshadow tool
[path to passwd] # The file that contains the copy of the /etc/passwd file you've taken from the target machine
[path to shadow] # The file that contains the copy of the /etc/shadow file you've taken from the target machine
Example Usage
unshadow local_passwd local_shadow > unshadowed.txt
Note on the Files
With unshadow you can use the entire /etc/passwd and /etc/shadow files if you have them, or just the relevant line from each. For example:
FILE 1 - local_passwd contains the /etc/passwd line for the root user:
root:x:0:0::/root:/bin/bash
FILE 2 - local_shadow contains the /etc/shadow line for the root user:
root:$6$2nwjN454g.dv4HN/$m9Z/r2xVfweYVkrr.v5Ft8Ws3/YYksfNwq96UL1FX0OJjY1L6l.DS3KEVsZ9rOVLB/ldTeEL/OIhJZ4GMFMGA0:18576::::::
Cracking
We can feed the output from unshadow (here called unshadowed.txt) directly into John. We shouldn't need to specify a mode, since we built the input specifically for John, but in some cases you will need to specify the format as before, using --format=sha512crypt:
john --wordlist=/usr/share/wordlists/rockyou.txt --format=sha512crypt unshadowed.txt