← Volver al inicio
John the Ripper Hashcat Cracking MD5 SHA Contraseñas

John the Ripper y Hashcat: Cracking de Contraseñas

01/04/2022

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.

1. Identificar el tipo de hash

# 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)

2. John the Ripper

# 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

3. Hashcat

# 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

4. Modos de hash de Hashcat (más comunes)

Modo (-m)Tipo de hash
0MD5
100SHA1
1400SHA256
1700SHA512
1000NTLM (Windows)
3200bcrypt
500md5crypt (Unix $1$)
1800sha512crypt (Unix $6$)
2500WPA/WPA2 (WiFi)

5. Preparar wordlists

# 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