Lab04-passwd
Lab04-passwd
Introduction
In this lab, students will become familiar with the location where Linux passwords are stored
and learn about tools and techniques for breaking Linux passwords.
Passwords help to secure systems running Linux and UNIX operating systems. If an attacker
is able to get the root password on a Linux or UNIX system, they will be able to take complete
control of that device. The protection of the root password is critical.
passwd file – User accounts on a Linux system are listed in the passwd file which is stored in
the /etc directory. The passwd file has less restrictive permissions than the shadow file because
it does not store the encrypted password hashes. On most Linux systems, any account has the
ability to read the contents of the passwd file.
shadow file – The shadow file also stores information about user accounts on a Linux system.
The shadow file also stores the encrypted password hashes, and has more restrictive
permissions than the passwd file. On most Linux systems, only the root account has the ability
to read the contents of the shadow file.
auth.log – This log file tracks SSH, or Secure Shell, connections. It provides information such
as IP addresses, and date and time stamps. It also tracks other events related to security, such
as the creation of new user's accounts and new group accounts.
John the Ripper – John the Ripper is an extremely fast password cracker that can crack
passwords through a dictionary attack or through the use of brute force.
Cracking Linux Passwords with John the Ripper
Passwords help to secure systems running the Linux operating system. If an attacker is able to
get the root password on a Linux system, they will be able to take complete control of that
device. The password hashes on a Linux system reside in the shadow file. John the Ripper is
an extremely powerful password cracker. It comes loaded by default on all versions of
BackTrack, but can be downloaded at www.openwall.com/john/.
2
seed@ubuntu:~$:john
16. Type the following command to attempt to crack the passwords with john:
seed@ubuntu:~$:sudo john /etc/shadow
Notice that even though there were only 3 different passwords in the list, the messages from
john indicated that it loaded 4 password hashes with 4 different salts. If you need to view the
password hashes and the corresponding revealed passwords at future time, you can always
retrieve them from the john.pot file where they are stored.
17. To view the password hashes and corresponding passwords, type the following:
seed@ubuntu:~$ sudo cat /root/.john/john.pot
Unfortunately, if you attempt to crack the password again, you will not have success.
18. Type the following command to attempt to crack the passwords with john
seed@ubuntu:~$ sudo john /etc/shadow
This is because hashes and their corresponding passwords are stored within the john.pot file;
john will not crack the password hash again. If you want the passwords to be cracked again,
you will need to remove the information stored in the john.pot file.
19. Type the following command to remove the existing john.pot file:
seed@ubuntu:~$ sudo rm /root/.john/john.pot
20. Type the following command to re-crack the passwords with john
seed@ubuntu:~$sudo john /etc/shadow
The first four passwords cracked were done via brute force. A brute force attack on a password
hash usually takes the longest. If a password has a large number of characters and is very
complex, the brute force attack can take a very long time. John also gives the user the ability
to utilize a password file. It comes with a password file called password.lst, located in the
/usr/share/john directory, with 3546 words in its list.
21. To view the first 20 lines of the file, type the following command in the terminal:
seed@ubuntu:~$ head -n 20 /usr/share/john/password.lst
If any account's passwords are changed, john will go through the cracking process again. We
will set chewbaca’s password to a word contained within the password.lst file.
22. Set chewbacca’s password to computer by typing computer twice after typing:
seed@ubuntu:~$ passwd chewbaca
23. Type the following to run john again and the new password hash will be loaded.
seed@ubuntu:~$ john /etc/shadow --wordlist=/usr/share/john/password.lst
Since that word was one of the first few in the dictionary, john was able to crack the password
in less than one second. Now we will try one of the last passwords in the list.
24. To view the last 20 lines of the file, type the following command in the terminal:
seed@ubuntu:~$ tail password.lst
25. Set chewbaca’s password to 1q2w3e4r by typing twice after typing:
seed@ubuntu:~$ passwd chewbaca
26. Type the following to run john again and the new password hash will be loaded:
seed@ubuntu:~$ john /etc/shadow --wordlist=/usr/share/john/password.lst
You can hit Enter during the cracking process to see which word is being tested.
3
Conclusion
In Linux, the names of the user accounts are listed in the /etc/passwd file. The hashes for the
user’s passwords are stored in the shadow file. The password hashes are salted, which means
if you give two users the same exact password, a different hash will be displayed for each.
When salting is done, you will be unable to perform a rainbow table attack. Instead, you will
need to perform a dictionary or brute force attack. John the Ripper is a password cracker that
allows an attacker to use brute force or a dictionary file to try to find the password for the hash.
All cracked passwords and their corresponding hashes will be stored in the john.pot file. Any
account changes are recorded in the auth.log file.
Submission
Play around with Hydra Password cracking Tool, try various attacking scenarios and write a
report about use cases. You should give at least 5 examples of attacks on well-known network
services. The more use cases are given, the higher mark you might get.