【发布时间】:2017-10-26 05:32:33
【问题描述】:
我对带有-oG 选项的masscan 实用程序产生的输出有疑问(“grep-able”输出);例如,它输出:
# Masscan 1.0.3 scan initiated Wed Jun 4 01:35:02 2014
# Ports scanned: TCP(3;21-23,) UDP(0;) SCTP(0;) PROTOCOLS(0;)
Host: 192.168.100.19 () Ports: 2222/open/tcp////
Host: 192.168.100.13 () Ports: 2222/open/tcp////
Host: 192.168.100.16 () Ports: 443/open/tcp////
Host: 192.168.100.8 () Ports: 21/open/tcp////
Host: 192.168.100.5 () Ports: 22/open/tcp////
Host: 192.168.100.5 () Ports: 443/open/tcp////
Host: 192.168.100.16 () Ports: 80/open/tcp////
Host: 192.168.100.19 () Ports: 22/open/tcp////
Host: 192.168.100.7 () Ports: 80/open/tcp////
Host: 192.168.100.8 () Ports: 80/open/tcp////
Host: 192.168.100.12 () Ports: 2222/open/tcp////
Host: 192.168.100.13 () Ports: 22/open/tcp////
# Masscan done at Wed Jun 4 01:35:16 2014
以上内容可读性不好,也不好理解。
如何使用 Linux 命令行实用程序,例如sed,awk,或grep,使用上面的文件输出如下内容?
Host: 192.168.100.5
Ports: 22, 443
Host: 192.168.100.7
Ports: 80
Host: 192.168.100.8
Ports: 21, 80
Host: 192.168.100.12
Ports: 2222
Host: 192.168.100.13
Ports: 2222, 22
......
如您所见,输出在此布局中更具可读性: 按 IP 地址排序,与下面列出的所有 个关联端口,在具有相同 IP 地址的多个输入行中合并。
【问题讨论】:
-
“Ports:”之后缺少空格的单个实例是某种错字吗?