Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Penetration testing, first steps

Lab · Medium · 2 hoursFree account

Password Cracking Lab

Identify hash types, then crack them with hashcat's attack modes and John the Ripper.

  • password-cracking
  • hashcat
  • john-the-ripper
  • ntlm
  • wordlists
  • shadow-file
On this page 13 sections
  1. ·Prerequisites
  2. ·Lab Setup
  3. 1Build a test hash set
  4. 2Match each hash to a hashcat mode
  5. Locked: Dictionary attack on the fast hashes
  6. Locked: Crack with John the Ripper
  7. Locked: Mask attack on the NTLM hash
  8. Locked: Rule-based attack on the Linux shadow hash
  9. Locked: Crack the bcrypt hash and read a benchmark
  10. Locked: Defence and Detection
  11. Locked: Check Your Work
  12. Locked: Password Cracking Cheat Sheet
  13. Locked: Clean-up

Stolen credentials drive most intrusions today, from ransomware to supply-chain breaches. Weak hashes crack on a laptop, and one reused password can give an attacker lateral movement across an entire domain. This lab builds a small set of test hashes, one of each common type, and cracks them with both hashcat and John the Ripper. Every hash here comes from a password you choose yourself. No step in this lab touches a real account.

What You'll Learn

  • Match a hash to its type from its format and length
  • Choose the right hashcat attack mode for a dictionary, mask and rule-based attack
  • Crack hashes with John the Ripper as a versatile alternative to hashcat
  • Crack NTLM, SHA-256 and Linux shadow hashes on your own test values
  • Read a hashcat benchmark and explain why a slow hash resists cracking
  • Explain Pass-the-Hash and password spraying, and where each is detected

Prerequisites

This lab assumes basic command-line comfort. No prior lab is required, but Cryptography Fundamentals covers the theory behind hashing if hashes are new to you.

Lab Setup

Use your own Kali machine (a virtual machine is fine). These tools ship with a default Kali install:

  1. hashcat (GPU or CPU; hashcat -I lists the backends it finds) and john.
  2. openssl, md5sum, sha1sum, sha256sum, iconv (packages openssl, coreutils).
  3. python3 with the bcrypt module (pip3 install bcrypt if it is missing).

Every hash in this lab comes from a password you make up yourself. Do not run these commands against a real account's hash, a colleague's password, or any system you do not own or have written permission to test.

Step 1: Build a test hash set

1

Create one hash of each common type, from the same test password

Using one password for every hash makes the attack steps easy to check: whatever method you use, the plaintext must come back the same. The password hashcat is used here only because it is short to type; use any password you like.

Create the fast, unsalted hashes.

echo -n "hashcat" | md5sum | cut -d' ' -f1        > md5.hash
echo -n "hashcat" | sha1sum | cut -d' ' -f1       > sha1.hash
echo -n "hashcat" | sha256sum | cut -d' ' -f1     > sha256.hash

Create the NTLM hash. NTLM is MD4 of the password in UTF-16LE, which is why Windows hashes need the iconv step and OpenSSL's legacy provider (MD4 is disabled by default in OpenSSL 3).

echo -n "hashcat" | iconv -t UTF-16LE | openssl dgst -md4 -provider legacy

Example output:

MD4(stdin)= b4b9b02e6f09a9bd760f388b67351e2b
echo "b4b9b02e6f09a9bd760f388b67351e2b" > ntlm.hash

Create a Linux shadow-style hash (SHA-512 crypt, $6$, the default on current Kali and Debian) and a bcrypt hash ($2b$, common for web application logins).

openssl passwd -6 -salt testsalt123 "hashcat"           > shadow.hash
python3 -c "import bcrypt; print(bcrypt.hashpw(b'hashcat', bcrypt.gensalt()).decode())" > bcrypt.hash
cat shadow.hash

Example output:

$6$testsalt123$YYiXl7/zc/fRNmRiNS1iHI2BOVcQr.i/jVC/RdhCl.0k8rogWzqPs/Mndbjf0lCUsXAJPAL9gyjE7b1EUTcrt/

You now have five files, five hash types, one known plaintext.

Step 2: Match each hash to a hashcat mode

2

Read length and prefix, then look up the hashcat mode number

Hashcat needs the mode number (-m) before it can crack anything. Length and prefix are usually enough to tell the types apart.

hashid -m md5.hash ntlm.hash shadow.hash bcrypt.hash

Example output:

--Hash: 8743b52063cd84097a65d1633f5c74f5
[+] MD5 [Hashcat Mode: 0]
--Hash: b4b9b02e6f09a9bd760f388b67351e2b
[+] NTLM [Hashcat Mode: 1000]
--Hash: $6$testsalt123$YYiXl7...
[+] sha512crypt [Hashcat Mode: 1800]
--Hash: $2b$12$8kCh3nAC9PHENy3O152NIu...
[+] bcrypt [Hashcat Mode: 3200]
HashLength / prefixHashcat mode
MD532 hex chars0
SHA-140 hex chars100
SHA-25664 hex chars1400
NTLM32 hex chars, no prefix1000
sha512cryptstarts $6$1800
bcryptstarts $2a$ / $2b$3200

Sign in to continue

9 more sections are for signed-in members. It is free: sign in with Google.

Related