【发布时间】:2019-05-27 10:13:34
【问题描述】:
我尝试将 nmap 扫描的结果保存到 txt 文件。我用这个命令
nmap -n -Pn -p T:3389 -T5 -sS -iR 0 | grep "scan" | awk '{ print $5 }' > test.txt
cat test.txt
输出如下所示:
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
它运行良好。
我只想扫描打开的端口,为此我尝试使用--open 选项,如下所示:
nmap -n -Pn -p T:3389 --open -T5 -sS -iR 0 | grep "scan" | awk '{ print $5 }' > test.txt
它不起作用,test.txt 是空的。我尝试使用tail -f test.txt 来查看实时结果,但它不起作用。有人可以解释一下我在做什么,错了吗?
我期待着第一次看到结果。
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
xx.xx.xx.xx
在我想添加端口号之后所有的ip都是这样的
xx.xx.xx.xx:3389
xx.xx.xx.xx:3389
xx.xx.xx.xx:3389
xx.xx.xx.xx:3389
xx.xx.xx.xx:3389
xx.xx.xx.xx:3389
为此我想使用sed -i s/$/:3389/ test.txt
我想知道是否有可能只用一个命令得到这个结果。
我尝试这样的事情:
nmap -n -Pn -p T:3389 --open -T5 -sS 192.168.0.1/24 | grep "scan" | awk '{ print $5 }' > test.txt; sed -i s/$/:3389/ test.txt
cat test.txt 这是结果:
192.168.0.2:3389
192.168.0.16:3389
addresses:3389
我不知道为什么地址:3389 出现在末尾。但这有效。
我想得到相同的结果,但使用这个命令:
nmap -n -Pn -p T:3389 --open -T5 -sS -iR 0 | grep "scan" | awk '{ print $5 }' > test.txt; sed -i s/$/:3389/ test.txt
我尝试了这个命令,但没有工作。我想在 bash 脚本中使用这个命令。感谢您提供任何帮助或建议。
nmap -n -Pn -p T:3389 --open -T5 -sS -iR 0
这是输出:
Nmap scan report for 187.3.104.223
Host is up (0.29s latency).
PORT STATE SERVICE
3389/tcp open ms-wbt-server
Nmap scan report for 118.89.215.203
Host is up (0.29s latency).
PORT STATE SERVICE
3389/tcp open ms-wbt-server
【问题讨论】:
-
你确定端口是开放的?
-
如果我只使用这个命令
nmap -n -Pn -p T:3389 --open -T5 -sS -iR 0它可以工作,但如果我尝试将结果保存在 txt 文件中。它不起作用 -
nmap -n -Pn -p T:3389 --open -T5 -sS -iR 0的输出是什么?可能输出中没有scan字,或者awk命令选择了错误的列。我们无法判断您是否不显示输出。 -
nmap -n -Pn -p T:3389 --open -T5 -sS -iR 0187.3.104.223 的 Nmap 扫描报告主机已启动(0.29 秒延迟)。 PORT STATE SERVICE 3389/tcp open ms-wbt-server Nmap 扫描报告 118.89.215.203 主机已启动(0.29 秒延迟)。端口状态服务 3389/tcp 打开 ms-wbt-server。在输出中是扫描Nmap scan report for 187.3.104.223 -
-iR表示“扫描随机地址”。无法保证您会在任何一致的时间内获得结果,因为您可能会扫描数千个地址,然后才能找到打开 3389 的地址。