MassDNS是一種簡單的高性能DNS存根解析器,其目標讀者是那些尋求解析數百萬甚至數十億數量級域名的人。無需特殊配置,MassDNS就能使用公開可用的解析器每秒解析超過350,000個名稱。
工具編譯
將git倉庫克隆cd到項目根文件夾中。然後運行make從原始碼構建。
工具用法
Usage: ./bin/massdns [options] [domainlist]
-b --bindto Bind to IP address and port. (Default: 0.0.0.0:0)
--busy-poll Use busy-wait polling instead of epoll.
-c --resolve-count Number of resolves for a name before giving up. (Default: 50)
--drop-group Group to drop privileges to when running as root. (Default: nogroup)
--drop-user User to drop privileges to when running as root. (Default: nobody)
--flush Flush the output file whenever a response was received.
-h --help Show this help.
-i --interval Interval in milliseconds to wait between multiple resolves of the same
domain. (Default: 500) -l
--error-log Error log file path. (Default: /dev/stderr)
--norecurse Use non-recursive queries. Useful for DNS cache snooping.
-o --output Flags for output formatting.
--predictable Use resolvers incrementally. Useful for resolver tests.
--processes Number of processes to be used for resolving. (Default: 1)
-q --quiet Quiet mode.
--rcvbuf Size of the receive buffer in bytes.
--retry Unacceptable DNS response codes. (Default: REFUSED)
-r --resolvers Text file containing DNS resolvers.
--root Do not drop privileges when running as root. Not recommended.
-s --hashmap-size Number of concurrent lookups. (Default: 10000)
--sndbuf Size of the send buffer in bytes.
--sticky Do not switch the resolver when retrying.
--socket-count Socket count per process. (Default: 1)
-t --type Record type to be resolved. (Default: A)
--verify-ip Verify IP addresses of incoming replies.
-w --outfile Write to the specified output file instead of standard output.
Output flags:
S - simple text output
F - full text output
B - binary output
J - ndjson output
使用示例
解析目標域名(位於lists的resolvers.txt中)的AAAA記錄,轉化結果存儲至result.txt中:
$ ./bin/massdns -r lists/resolvers.txt -t AAAA domains.txt > results.txt
或者運行下列命令:
$ ./bin/massdns -r lists/resolvers.txt -t AAAA -w results.txt domains.txt
樣本輸出
默認配置下,MassDNS將輸出響應數據包,格式為文本格式,輸出樣例如下:
;; Server: 77.41.229.2:53
;; Size: 93
;; Unix time: 1513458347
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51298
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
example.com. IN A
;; ANSWER SECTION:
example.com. 45929 IN A 93.184.216.34
;; AUTHORITY SECTION:
example.com. 24852 IN NS b.iana-servers.net.
example.com. 24852 IN NS a.iana-servers.net.
輸出結果包含了解析的IP位址,可以幫助我們輕鬆對輸出結果進行過濾。
數據解析
代碼庫中包含了一個名為resolvers.txt的文件,其中包含了一套有子項目提供的已過濾的解析器子集。請注意,MassDNS的使用可能會提升系統/網絡負載,因為需要加載大量解析器,具體將決定你的ISP。
MassDNS的DNS解析實現目前還不完整,只支持最常見的一些記錄類型。歡迎您通過代碼貢獻來幫助改變這種狀況。
PTR記錄
MassDNS包含了一個Python腳本,允許我們解析所有的IPv4 PTR記錄:
$ ./scripts/ptr.py | ./bin/massdns -r lists/resolvers.txt -t PTR -w ptr.txt
請注意,in-addr.arpa中的標籤會被反轉。為了解析域名為1.2.3.4的地址,MassDNS將需要以「 4.3.2.1.in-addr.arpa」的方式來作為輸入查詢名稱。此時,Python腳本並不會按升序解析記錄,這樣可以避免在IP v4子網的域名伺服器上突然出現的負載激增。
網絡偵察&爆破子域名
注意:請不要隨意使用該工具,適當調整-s參數預設給權威域名伺服器造成負載壓力。
跟subbrute類似,MassDNS允許我們使用subbrute.py腳本來對子域名進行爆破枚舉舉:
$ ./scripts/subbrute.py lists/names.txt example.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w results.txt
作為一種額外的網絡偵察手段,ct.py腳本可以從crt.sh中抓取數據,並從證書透明日誌中提取子域名:
$ ./scripts/ct.py example.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w results.txt
文章來源:
https://github.com/blechschmidt/massdns