
高性能なDNSスタブリゾルバー。バルクルックアップや偵察(サブドメイン列挙)向け。
MassDNSは、数百万から数十億単位の膨大な数のドメイン名を解決することを目的とした、シンプルで高性能なDNSスタブリゾルバです。特別な設定をしなくても、公開されているリゾルバを使用して、毎秒35万以上の名前を解決できます。
Gitリポジトリをクローンし、プロジェクトルートフォルダにcdしてください。そしてmakeを実行してソースからビルドします。Linux以外の場合はmake nolinuxを実行してください。Windowsでは、Cygwinのパッケージgcc-core、git、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)
--extended-input Input names are followed by a space-separated list of resolvers.
These are used before falling back to the resolvers file.
--filter Only output packets with the specified response code.
--flush Flush the output file whenever a response was received.
-h --help Show this help.
--ignore Do not output packets with the specified response code.
-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.
--rand-src-ipv6 Use a random IPv6 address from the specified subnet for each query.
--rand-src-ipv6-file Use a random IPv6 address from the specified file.
--rcvbuf Size of the receive buffer in bytes.
--retry Unacceptable DNS response codes.
(Default: All codes but NOERROR or NXDOMAIN)
-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.
--status-format Format for real-time status updates, json or ansi (Default: ansi)
--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:
L - domain list output
S - simple text output
F - full text output
B - binary output
J - ndjson output
Advanced flags for the domain list output mode:
0 - Include NOERROR replies without answers.
Advanced flags for the simple output mode:
d - Include records from the additional section.
i - Indent any reply record.
l - Separate replies using a line feed.
m - Only output reply records that match the question name.
n - Include records from the answer section.
q - Print the question.
r - Print the question with resolver IP address, Unix timestamp and return code prepended.
s - Separate packet sections using a line feed.
t - Include TTL and record class within the output.
u - Include records from the authority section.
Advanced flags for the ndjson output mode:
e - Write a record for each terminal query failure.
コマンドラインインターフェースの詳細については、man ./doc/massdns.1 でマニュアルページを参照してください。
domains.txt内のドメインからすべてのAAAAレコードを、lists内のresolvers.txtのリゾルバを使用して解決し、結果をresults.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アドレスが含まれているため、一部のリゾルバが誤った結果を生成している場合に出力をフィルタリングしやすくなっています。
リポジトリには、subbruteプロジェクトが提供するリゾルバのフィルタリングされたサブセットからなるresolvers.txtファイルが含まれています。
MassDNSの使用は使用するリゾルバに大きな負荷をかけ、ISPに苦情が出る可能性があることに注意してください。
また、提供されるリゾルバが信頼できるとは限らないことにも注意してください。現在、リゾルバリストは古く、多くのリゾルバが機能していません。
MassDNSのカスタムでmallocフリーなDNS実装は、現在最も一般的なレコードのみをサポートしています。これを変更するための協力を歓迎します。
MassDNSには、すべてのIPv4 PTRレコードを解決するためのPythonスクリプトが含まれており、対応するクエリを標準出力に出力します。
$ ./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スクリプトは昇順でレコードを解決しません。これは、IPv4サブネットのネームサーバーへの突然の急激な負荷を避けることができるため、利点です。
偵察スキャンは責任を持って実行し、権威ネームサーバーに過剰な負荷をかけないように-sパラメータを調整してください。
subbruteと同様に、MassDNSは含まれているsubbrute.pyスクリプトを使用してサブドメインをブルートフォースできます:
$ ./scripts/subbrute.py example.com lists/names.txt | ./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
subbruteプロジェクトからコピーされたnames.txtおよびnames_small.txtファイルには、一般的に使用されるサブドメインの名前が含まれています。また、100万以上の名前を含むJason Haddixのサブドメイン集や、900万以上の名前を含むAssetnoteワードリストも検討してください。
MassDNSには、scriptsフォルダにrecon.pyラッパースクリプト(ベータステータス)も含まれており、権威ネームサーバーに対して直接サブドメイン列挙を実行するため、サードパーティのリゾルバは必要ありません。並行性はMassDNSによって自動的に決定され、毎秒数十万のクエリをサポートし、信頼性の高い結果を提供します。安価な専用サーバーでは、Assetnodeワードリストを1分未満で列挙できます。現在の制限として、ゾーン委任は委任ポイントまでしか処理されません。たとえば、example.orgが列挙され、sub.example.orgが別のネームサーバーに委任されている場合、ワードリストにabc.subが含まれていても、このスクリプトではabc.sub.example.orgは見つかりません。ただし、スクリプトはこの事実をこの場合?.sub.example.orgとして報告します。
$ ./scripts/recon.py -d google.com -l lists/best-dns-wordlist.txt > google.txt

MassDNSはroot権限を必要とせず、rootで実行された場合、デフォルトで"nobody"というユーザーに権限をドロップします。
"nobody"ユーザーが存在しない場合、MassDNSは実行を拒否します。その場合は、他の非特権ユーザーとしてMassDNSを実行することをお勧めします。
権限ドロップは、--root引数を使用して回避できますが、これは推奨されません。
また、master以外のブランチは本番環境では一切使用しないでください。
MassDNSは、ネットワークがボトルネックとなるシナリオ向けに設計されたシンプルなシングルスレッドアプリケーションです。高いアップロードおよびダウンロード帯域幅を持つサーバーで実行するように設計されています。内部では、MassDNSはハッシュマップを使用してルックアップの並行性を制御します。したがって、サイズパラメータ-sを設定することでルックアップレートを制御できます。パフォーマンスの問題が発生している場合は、-sパラメータを調整して成功率を向上させてみてください。
IPv6リゾルバによるレート制限が問題になる場合は、--rand-src-ipv6 <your_ipv6_prefix>を利用できます。MassDNSはDNSパケットの送受信にrawソケットを使用し、クエリごとに指定されたプレフィックスからランダムに送信元IPv6アドレスを選択します。これにはMassDNSをCAP_NET_RAW権限で実行する必要があります。この方法を使用する場合、オペレーティングシステムによってICMP Port unreachable応答が生成されないように、iptablesまたはnftablesでMassDNSが受信するDNSトラフィックをドロップする必要があります。たとえば、ip6tables -p udp --sport 53 -I INPUT -j DROPを使用します。このルールは例示であり、他のアプリケーションのトラフィックを含むすべてのDNSトラフィックをドロップすることに注意してください。ユースケースに合わせてルールをより細かく調整することを検討してください。
結果の信頼性が非常に重要な場合は、含まれているリゾルバリストに依存すべきではありません。代わりに、ローカルのunboundリゾルバを設定し、MassDNSにそのIPアドレスを指定してください。MassDNSを偵察ツールとして使用する場合は、最初にデフォルトのリゾルバリストで実行し、見つかった名前に対して信頼できるリゾルバのリストで再実行して誤検出を排除することをお勧めします。
単一の名前(例:example.com)のサブドメインを列挙する場合、サードパーティのリゾルバを単に除外しても構いません。その場合、権威ネームサーバーに直接問い合わせることもできます:
$ ./bin/massdns -r <(./scripts/auth-addrs.sh example.com) --norecurse -o Je example-com-subdomains.txt > results.txt