Lab 11: Password Forensics - Menganalisis & Meretrieve Password dari Hash
Target Skill: Mahasiswa mampu mengidentifikasi jenis hash, melakukan cracking dengan dictionary attack, dan menganalisis kebijakan password
Tools:python3,john(John the Ripper),hashid
Durasi: 30 menit
Level: Beginner
Mengapa Password Forensics Penting?
Ketika investigator mendapatkan file berisi hash password (seperti
/etc/shadow atau SAM), pertanyaan
utamanya: password apa yang dipakai user?
Jawabannya bisa mengungkap:
- Akun mana yang sudah diretas
- Password yang digunakan di akun lain (credential reuse)
- Seberapa lemah kebijakan password organisasi
- Motif dan pola pikir attacker
Learning Objectives
- Mengidentifikasi jenis hash dari formatnya
- Melakukan dictionary attack dengan John the Ripper
- Menganalisis kekuatan password
- Memahami konsep salt dan hash
Langkah Praktikum
cd ~ && mkdir forensics-lab11 && cd forensics-lab11
# 1. Buat file hash simulasi (berbagai jenis)
cat > hashes.txt << 'EOF'
# MD5 (unsalted)
user1:$1$salt$abcdef1234567890abcdef1234567890
# SHA-512 (Linux shadow format)
user2:$6$saltsalt$abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12
# NT hash (Windows SAM)
user3:31d6cfe0d16ae931b73c59d7e0c089c0
# bcrypt
user4:$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
# Simple MD5 (unsalted)
admin:21232f297a57a5a743894a0e4a801fc3
EOF
echo "✅ File hash multi-format dibuat"
# 2. Identifikasi hash
cat > hash-identifier.py << 'PYEOF'
# Simple hash identifier
import re
hashes = {
'21232f297a57a5a743894a0e4a801fc3': ('MD5', 'admin'), # known: md5('admin')
'31d6cfe0d16ae931b73c59d7e0c089c0': ('MD5', ''), # md5('')
}
def identify(hash_str):
length = len(hash_str)
if hash_str.startswith('$1$'): return 'MD5 crypt (Linux)'
if hash_str.startswith('$6$'): return 'SHA-512 crypt (Linux shadow)'
if hash_str.startswith('$2a$') or hash_str.startswith('$2b$'): return 'bcrypt'
if hash_str.startswith('$5$'): return 'SHA-256 crypt'
if length == 32: return 'MD5 (possible)'
if length == 40: return 'SHA1 (possible)'
if length == 64: return 'SHA256 (possible)'
if length == 128: return 'SHA512 (possible)'
return 'Unknown'
with open('hashes.txt') as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'): continue
if ':' in line:
user, hash_val = line.split(':', 1)
print(f"{user:10} → {identify(hash_val):30} ({len(hash_val)} chars)")
PYEOF
python3 hash-identifier.py
# 3. Simulasi dictionary attack
cat > dictionary.txt << 'DICT'
admin
password
123456
12345678
qwerty
letmein
welcome
monkey
dragon
baseball
iloveyou
trustno1
sunshine
master
DICT
cat > crack-simul.py << 'PYEOF'
import hashlib
# Target hashes
targets = {
'admin': '21232f297a57a5a743894a0e4a801fc3', # md5('admin')
}
with open('dictionary.txt') as f:
words = [w.strip() for w in f if w.strip()]
print("=== Dictionary Attack Simulation ===")
for word in words:
h = hashlib.md5(word.encode()).hexdigest()
for user, target_hash in targets.items():
if h == target_hash:
print(f"✅ {user}:{word} = {h}")
# Hitung password strength
print("\n=== Password Strength Analysis ===")
for word in words:
score = 0
if len(word) >= 8: score += 1
if any(c.isupper() for c in word): score += 1
if any(c.islower() for c in word): score += 1
if any(c.isdigit() for c in word): score += 1
if any(c in '!@#$%^&*' for c in word): score += 1
level = ['Very Weak', 'Weak', 'Medium', 'Strong', 'Very Strong'][score]
if word in ['admin', 'password', '123456']:
level = '❌ COMMON - DO NOT USE!'
print(f" {word:15} → {level}")
PYEOF
python3 crack-simul.py
️ Analisis
| Hash Type | Panjang | Prefix | Contoh |
|---|---|---|---|
| MD5 | 32 hex | - | 21232f297a57a5a743894a0e4a801fc3 |
| SHA1 | 40 hex | - | a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
|
| SHA256 | 64 hex | - | (64 chars) |
| SHA512 crypt | 106 chars | $6$ |
$6$salt$hash... |
| bcrypt | 60 chars | $2a$ |
$2a$10$... |
| NT hash | 32 hex | - | 31d6cfe0d16ae931b73c59d7e0c089c0 |
Refleksi: Password mahasiswa S1 umumnya lemah - dictionary attack sederhana bisa memecahkan 90% password umum dalam hitungan detik. Gunakan password manager!
Generated by @farishhz Agent Pentest Pipeline - TDCTF Security Academy