0
的greppable Nmap的輸出如下所示:對於IP地址,主機,端口號,端口狀態,協議,服務和服務版本(如果有),我該如何awk或grep greppable Nmap輸出?
Host: 9.2.1.100 (hello.world.com) Status: Up
Host: 9.2.1.100 (hello.world.com) Ports: 21/closed/tcp//ftp///, 22/closed/tcp//ssh///,
23/closed/tcp//telnet///, 25/closed/tcp//smtp///, 80/open/tcp//http//Citrix Metaframe ICA Browser/,
110/filtered/tcp//pop3///, 139/open/tcp//netbios-ssn//Microsoft Windows netbios-ssn/,
443/closed/tcp//https///, 445/open/tcp//microsoft-ds//Windows Server 2003 3790 Service Pack 2 microsoft-ds/,
3389/open/tcp//ms-wbt-server//Microsoft Terminal Service/ Seq Index: 256 IP ID Seq: Incremental
我的問題是我怎麼用awk或grep來解析輸出,使我得到如下: IP地址,主機,端口狀態(限只有開放端口),協議,服務和服務版本(如果有的話)?
9.2.1.100\thello.world.com\t80\topen\ttcp\thttp\tCitrix Metaframe ICA Browser\n
9.2.1.100\thello.world.com\t139\topen\ttcp\tnetbios-ssn\tMicrosoft Windows netbios-ssn\n
...
指出端口列表從字段#5開始,只是從字段#5迭代到最後一個查找字符串'/ open /'。你最好使用'awk'。你必須記住,一個端口信息與下一個端口信息用逗號','分開。 – Jdamian