Nmap 探测网络服务

探测DHCP服务器

DHCP是局域网中的网络协议,用于在网络中自动分配IP地址.

DHCP发现

在Nmap中,通过使用dhcp-discover脚本从DHCP服务器上获取非常有用的信息,语法格式如下:

1
nmap -sU -p 67 --script=dhcp-discover <target>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 使用dhcp-discover进行DHCP发现
$ nmap -sU -p 67 --script=dhcp-discover 192.168.1.1
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-11 20:55 China Standard Time
Nmap scan report for 192.168.1.1
Host is up (0.020s latency).

PORT STATE SERVICE
67/udp open dhcps
| dhcp-discover:
| DHCP Message Type: DHCPACK
| Server Identifier: 192.168.1.1
| Subnet Mask: 255.255.255.0
| Router: 192.168.1.1
|_ Domain Name Server: 192.168.1.1
MAC Address: 28:93:7D:**:**:**

Nmap done: 1 IP address (1 host up) scanned in 6.56 seconds

探测DNS服务器

DNS可以将主机名解析为对应的IP地址.

获取DNS信息

Nmap中使用dns-nsid脚本获取DNS的详细信息,语法格式如下:

1
nmap -sSU -p 53 --script=dns-nsid <target>
1
2
3
4
5
6
7
8
9
10
11
# 使用dns-nsid获取DNS信息
$ nmap -sSU -p 53 --script=dns-nsid dns29.hichina.com
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-11 21:26 CST
Nmap scan report for dns29.hichina.com (139.224.142.109)
Host is up (0.034s latency).

PORT STATE SERVICE
53/tcp open domain
53/udp open domain

Nmap done: 1 IP address (1 host up) scanned in 0.91 seconds

使用字典暴力破解子域名

网站的域名下可以有多个子域名,通过子域名可以获取网站的更多信息,Nmap的dns-brute脚本可以采用字典暴力破解猜测子域名

1
2
3
4
5
6
7
8
9
10
11
12
13
└─# nmap --script dns-brute diaoan.xyz
Starting Nmap 7.92 ( https://nmap.org ) at 2022-02-11 22:22 CST
Nmap scan report for diaoan.xyz (121.199.61.226)
Host is up (0.033s latency).
PORT STATE SERVICE
80/tcp open http

Host script results:
| dns-brute:
| DNS Brute-force hostnames:
| www.diaoan.xyz - 121.199.61.226

Nmap done: 1 IP address (1 host up) scanned in 14.18 seconds

利用DNS服务发现协议获取DNS服务信息

DNS服务发现协议是一种用于局域网主机发现的协议.Nmap中利用dns-service-discovery脚本利用该机制

1
nmap --script=dns-service-discovery <target>

探测DNS服务器随机端口可预测漏洞

有写DNS服务区存在随机端口可预测漏洞,容易造成DNS缓存投毒攻击

1
nmap --script=dns-random-srcport <target>