Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
工具/GitHubGitHub/blechschmidt/massdns
OSINT (开源情报)侦察DNS和子域名枚举信息收集DNS 分析
GitHubblechschmidt/massdns

massdns

高性能DNS存根解析器,用于批量查询和侦察(子域名枚举)

查看仓库
3.6k5044个月前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
massdns — 高性能DNS存根解析器,用于批量查询和侦察(子域名枚举) | Kitploit

MassDNS

高性能DNS存根解析器

MassDNS是一个简单的高性能DNS存根解析器,专为需要解析海量域名(数百万甚至数十亿级别)的用户设计。无需特殊配置,MassDNS即可利用公开可用的解析器每秒解析超过35万个域名。

贡献者

  • Quirin Scheitle,慕尼黑工业大学

编译

克隆Git仓库并cd进入项目根目录。然后运行make从源代码构建。如果你不在Linux上,运行make nolinux。在Windows上,需要Cygwin的gcc-core、git和make包。

用法

root@kitploit:~
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。

示例

使用lists中的resolvers.txt解析器解析domains.txt中的域名的所有AAAA记录,并将结果存储在results.txt中:

root@kitploit:~
$ ./bin/massdns -r lists/resolvers.txt -t AAAA domains.txt > results.txt

这等同于:

root@kitploit:~
$ ./bin/massdns -r lists/resolvers.txt -t AAAA -w results.txt domains.txt

示例输出

默认情况下,MassDNS将以文本格式输出响应数据包,类似如下所示:

root@kitploit:~
;; 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文件,其中包含由subbrute项目提供的解析器的过滤子集。 请注意,使用MassDNS可能会对所使用的解析器造成显著负载,并导致滥用投诉发送到您的ISP。 另外请注意,所提供的解析器不能保证可信。解析器列表目前已经过时,其中很大一部分解析器已失效。

MassDNS的自定义无malloc DNS实现目前仅支持最常见的记录。欢迎通过协作来帮助改变这一点。

PTR记录

MassDNS包含一个Python脚本,允许您通过将相应查询打印到标准输出来解析所有IPv4 PTR记录。

root@kitploit:~
$ ./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脚本暴力枚举子域名:

root@kitploit:~
$ ./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抓取数据从证书透明度日志中提取子域名:

root@kitploit:~
$ ./scripts/ct.py example.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w results.txt

文件names.txt和names_small.txt(从subbrute项目复制而来)包含常用子域名的名称。也可以考虑使用包含超过1,000,000个名称的Jason Haddix的子域名汇编或包含超过9,000,000个名称的Assetnote词表。

MassDNS还在scripts文件夹中附带了一个recon.py包装脚本(beta状态),它直接对权威名称服务器执行子域名枚举,因此不需要第三方解析器。并发度由MassDNS自动确定,支持每秒数十万次查询,同时提供可靠的结果。在一台便宜的专用服务器上,可以在不到一分钟内枚举Assetnode词表。当前的限制是区域委派仅处理到委派点。例如,如果枚举example.org,并且sub.example.org委派给另一个名称服务器,则如果词表中包含abc.sub,该脚本将无法找到abc.sub.example.org。但脚本在这种情况下会报告为?.sub.example.org。

root@kitploit:~
$ ./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数据包,并为每个查询从指定前缀中随机选择一个源IPv6地址。这要求MassDNS以CAP_NET_RAW权限运行。使用此方法时,您应该使用iptables或nftables丢弃MassDNS接收到的DNS流量,以避免操作系统生成ICMP端口不可达响应,例如使用ip6tables -p udp --sport 53 -I INPUT -j DROP。请注意,此规则仅为示例,会丢弃所有DNS流量,包括其他应用程序的流量。您可能希望调整规则以更精细地适应您的用例。

结果真实性

如果结果真实性至关重要,您不应依赖附带的解析器列表。相反,设置一个本地unbound解析器,并向MassDNS提供其IP地址。如果您将MassDNS用作侦察工具,您可能希望先使用默认解析器列表运行它,然后在找到的名称上使用受信任解析器列表重新运行,以消除误报。

如果您正在枚举单个名称(例如example.com)的子域名,您可能希望简单地省略第三方解析器。在这种情况下,您可以直接探测权威名称服务器,如下所示:

root@kitploit:~
$ ./bin/massdns -r <(./scripts/auth-addrs.sh example.com) --norecurse -o Je example-com-subdomains.txt > results.txt

待办事项

  • 防止对应用速率限制或在一段时间后拒绝解析的解析器造成洪泛
  • 实现带宽限制
  • 使用跨解析器检查检测DNS投毒和DNS垃圾邮件(例如Level 3 DNS劫持)
  • 为侦察添加通配符检测
  • 通过添加一种模式来提高侦察可靠性,该模式通过受信任(本地)解析器列表重新解析找到的域名,以消除误报
  • 自动检测最佳并发度
  • 正确解析命令行,并允许在不使用空格的情况下使用/组合短选项
下载工具