我有很多文件命名192.168.203.txt
为输出
sudo nmap -O --top-ports 192.168.203.* >>192.168.203.txt
输出如下所示:
Nmap scan report for 192.168.203.29
Host is up (0.00067s latency).
PORT STATE SERVICE
21/tcp closed ftp
22/tcp closed ssh
23/tcp closed telnet
25/tcp closed smtp
80/tcp open http
110/tcp closed pop3
139/tcp filtered netbios-ssn
443/tcp closed https
445/tcp filtered microsoft-ds
3389/tcp filtered ms-wbt-server
Device type: general purpose
Running: Microsoft Windows 2008|7
OS CPE: cpe:/o:microsoft:windows_server_2008::sp2 cpe:/o:microsoft:windows_7
OS details: Microsoft Windows Server 2008 SP2, Microsoft Windows 7 or Windows Server 2008 SP1
Network Distance: 6 hops
我只想192.168.203.29
用http
orssh
或其他端口 单独 grep IP open
。也许我会将所有结果通过管道IP
传输到一个名为http_open_ip.txt
.
我已经ftp
用命令尝试了 grep:
cat *.txt|grep -B 3 "ftp"|grep -B3 "open"|grep "192.168."|awk '{print $5}'|sort -t . -k 3,3n -k 4,4n> ftp_open_ip.txt
因此,我得到了一个文件ftp_open_ip.txt
。但我发现此命令不适用于其他关键字,例如ssh
stmp
. 我应该怎么办 ?