iT邦幫忙

2021 iThome 鐵人賽

DAY 16
1
Security

Kali Linux 工具筆記系列 第 16

Day 16 網頁分析 - Web Application Analysis (網頁內容掃描器 - DIRB )

今天要介紹的工具是BIRDDIRB,是一個網頁內容掃描器,它根據字典檔一個個向目標網頁發出請求,並分析回傳的結果,藉以確認網頁資料夾或物件存在。而DIRB有預設定義好的一些字典檔,也可以不使用預設,改用自己定義的字典檔來做掃描。

使用方式

首先先直接執行dirb來看一下使用方式,只要給定目標網頁就可以了,後面根據需求來決定是否要使用自定義的字典檔

-----------------
DIRB v2.22    
By The Dark Raver
-----------------

dirb <url_base> [<wordlist_file(s)>] [options]

========================= NOTES =========================
 <url_base> : Base URL to scan. (Use -resume for session resuming)
 <wordlist_file(s)> : List of wordfiles. (wordfile1,wordfile2,wordfile3...)

======================== HOTKEYS ========================
 'n' -> Go to next directory.
 'q' -> Stop scan. (Saving state for resume)
 'r' -> Remaining scan stats.

======================== OPTIONS ========================
 -a <agent_string> : Specify your custom USER_AGENT.
 -b : Use path as is.
 -c <cookie_string> : Set a cookie for the HTTP request.
 -E <certificate> : path to the client certificate.
 -f : Fine tunning of NOT_FOUND (404) detection.
 -H <header_string> : Add a custom header to the HTTP request.
 -i : Use case-insensitive search.
 -l : Print "Location" header when found.
 -N <nf_code>: Ignore responses with this HTTP code.
 -o <output_file> : Save output to disk.
 -p <proxy[:port]> : Use this proxy. (Default port is 1080)
 -P <proxy_username:proxy_password> : Proxy Authentication.
 -r : Don't search recursively.
 -R : Interactive recursion. (Asks for each directory)
 -S : Silent Mode. Don't show tested words. (For dumb terminals)
 -t : Don't force an ending '/' on URLs.
 -u <username:password> : HTTP Authentication.
 -v : Show also NOT_FOUND pages.
 -w : Don't stop on WARNING messages.
 -X <extensions> / -x <exts_file> : Append each word with this extensions.
 -z <millisecs> : Add a milliseconds delay to not cause excessive Flood.

常用的用法也提供了範例

======================== EXAMPLES =======================
 dirb http://url/directory/ (Simple Test)
 dirb http://url/ -X .html (Test files with '.html' extension)
 dirb http://url/ /usr/share/dirb/wordlists/vulns/apache.txt (Test with apache.txt wordlist)
 dirb https://secure_url/ (Simple Test with SSL)                                                  

這邊先使用預設的字典檔來體驗一下效果,可以用Day2建立的靶機來試試看,不過如果有在Day14因為建立wordpress網站的話,建議可以先還原靶機的原始網頁設置

# 以下指令皆在靶機上執行

# 關閉apache2
sudo /etc/init.d/apache2 stop

# Day14把wordpress資料夾指向了/var/www,所以可以直接刪除此軟連結
sudo rm /var/www

# 復原原本備份
sudo mv /var/www.bak /var/www

# 重啟apache2
sudo /etc/init.d/apache2 start

接著就可以用dirb來對靶機做掃描囉

dirb http://192.168.1.86

這邊執行的一開始就表明了使用預設的字典檔/usr/share/dirb/wordlists/common.txt,這個字典檔裡含有4612個關鍵字

START_TIME: Fri Oct  1 10:14:15 2021
URL_BASE: http://192.168.1.86/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
-----------------

GENERATED WORDS: 4612

這邊節錄一下/usr/share/dirb/wordlists/common.txt的部分內容,來了解一下格式,每一行都是一個關鍵字,利用這些關鍵字去組合並掃描,來確認目標網站存在哪些路徑。

php
php.ini
php_uploads
php168
php3
phpadmin
phpads
phpadsnew

這邊節錄一些掃描結果,只能說靶機不愧是靶機,就是故意要被掃到,路徑中充滿許多常見的關鍵字,所以才會如此容易命中。

+ http://192.168.1.86/cgi-bin/ (CODE:403|SIZE:293)                          
==> DIRECTORY: http://192.168.1.86/dav/
+ http://192.168.1.86/index (CODE:200|SIZE:891)                             
+ http://192.168.1.86/index.php (CODE:200|SIZE:891)                         
+ http://192.168.1.86/phpinfo (CODE:200|SIZE:48059)                         
+ http://192.168.1.86/phpinfo.php (CODE:200|SIZE:48071)                     
==> DIRECTORY: http://192.168.1.86/phpMyAdmin/
+ http://192.168.1.86/server-status (CODE:403|SIZE:298)                     
==> DIRECTORY: http://192.168.1.86/test/
==> DIRECTORY: http://192.168.1.86/twiki/
                                                                            
---- Entering directory: http://192.168.1.86/dav/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.
    (Use mode '-w' if you want to scan it anyway)

了解用法後,可以嘗試定義自己的字典檔,如果想確認自訂的關鍵字是否已經存在於預設的字典內,那麼可以去/usr/share/dirb/wordlists/這個路徑下看看預設的字典檔有哪些,這些字典檔也可以拿來直接用

dirb http://192.168.1.86 /usr/share/dirb/wordlists/vulns/apache.txt     

相關工具

html2dic可以從html的文件產生可用的字典檔

# 用 wget 下載 index.html頁面
wget http://example.com

# 產生字典檔並輸出到檔案
html2dic index.html > my_dic.txt

結語

其實dirb不是一個攻擊用的工具,它也不是直接偵測漏洞,只是提供一個輔助的手段或是進行前置的準備動作,之後再用其他工具來使用這些資訊來達到最後的目的。


上一篇
Day 15 網頁分析 - Web Application Analysis (網頁快照截圖 - cutycapt )
下一篇
Day 17 網頁分析 - Web Application Analysis (WhatWeb)
系列文
Kali Linux 工具筆記31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言