bash – 如何确定给定范围内的哪些IP具有使用nmap的端口80?
发布时间:2020-12-15 18:45:46 所属栏目:安全 来源:网络整理
导读:我完全不了解bash脚本,我正试图让这个工作: 扫描ip范围,查找端口80打开的设备… 我认为它必须如下所示: #!/bin/bashecho -----------------------------------for ip in 192.168.0.{1,.255}; donmap -p80 192.168.0.1 if #open; then echo "{ip} has the p
我完全不了解bash脚本,我正试图让这个工作:
扫描ip范围,查找端口80打开的设备… #!/bin/bash echo ----------------------------------- for ip in 192.168.0.{1,.255}; do nmap -p80 192.168.0.1 if #open; then echo "{ip} has the port 80 open" else #do nothing fi done echo ----------------------------------- exit 0 我也只是想看到这样的结果: ----------------------------------- 192.168.0.1 has the port 80 open 192.168.0.10 has the port 80 open 192.168.0.13 has the port 80 open 192.168.0.15 has the port 80 open ----------------------------------- (所以没有错误或nmap的正常输出..) 有人可以帮我吗?
nmap带有一个很好的输出参数-oG(grepable output),这使得解析更容易.也不需要遍历所有要扫描的IP地址. nmap是网络掩码.
你的例子可以写成: nmap -p80 192.168.0.0/24 -oG - | grep 80/open -oG启用grepable输出,并且 – 指定要输出的文件(在本例中为stdout).管道符号将nmap(stdout)的输出重定向到grep,在这种情况下,它只返回包含80 / open的行. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |