Homework
Three tasks that deepen your understanding of mask design, attack benchmarking, and multi-stage cracking strategies.
Complete all five lab exercises before starting the homework. These tasks build on the skills you practiced in the lab.
Task 1 — Custom Charset Design
Objective
Design a set of custom charsets tailored to a specific password policy, then use them to crack test hashes.
Instructions
- Choose a password policy (real or hypothetical). Example: "8 characters minimum, must contain at least one uppercase letter, one lowercase letter, one digit, and one of the following special characters:
!@#$" - Create 5 test passwords that comply with this policy. Generate their MD5 hashes.
- Design masks using custom charsets (
-1,-2, etc.) that model the policy constraints. Write at least 3 different masks targeting different structural patterns:- Example mask 1:
-1 !@#$ ?u?l?l?l?l?d?d?1(uppercase + 4 lower + 2 digits + special) - Example mask 2:
-1 !@#$ ?1?u?l?l?l?l?l?d(special + uppercase + 5 lower + digit) - Example mask 3:
-1 !@#$ ?d?d?u?l?l?l?l?1(2 digits + uppercase + 4 lower + special)
- Example mask 1:
- Run each mask against your test hashes. Record which passwords each mask cracks.
- Write a brief explanation (3-5 sentences) of why multiple masks are needed even with custom charsets.
Deliverable
A text file or document containing: the password policy, your 5 test passwords, the 3+ masks with their commands, results, and your explanation.
Task 2 — Attack Speed Benchmarking
Objective
Compare the performance of mask, hybrid, and dictionary attacks on identical hash sets to understand when each mode is most efficient.
Instructions
- Create a set of 10 test passwords that include a mix of:
- Pure dictionary words (e.g., "sunshine")
- Words with appended digits (e.g., "sunshine123")
- Pattern-based passwords (e.g., "Abcd1234")
- Words with prepended digits (e.g., "99sunshine")
- Generate their MD5 hashes into
bench_hashes.txt. - Run the following attacks and record the time, speed, and number of passwords cracked for each:
# Dictionary attack hashcat -m 0 -a 0 bench_hashes.txt rockyou.txt # Hybrid append hashcat -m 0 -a 6 bench_hashes.txt rockyou.txt ?d?d?d # Hybrid prepend hashcat -m 0 -a 7 bench_hashes.txt ?d?d rockyou.txt # Mask attack (8-char mixed) hashcat -m 0 -a 3 bench_hashes.txt ?u?l?l?l?d?d?d?d - Create a results table:
Attack Mode Passwords Cracked Time Speed (H/s) Dictionary (-a 0) ?/10 ? ? Hybrid append (-a 6) ?/10 ? ? Hybrid prepend (-a 7) ?/10 ? ? Mask (-a 3) ?/10 ? ? - Write a brief analysis (5-8 sentences): Which attack mode cracked the most passwords? Which was fastest? Were there passwords that only one mode could crack? What does this tell you about real-world cracking strategy?
Tip: Use --potfile-disable between runs so previously cracked hashes don't get skipped. Alternatively, clear the potfile before each run.
Task 3 — Multi-Stage Cracking Script
Objective
Write a shell script that chains multiple attack modes in order of efficiency, stopping when all hashes are cracked or all attacks are exhausted.
Instructions
- Create a Bash script called
crack_chain.shthat accepts a hash file as an argument. - The script should run the following attacks in sequence:
- Stage 1: Dictionary attack with rockyou.txt
- Stage 2: Hybrid append — wordlist +
?d?d - Stage 3: Hybrid append — wordlist +
?d?d?d - Stage 4: Hybrid prepend —
?d?d+ wordlist - Stage 5: Mask for 4-digit PINs:
?d?d?d?d - Stage 6: Mask for 6-digit PINs:
?d?d?d?d?d?d - Stage 7: Mask for name+digits:
?u?l?l?l?l?d?d
- Between each stage, print a status message showing which stage just completed and how many hashes have been cracked so far.
- Test the script against a set of 10+ test hashes covering diverse password patterns.
Starter Template
#!/bin/bash
# crack_chain.sh - Multi-stage hashcat cracking script
HASHFILE="$1"
WORDLIST="rockyou.txt"
HASHTYPE=0 # MD5
if [ -z "$HASHFILE" ]; then
echo "Usage: $0 <hashfile>"
exit 1
fi
echo "=== Stage 1: Dictionary Attack ==="
hashcat -m $HASHTYPE -a 0 "$HASHFILE" "$WORDLIST"
echo "Stage 1 complete."
echo "=== Stage 2: Hybrid Append ?d?d ==="
hashcat -m $HASHTYPE -a 6 "$HASHFILE" "$WORDLIST" ?d?d
echo "Stage 2 complete."
echo "=== Stage 3: Hybrid Append ?d?d?d ==="
hashcat -m $HASHTYPE -a 6 "$HASHFILE" "$WORDLIST" ?d?d?d
echo "Stage 3 complete."
# Continue with remaining stages...
echo "=== Stage 4: Hybrid Prepend ?d?d ==="
hashcat -m $HASHTYPE -a 7 "$HASHFILE" ?d?d "$WORDLIST"
echo "Stage 4 complete."
echo "=== Stage 5: PIN 4-digit ==="
hashcat -m $HASHTYPE -a 3 "$HASHFILE" ?d?d?d?d
echo "Stage 5 complete."
echo "=== Stage 6: PIN 6-digit ==="
hashcat -m $HASHTYPE -a 3 "$HASHFILE" ?d?d?d?d?d?d
echo "Stage 6 complete."
echo "=== Stage 7: Name+Digits ==="
hashcat -m $HASHTYPE -a 3 "$HASHFILE" ?u?l?l?l?l?d?d
echo "Stage 7 complete."
echo "=== All stages finished ==="
hashcat -m $HASHTYPE --show "$HASHFILE"
Enhancement ideas: Add a function that counts remaining uncracked hashes after each stage and skips further stages if all are cracked. Add a --quiet mode that suppresses Hashcat's verbose output. Add timing information for each stage.
Submission Checklist
- Task 1: Password policy defined; 5 test passwords + hashes; 3+ custom masks; results and explanation
- Task 2: 10 test passwords benchmarked across 4 attack modes; results table; written analysis
- Task 3:
crack_chain.shscript created; tested against 10+ hashes; stage output visible