12 Jun 2024
An opportunity to play with root privilege and try out practical password cracking tools.
Preparation
-
Bring a USB stick to the lab to save your work
Procedure
As with last week, log in using the username l33t
and the
password opposable thumbs
.
-
Using the
/etc/passwd
and/etc/group
files, as well as theid
andfinger
commands, identify all of the "real" users (i.e., not system "users" likenobody
ormessagebus
) on your computer. How can you distinguish "real" users from system "users"? -
Gain privilege
-
Attempt to switch to the
root
user via thesu
command. Explain why this attempt fails. -
Use
sudo
to gain root privilege. Explain, with reference to the/etc/sudoers
file, why this succeeds.
-
-
Exfiltrate password hashes
-
Examine the
/etc/shadow
file. What does this contain? Using information from theshadow
manual page, what does the!
in many of the lines from/etc/shadow
mean? -
Copy the
/etc/passwd
and/etc/shadow
files to thel33t
user’s home directory and exit your root shell.
-
-
Prepare for cracking
-
Attempt to combine the information in your copies of the
passwd
andshadow
files into one file using theunshadow
command (which comes with John the Ripper). Explain, with reference to specific Unix permissions, why you receive aPermission denied
error. -
Change the permissions of
shadow
to allowunshadow
to succeed and output the results into a new file. -
What three characters does each of these password hashes start with? Using
man 5 crypt
, what does this signify? -
Copy all of the additional password hash files contained in
/usr/local/share/password-hashes
into your home directory. -
Copy the RockYou wordlist from
/usr/share/wordlists
to your home directory and extract it into a.txt
file. How many passwords does it contain?
-
-
Hashcat
-
On this system, the
hashcat
tool has been compiled to avail of your GPU (an nVidia Quadro P400). Runhashcat
in its benchmarking mode (seeman hashcat
) to evaluate how many hashes it can check per second with the followinghash-type
:-
Plain MD5
-
Salted MD5
-
Plain SHA-1
-
Salted SHA-1
-
HMAC-SHA256
-
Plain SHA-512
-
sha512crypt
(a.k.a.,SHA-512(Unix)
)
-
-
Copy the unshadowed password file into a new file called
hashes.txt
. Edit this file so that it contains only password hashes (i.e., no usernames, UIDs, shells, etc.), and that all the hashes are of the same type (sincehashcat
can’t crack more than one hash type at a time). When you’re done, there should be no colon (:
) characters in the file. Or you could do this with a one-lineawk
script… -
Crash the hashes in
hashes.txt
using thehashcat
tool, which on this system has been compiled to avail of your GPU (an nVidia Quadro P400). You may find the-O
and-r
options to be helpful… try looking at some of the rulesets in/usr/share/hashcat/rules
. Leave this tool running while you proceed to the next part of the lab; at the end of the lab report how many hasheshashcat
was able to crack (and what they were). You should find your cracking results in~/.local/share/hashcat/hashcat.potfile
.
-
-
John the Ripper
-
Run John the Ripper (
john
) against the Windows NT password file (ntlm.txt
). Use the RockYou wordlist (using the--wordlist
argument tojohn
). You may need to use the--format=XXXX
argument to help John interpret the hash, as it doesn’t include information about its format (e.g.,$6$
). Seeman john
,john --help
andjohn --list=formats
to find out howjohn
describes the NTLM (Windows NT LAN Manager) hash format. -
Use the
hashid
tool to identify the possible hash algorithms for each password hash in each of thehashN.txt
files that you copied from/usr/share/password-hashes
. Crack each password. You may benefit from the--session
argument tojohn
when running multiple instances at the same time.
-
-
Crack password-protected files (ENGI 9823 only, may be completed at home)
-
Use
zip2john
together withjohn
to crack the password forsecure.zip
. -
Use
rar2john
together withjohn
to crack the password forsecure.rar
. -
Use
ssh2john
together withjohn
to crack the passphrase for the SSH public keyid_rsa
.
-