Práctica de cracking de hashes de contraseñas con John the Ripper (CPU) y Hashcat (GPU), cubriendo ataques de diccionario, fuerza bruta y reglas.
# Con hashid:
hashid 5f4dcc3b5aa765d61d8327deb882cf99
# Con hash-identifier:
hash-identifier
# Tipos comunes:
# MD5: 32 caracteres hex
# SHA1: 40 caracteres hex
# SHA256: 64 caracteres hex
# bcrypt: $2b$... (empieza con $2)
# NTLM: 32 caracteres hex (Windows)
# Ataque con diccionario:
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
# Especificar formato del hash:
john --format=md5crypt --wordlist=rockyou.txt hashes.txt
john --format=sha256 --wordlist=rockyou.txt hashes.txt
john --format=bcrypt --wordlist=rockyou.txt hashes.txt
john --format=NT --wordlist=rockyou.txt hashes.txt # NTLM Windows
# Ataque con reglas (mutaciones de palabras del diccionario):
john --wordlist=rockyou.txt --rules hashes.txt
# Ataque incremental (fuerza bruta pura):
john --incremental hashes.txt
# Ver contraseñas ya crackeadas:
john --show hashes.txt
# Crackear /etc/shadow de Linux:
unshadow /etc/passwd /etc/shadow > combined.txt
john combined.txt
# Ataque de diccionario (-a 0):
hashcat -a 0 -m 0 hashes.txt rockyou.txt # MD5
hashcat -a 0 -m 100 hashes.txt rockyou.txt # SHA1
hashcat -a 0 -m 1400 hashes.txt rockyou.txt # SHA256
hashcat -a 0 -m 1000 hashes.txt rockyou.txt # NTLM (Windows)
hashcat -a 0 -m 3200 hashes.txt rockyou.txt # bcrypt
# Ataque de fuerza bruta (-a 3):
hashcat -a 3 -m 0 hash.txt ?d?d?d?d?d?d # 6 dígitos
# Máscaras de fuerza bruta:
# ?l = minúscula | ?u = MAYÚSCULA | ?d = dígito | ?s = símbolo | ?a = todo
# Combinaciones comunes:
hashcat -a 3 -m 0 hash.txt ?u?l?l?l?d?d?d?s # Formato Password1!
# Ataque con reglas (mejora el diccionario):
hashcat -a 0 -m 0 hash.txt rockyou.txt -r /usr/share/hashcat/rules/best64.rule
# Ver progreso en tiempo real:
hashcat -a 0 -m 0 hash.txt rockyou.txt --status
| Modo (-m) | Tipo de hash |
|---|---|
| 0 | MD5 |
| 100 | SHA1 |
| 1400 | SHA256 |
| 1700 | SHA512 |
| 1000 | NTLM (Windows) |
| 3200 | bcrypt |
| 500 | md5crypt (Unix $1$) |
| 1800 | sha512crypt (Unix $6$) |
| 2500 | WPA/WPA2 (WiFi) |
# Descomprimir rockyou.txt (Kali):
gunzip /usr/share/wordlists/rockyou.txt.gz
# Crear wordlist personalizada con cewl (basada en una web):
cewl https://www.target.com -d 2 -m 6 -w wordlist_target.txt
# Crear mutaciones con crunch:
crunch 8 10 abcdefghijklmnopqrstuvwxyz0123456789 -o wordlist.txt