我们可以利用DNS区域传输来查看目标的记录,首先我们要先知道一个域名服务器,因为域名服务器有所有主机的记录,dig @域名服务器 域 传输方法axfr(AXFR请求,是从DNS服务器请求在主DNS服务器上更新信息的一类域名系统的请求。)
我们先挑选一个ns记录,来进行区域传输;
root@kali:~# dig @ns2.sina.com sina.com axfr
;; Connection to 114.134.80.145#53(114.134.80.145) for sina.com failed: connection refused.
尝试连接53端口,连接被拒绝;换一个
root@kali:~# dig @ns4.sina.com sina.com axfr
; <<>> DiG 9.9.5-9+deb8u3-Debian <<>> @ns4.sina.com sina.com axfr
; (1 server found)
;; global options: +cmd
; Transfer failed.
失败
dns是基于UDP,TCP的53端口的(其实当解析器发出一个request后,返回的response中的tc删节标志比特位被置1时,说明反馈报文因为超长而有删节。这是因为UDP的报文最大长度为512字节。解析器发现后,将使用TCP重发request,TCP允许报文长度超过512字节。既然TCP能将data stream分成多个segment,它就能用更多的segment来传送任意长度的数据。
另外一种情况是,当一个域的辅助域名服务器启动时,将从该域的主域名服务器primary DNS server执行区域传送。除此之外,辅域名服务器也会定时(一般时3小时)向PDS进行查询以便了解SOA的数据是否有变动。如有变动,也会执行一次区域传送。区域传送将使用TCP而不是UDP,因为传送的数据量比一个request或response多得多。)
root@kali:~# host -h
host: illegal option -- h
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
[-R number] [-m flag] hostname [server]
-a is equivalent to -v -t ANY
-c specifies query class for non-IN data
-C compares SOA records on authoritative nameservers
-d is equivalent to -v
-l lists all hosts in a domain, using AXFR
-i IP6.INT reverse lookups
-N changes the number of dots allowed before root lookup is done
-r disables recursive processing
-R specifies number of retries for UDP packets
-s a SERVFAIL response should stop query
-t specifies the query type
-T enables TCP/IP mode
-v enables verbose output
-w specifies to wait forever for a reply
-W specifies how long to wait for a reply
-4 use IPv4 query transport only
-6 use IPv6 query transport only
-m set memory debugging flag (trace|record|usage)
root@kali:~# man host //查看该命令的基础用法
root@kali:~# info host //查看该命令的基础用法
root@kali:~# host -T -l sina.com 8.8.8.8 ns3.sina.com
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:
Host sina.com not found: 2(SERVFAIL)
; Transfer failed.
当我们不能进行区域传输时,我们可以使用字典爆破
root@kali:~# fierce -dnsserver 8.8.8.8 -dns sina.com.cn wordlist a.txt /usr/share/fierce/hosts.txt
DNS Servers for sina.com.cn:
ns3.sina.com.cn
ns2.sina.com.cn
ns4.sina.com.cn
ns1.sina.com.cn
Trying zone transfer first...
Unsuccessful in zone transfer (it was worth a shot)
Okay, trying the good old fashioned way... brute force
Checking for wildcard DNS...
** Found 97704271057.sina.com.cn at 202.102.110.204.
** High probability of wildcard DNS.
Now performing 2280 test(s)...
123.125.29.250 8.sina.com.cn
58.63.236.239 a1.sina.com.cn
58.63.236.237 a1.sina.com.cn
58.63.236.230 a1.sina.com.cn
58.63.236.230 a2.sina.com.cn
58.63.236.239 a2.sina.com.cn
58.63.236.237 a2.sina.com.cn
58.63.236.248 ad.sina.com.cn
121.14.1.189 ad.sina.com.cn
121.14.1.190 ad.sina.com.cn
121.14.1.190 ads.sina.com.cn
……
可以看到是先查询了所有的ns记录,然后去axfr,这个程序自带字典,我们查一下
dpkg -L fierce
安装dnsdict6
wget http://www.thc.org/releases/thc-ipv6-2.7.tar.gz
使用上面的命令会出现证书错误,在本机下载然后拖进虚拟,最后打开终端开始安装!
tar zvxf thc-ipv6-2.7.tar.gz
cd thc-ipv6-2.7
sudo apt-get install libpcap-dev libssl-dev
make
sudo cp dnsdict6 /usr/bin/
用来枚举域服务器的,它使用你提供的一个字典或者内置的列表来枚举
语法:dnsdict6 [-d46] [-s|-m|-l|-x] [-t 并发线程] [-D] 域名 [字典路径]
参数说明:
-4 显示ipv4
-t 指定要使用的线程 默认:8 最大:32
-D =================[只显示字典不扫描]====
-d 显示在DNS服务器上的NS(一种服务记录类型)MX(邮件服务器) ipv6 的域名信息
-e 忽略没有NS域错误
-S 执行SRV服务名称猜测
-[smlx] 选择字典大小[内置的] -s 小型是50条 -m 中等是796条[默认] -l 大型1416条 -x 最大3211条 -u最大的字典
root@kali:~# dnsdict6 -h
dnsdict6 v2.7 (c) 2014 by van Hauser / THC <vh@thc.org> www.thc.org
Syntax: dnsdict6 [-d4] [-s|-m|-l|-x|-u] [-t THREADS] [-D] domain [dictionary-file]
Enumerates a domain for DNS entries, it uses a dictionary file if supplied
or a built-in list otherwise. This tool is based on dnsmap by gnucitizen.org.
Options:
-4 do also dump IPv4 addresses
-t NO specify the number of threads to use (default: 8, max: 32).
-D dump the selected built-in wordlist, no scanning.
-d display IPv6 information on NS