Herramientas de Password Cracking
Herramientas de Password Cracking
1. John the Ripper
1. Descripcion
John the Ripper (John) es una herramienta de code abierto para crackeo de contrasenas. Soporta multiples formatos y es ideal para principiantes por su facilidad de uso.
1. Instalacion
# Arch Linux
sudo pacman -S john
# Kali/Parrot (ya incluido)
which john
# Desde fuente
git clone https://github.com/magnumripper/JohnTheRipper
cd JohnTheRipper/src
./configure && make -j4
1. Modos de Uso
wordlist Mode
john --wordlist=rockyou.txt --format=raw-md5 hash.txt
Incremental (Fuerza Bruta)
john --incremental --format=raw-md5 --max-length=8 hash.txt
Single Mode (usa info del usuario)
john --single --format=des hash.txt
1. Pre-procesamiento
Combinar passwd y shadow:
unshadow /etc/passwd /etc/shadow > hash.txt
john --wordlist=rockyou.txt hash.txt
1. Formatos de Hash
| Formato | Opcion | Ejemplo Hash |
|---|---|---|
| MD5 | raw-md5 | d8578edf8458ce06fbc5bb76a58... |
| SHA-256 | raw-sha256 | a665a45920422f... |
| bcrypt | bcrypt | $2a$12$... |
| NTLM | ntlm | e38ad4149434383f... |
| LM | lm | c4f3dab8e7b0... |
| MySQL | mysql | *c4caa792ba9... |
1. Mostrar Resultados
john --show hash.txt
john --show --format=raw-md5 hash.txt
1. Formatos de Salida
# Guardar sesion
john --save-session=misesion hash.txt
# Continuar sesion
john --restore=misesion
2. Hashcat
2. Descripcion
Hashcat es la herramienta mas rapida de password cracking, optimizada paraGPU. Soporta mas de 300 modos de hash.
2. Instalacion
# Arch Linux
sudo pacman -S hashcat
# Kali/Parrot (ya incluido)
which hashcat
2. Modos de Ataque
Mode 0: Straight (Diccionario)
hashcat -m 0 -a 0 hash.txt wordlist.txt
| Numero | Descripcion | |——-|———-| | -m 0 | Tipo de hash (0 = MD5) | | -a 0 | Modo straight |
Mode 1: Combination
# Combina dos wordlists
hashcat -m 0 -a 1 hash.txt wordlist1.txt wordlist2.txt
Mode 3: Brute-force
hashcat -m 0 -a 3 hash.txt ?a?a?a?a?a?a
Mode 6: Wordlist + Rules
hashcat -m 0 -a 6 hash.txt wordlist.txt rules.rule
2. Numeros de Hash
| Numero | Hash | Numero | Hash |
|---|---|---|---|
| 0 | MD5 | 1000 | MySQL |
| 100 | SHA1 | 131 | MSSQL |
| 1400 | SHA256 | 1700 | SHA-512 |
| 3200 | bcrypt | 1440 | SHA-256(salt) |
| 5500 | NetNTLMv1 | 5600 | NetNTLMv2 |
Consulta completa: hashcat --help | grep -A 300 "Hash types"
2. Opciones GPU
# Seleccionar dispositivo
--device 0 # GPU 0
--device 1 # GPU 1
--device all # Todos
--opencl-device-types 1 # Solo GPU
2. Optimizacion
# Threads
--workload-profile 3
# Segmentos
--segment-size 512
# Fuerza
--force
2. Ejemplos
# MD5 basico
hashcat -m 0 -a 0 hash.txt rockyou.txt
# Wordlist + rules
hashcat -m 0 -a 0 hash.txt wordlist.txt -r rules.rule
# Brute-force
hashcat -m 0 -a 3 hash.txt ?l?l?l?l?l?l
# Benchark
hashcat -m 0 -b
3. Hydra
3. Descripcion
Hydra es una herramienta de fuerza bruta concurrente para protocolos de red. Soporta multiples servicios.
3. Instalacion
# Arch Linux
sudo pacman -S hydra
# Kali/Parrot (ya incluido)
which hydra
3. Sintaxis Basica
hydra -L usuarios.txt -P passwords.txt servidor servicio
| Parametro | Descripcion |
|---|---|
| -L | Archivo de usuarios |
| -l | Usuario unico |
| -P | Archivo de contrasenas |
| -p | Contrasena unica |
| -t | Threads (default 16) |
| -v | Verbose |
| -f | Salir al encontrar |
3. Servicios Soportados
| Servicio | Parametro | Ejemplo |
|---|---|---|
| SSH | ssh | hydra -L u.txt -P p.txt 192.168.1.1 ssh |
| FTP | ftp | hydra -L u.txt -P p.txt 192.168.1.1 ftp |
| HTTP | http-get | hydra -L u.txt -P p.txt 192.168.1.1 http-get /admin |
| SMB | smb | hydra -L u.txt -P p.txt 192.168.1.1 smb |
| RDP | rdp | hydra -L u.txt -P p.txt 192.168.1.1 rdp |
| MySQL | mysql | hydra -L u.txt -P p.txt 192.168.1.1 mysql |
| PostgreSQL | postgres | hydra -L u.txt -P p.txt 192.168.1.1 postgres |
3. Opciones
# Threads
hydra -t 50 -L u.txt -P p.txt servidor ssh
# Puerto especifico
hydra -s 2222 -L u.txt -P p.txt servidor ssh
# Salir al encontrar
hydra -f -L u.txt -P p.txt servidor ssh
# Verbose
hydra -v -L u.txt -P p.txt servidor ssh
3. Ejemplos
# SSH con wordlist
hydra -L usuarios.txt -P rockyou.txt 192.168.1.1 ssh
# HTTP Basic Auth
hydra -L usuarios.txt -P passwords.txt 192.168.1.1 http-get /admin
# Multiple targets
hydra -L u.txt -P p.txt -M targets.txt ssh
# Con proxy
hydra -L u.txt -P p.txt -x 192.168.1.1 proxy
4. Crunch - Generacion de Wordlists
4. Descripcion
Crunch genera wordlists personalizadas segun patrones especificos. Esencial cuando se conoce la politica de contrasenas del objetivo.
4. Instalacion
sudo pacman -S crunch
4. Sintaxis Basica
crunch min max [charset] [options]
4. Parametros
| Parametro | Descripcion |
|---|---|
| min | Longitud minima |
| max | Longitud maxima |
| -o | Archivo de salida |
| -t | Patron (@=minuscula, ,=mayuscula, %=numero, ^=simbolo) |
| -p | Palabras para permutar |
| -s | Iniciar desde |
4. Ejemplos
# 4 digitos
crunch 4 4 0123456789 -o 4digitos.txt
# Con patron (password + numeros)
crunch 8 8 -t "password%%" -p "password" -o pw.txt
# Fechas
crunch 6 6 -t "%%%%0102" -o fechas.txt
# Permutaciones
crunch 4 4 -p admin root test -o perms.txt
5. Zip2john - Extraer Hashes de ZIP
5. Extraer Hash de ZIP
# Nuevo formato
zip2john archivo.zip > hash.txt
# Formato legacy
zip2john.py archivo.zip > hash.txt
5. Crackear
john --wordlist=rockyou.txt hash.txt
6. Pdf2john - Extraer Hashes de PDF
6. Extraer Hash de PDF
# Perl
pdf2john.pl archivo.pdf > hash.txt
# Python
pdf2john.py archivo.pdf > hash.txt
6. Crackear
john --wordlist=rockyou.txt hash.txt
7. Ssh2john - Extraer Hashes de SSH
7. Extraer Hash de SSH Private Key
ssh2john id_rsa > hash.txt
# Python
ssh2john.py id_rsa > hash.txt
7. Crackear
john --wordlist=rockyou.txt hash.txt
8. Rarcrack - Crackeo de Archives
8. Rarcrack
# Instalar
sudo pacman -S rarcrack
# Uso
rarcrack archivo.rar --charset a --threads 10 --type rar
rarcrack archivo.zip --charset a --threads 10 --type zip
# Buscar password
rarcrack archivo.rar --charset a --threads 10 --type rar --proc
9. Hash Identifier
9. Identificar Tipo de Hash
# Instalar
pip install hashid
# Uso
hashid hash.txt
# Con verbose
hashid -m hash.txt
10. Pipelines Recomendados
10.1. Pipeline Basico
# 1. Identificar hash
hashid hash.txt
# 2. Probar diccionarios pequenos
john --wordlist=passwords.txt hash.txt
# 3. Si no, probar rockyou
john --wordlist=rockyou.txt hash.txt
10.2. GPU (Hashcat)
# MD5
hashcat -m 0 -a 0 hash.txt rockyou.txt
# NTLM
hashcat -m 1000 -a 0 hash.txt rockyou.txt
# SHA256
hashcat -m 1400 -a 0 hash.txt rockyou.txt
10.3. Service Brute Force (Hydra)
# SSH
hydra -L usuarios.txt -P rockyou.txt 192.168.1.1 ssh
# HTTP
hydra -L usuarios.txt -P rockyou.txt 192.168.1.1 http-post-form "/login:user^USER^&pass^PASS^:F=Error"
11. Cheat Sheet Rapido
| Herramienta | Comando |
|---|---|
| John | john --wordlist=rockyou.txt hash.txt |
| Hashcat | hashcat -m 0 -a 0 hash.txt rockyou.txt |
| Hydra | hydra -L u.txt -P p.txt servidor ssh |
| Crunch | crunch 8 8 -t "pass%%" -o wordlist.txt |
| zip2john | zip2john.zip > hash.txt |
| ssh2john | ssh2john id_rsa > hash.txt |
| hashid | hashid hash.txt |