关于nmap对于udp端口扫描的调查(-sU命令)

关于nmap对于udp端口扫描的调查

关于nmap对于udp端口扫描的调查(-sU命令)

官网对于-sU的解释:
While most popular services on the Internet run over the TCP protocol, UDP services are widely deployed. DNS, SNMP, and DHCP (registered ports 53, 161/162, and 67/68) are three of the most common. Because UDP scanning is generally slower and more difficult than TCP, some security auditors ignore these ports. This is a mistake, as exploitable UDP services are quite common and attackers certainly don’t ignore the whole protocol. Fortunately, Nmap can help inventory UDP ports.

UDP scan is activated with the -sU option. It can be combined with a TCP scan type such as SYN scan (-sS) to check both protocols during the same run.

UDP scan works by sending a UDP packet to every targeted port. For some common ports such as 53 and 161, a protocol-specific payload is sent to increase response rate, but for most ports the packet is empty unless the --data, --data-string, or --data-length options are specified. If an ICMP port unreachable error (type 3, code 3) is returned, the port is closed. Other ICMP unreachable errors (type 3, codes 0, 1, 2, 9, 10, or 13) mark the port as filtered. Occasionally, a service will respond with a UDP packet, proving that it is open. If no response is received after retransmissions, the port is classified as open|filtered. This means that the port could be open, or perhaps packet filters are blocking the communication. Version detection (-sV) can be used to help differentiate the truly open ports from the filtered ones.

A big challenge with UDP scanning is doing it quickly. Open and filtered ports rarely send any response, leaving Nmap to time out and then conduct retransmissions just in case the probe or response were lost. Closed ports are often an even bigger problem. They usually send back an ICMP port unreachable error. But unlike the RST packets sent by closed TCP ports in response to a SYN or connect scan, many hosts rate limit ICMP port unreachable messages by default. Linux and Solaris are particularly strict about this. For example, the Linux 2.4.20 kernel limits destination unreachable messages to one per second (in net/ipv4/icmp.c).

Nmap detects rate limiting and slows down accordingly to avoid flooding the network with useless packets that the target machine will drop. Unfortunately, a Linux-style limit of one packet per second makes a 65,536-port scan take more than 18 hours. Ideas for speeding your UDP scans up include scanning more hosts in parallel, doing a quick scan of just the popular ports first, scanning from behind the firewall, and using --host-timeout to skip slow hosts.

翻译成人话就是:
虽然 Internet 上最流行的服务运行在 TCP 协议上,但UDP服务被广泛部署。DNS、SNMP 和 DHCP(注册端口 53、161/162 和 67/68)是最常见的三种。由于 UDP 扫描通常比 TCP 慢且难度更大,因此一些安全审核员会忽略这些端口。这是一个错误,因为可利用的 UDP 服务非常普遍,攻击者当然不会忽略整个协议。幸运的是,Nmap 可以帮助清点 UDP 端口。
UDP 扫描通过该-sU选项激活。它可以与 TCP 扫描类型(例如 SYN 扫描 ( -sS))结合使用,以在同一运行期间检查两种协议。

UDP 扫描的工作原理是向每个目标端口发送一个 UDP 数据包。对于一些常见的端口,例如53和161,协议特定的有效载荷发送到增加反应速率,但对于大多数端口,除非该分组是空的–data, --data-string或者–data-length 被指定的选项。如果返回 ICMP 端口不可达错误(类型 3,代码 3),则端口为closed。其他 ICMP 不可达错误(类型 3,代码 0、1、2、9、10 或 13)将端口标记为filtered。有时,服务会以 UDP 数据包进行响应,以证明它是open。如果重传后没有收到响应,则该端口归类为open|filtered。这意味着端口可能是开放的,或者数据包过滤器可能会阻止通信。版本检测(-sV) 可用于帮助区分真正开放的端口和过滤的端口。

UDP 扫描的一大挑战是快速完成。打开和过滤的端口很少发送任何响应,让 Nmap 超时,然后重新传输,以防万一探测或响应丢失。封闭的端口通常是一个更大的问题。他们通常会发回 ICMP 端口不可达错误。但与关闭的 TCP 端口发送的 RST 数据包不同,以响应 SYN 或连接扫描,许多主机的速率限制 默认情况下,ICMP 端口不可达消息。Linux 和 Solaris 对此特别严格。例如,Linux 2.4.20 内核将目标不可达消息限制为每秒一条(in net/ipv4/icmp.c)。

Nmap 检测速率限制并相应地减慢速度,以避免目标机器将丢弃的无用数据包淹没网络。不幸的是,Linux 风格的每秒一个数据包限制使得 65,536 个端口扫描需要超过 18 个小时。加快 UDP 扫描速度的想法包括并行扫描更多主机、首先快速扫描常用端口、从防火墙后面扫描以及使用–host-timeout跳过慢速主机。

实验:
通过实验表明,他并不是完全发送的空的udp包,目前猜测他自己有一个常用端口列表,对于这个列表内的端口,他会向目标端口发送的数据包中有应用层协议,比如53端口,运行的是dns服务,在探测中就会发送dns包。对于列表中没有的端口,他才会发送空的udp包进行探测。具体的抓包结果如下:
对目的主机53端口进行udp扫描,具体抓包结果
在这里插入图片描述
对于目的主机不知名端口扫描(也就是nmap列表中没有的)
在这里插入图片描述
这回他发送的包才是空的udp包

总结:
nmap在测试udp端口是否开放的时候,对于一些常用端口,为了加快目标主机的返回包的速度,回发送相应应用层协议的包;对于其他端口只是发送空的udp包
在接受包的过程中,如果返回 ICMP 端口不可达错误(类型 3,代码 3),则端口为closed状态,如果返回UDP 数据包进行响应,证明它是open。但是大多是udp端口是不给相应的回应的,这种就比较难办了,因为不给返回结果的情况很多,比如端口是开放的本身udp就不需要返回东西,可能端口是关闭的,但是有些操作系统回限制icmp的发包频率,就会导致端口关闭可能也不返回东西。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值