Lecture 5 - Password Cracking Workshop
Overview
Related
- Post-exploitation, the interesting work is often offline.
- Once you have looted a password hash from a compromised machine, you can crack it on your own hardware, at your own pace.
- This walkthrough uses John the Ripper, pre-installed on Kali, against the rockyou wordlist that Kali also bundles.
- Everything below runs locally against hashes you generate or own.
Analogy Cracking online is like trying every key on a locked front door while a neighbour watches and calls the police after 3 tries. Cracking offline is like taking the lock home and trying millions of keys in your garage with nobody watching.
1. Prepare rockyou (one-time)
- Kali ships the wordlist gzipped, so decompress it once:
sudo gunzip /usr/share/wordlists/rockyou.txt.gz
wc -l /usr/share/wordlists/rockyou.txt- If it reports that the
.gzfile does not exist, rockyou is already decompressed — you are good to go.
2. Create a Target Hash
- This stands in for something you would pull off a compromised box.
- A deliberately weak password is used here so it cracks instantly.
- The
-6flag produces a SHA-512 crypt hash — the same$6$format used in/etc/shadow.
HASH=$(openssl passwd -6 'iloveyou')
echo "victim:$HASH" > loot.txt
cat loot.txt # victim:$6$....3. Crack It
- John auto-detects the hash type — no need to specify it.
- Since
"iloveyou"sits near the top of rockyou, this lands in well under a second.
john --wordlist=/usr/share/wordlists/rockyou.txt loot.txt4. Read the Result
john --show loot.txt # victim:iloveyou- John caches cracks in
~/.john/john.pot, so re-running step 3 will report "No password hashes left to crack." - To reset, delete the pot file:
rm ~/.john/john.pot5. The Realistic Version (Dumping /etc/shadow)
- This is what the slide is actually about.
- Post-exploitation, you have dumped
/etc/shadowfrom a box you own, but Kali usesyescrypt. - Combine
passwdandshadow, then crack:
sudo unshadow /etc/passwd /etc/shadow > shadow_hashes.txt
john --format=crypt --wordlist=/usr/share/wordlists/rockyou.txt shadow_hashes.txt
john --show shadow_hashes.txt- This only lands hits on accounts whose passwords are actually in rockyou, so you could:
cp /usr/share/wordlists/rockyou.txt ~/rockyou-demo.txt && sed -i '1ikali' ~/rockyou-demo.txtWarning Do
not use >> here — it would add to the end of the file instead of the beginning where you want your test password.
6. Same Thing in Hashcat
- Hashcat is also pre-installed.
- Note it wants just the hash, with no
"victim:"prefix. - Mode
1800is SHA-512 crypt.
echo "$HASH" > hash_only.txt
hashcat -m 1800 hash_only.txt /usr/share/wordlists/rockyou.txtWhy One Credential Unlocks So Much More
- You are cracking it offline, on your own hardware, with no account lockout and nothing logging the attempts.
- People reuse passwords.
- The admin whose workstation hash you cracked may have used the same one (or
"iloveyou2") on the VPN, the database, and the domain admin account. - One offline crack becomes lateral movement, and lateral movement becomes the whole environment.
The breach is not the finish line, it is the pivot.