使用 Nmap 执行第三层发现不需要实验环境,因为 Internet 上的许多系统都将回复 ICMP 回显请求。但是,强烈建议你只在您自己的实验环境中执行任何类型的网络扫描,除非你完全熟悉您受到任何管理机构施加的法律法规。如果你希望在实验环境中执行此技术,你需要至少有一个响应 ICMP 请求的系统。在提供的示例中,使用 Linux 和 Windows 系统的组合。有关在本地实验环境中设置系统的更多信息,请参阅第一章中的“安装 Metasploitable2”和“安装 Windows Server”秘籍。
### 操作步骤
`fping`非常类似于添加了一些额外功能的`ping`工具。 它可以以`ping`的相同方式,向单个目标发送 ICMP 回显请求,以确定它是否活动。 这通过将 IP 地址作为参数传递给`fping`实用程序来完成:
root@KaliLinux:~# fping -f iplist.txt 172.16.36.2 is alive 172.16.36.1 is alive 172.16.36.132 is alive 172.16.36.135 is alive 172.16.36.180 is alive
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.203
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.203
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.203
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.203
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.205
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.205
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.205
ICMP Host Unreachable from 172.16.36.180 for ICMP Echo sent to 172.16.36.205
172.16.36.203 is unreachable
172.16.36.205 is unreachable
172.16.36.254 is unreachable
```
### 工作原理
`fping`工具执行ICMP发现的方式与我们之前讨论的其他工具相同。 对于每个 IP 地址,`fping`发送一个或多个 ICMP 回显请求,然后评估所接收的响应以识别活动主机。 `fping`还可以用于通过提供适当的参数,来扫描一系列系统或 IP 地址的输入列表。 因此,我们不必使用`bash`脚本来操作工具,就像使用`ping`操作一样,使其成为有效的扫描工具。