Commands / On the wire

On the wire

hydra

Also thc-hydra, dictionary attack, brute force, password guesser

Guesses a service's login by trying a list of usernames and passwords against it until one works.

Where nmap finds that a login service is open, hydra tries to get through it. Point it at a host and a service (SSH, FTP, HTTP forms and many more), give it a username and a password list, and it tries each in turn, reporting the pair that logs in. A weak password is one already on the list, so it falls in seconds. Nothing is broken in the service: every guess is a real login attempt, so the run is loud — the service writes each one to its log. Only guess logins you are allowed to; in netlab, the lab's own.

hydra command usage

hydra [-l USER | -L USERLIST] [-p PASS | -P PASSLIST] [-t TASKS] [-f] [-V] [-s PORT] TARGET SERVICE

Options

-l admin
one username to try (-L users.lst for a list of usernames)
-P pass.lst
a password list, one per line (-p for a single password)
-f
stop at the first working login, not after the whole list
-t 4
run this many guesses at once (fewer is gentler, and steadier against SSH)
-V
print every username/password pair as it is tried
-s 2222
the service listens on this port, not its default

hydra examples

hydra -l admin -P pass.lst 10.0.1.10 ssh
Tries every password in pass.lst against the admin account over SSH and names the one that works.
hydra -l admin -P pass.lst -t 4 -f 10.0.1.10 ssh
Runs four guesses at a time and stops at the first that logs in.
hydra -L users.lst -P pass.lst 10.0.1.10 ssh
Tries every username in one list against every password in another.
hydra -l admin -p password123 10.0.1.10 ssh
Tries a single password, to confirm one guess by hand.
hydra -l admin -P pass.lst ftp://10.0.1.10
Guesses an FTP login, naming the service in the URL form instead.

Reading the output

$ hydra -l admin -P pass.lst -f 10.0.1.10 ssh
[DATA] attacking ssh://10.0.1.10:22/
[22][ssh] host: 10.0.1.10   login: admin   password: password123
1 of 1 target successfully completed, 1 valid password found
  • The [22][ssh] line names the login and password that worked: the weak password was on the list.
  • 1 valid password found: the account is cracked. A long random password would have ended with 0 valid passwords found.

Pitfalls

  • Every guess is a real login the service logs: a dictionary run shows up as a burst of failed logins from one address, easy to alert on.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab