比方說您有以下NMAP輸出文件名爲「my_nmap_file.txt」
Starting Nmap 6.40 (http://nmap.org) at 2014-12-07 15:19 EST
Nmap scan report for 192.168.1.1
Host is up (0.020s latency).
Not shown: 991 closed ports
PORT STATE SERVICE
23/tcp open telnet
53/tcp open domain
80/tcp open http
139/tcp open netbios-ssn
445/tcp open microsoft-ds
3333/tcp open dec-notes
5555/tcp open freeciv
49152/tcp open unknown
49153/tcp open unknown
MAC Address: C4:3D:C7:8F:03:19 (Netgear)
Nmap scan report for 192.168.1.2
Host is up (0.025s latency).
All 1000 scanned ports on 192.168.1.2 are closed
MAC Address: 58:C3:8B:63:52:96 (Samsung Electronics)
Nmap scan report for 192.168.1.8
Host is up (0.058s latency).
All 1000 scanned ports on 192.168.1.8 are closed
MAC Address: F0:27:65:79:1A:B7 (Murata Manufactuaring Co.)
Nmap scan report for 192.168.1.6
Host is up (0.0000070s latency).
All 1000 scanned ports on 192.168.1.6 are closed
您可以嘗試在命令行
cat 'my_nmap_file.txt'|grep "Nmap scan report for *" |grep -o -E '[0-9.]+'|sed '1 s#.*#Your Gateway: &#'
這將匹配找到以下行類似下面並獲取IP地址
Nmap scan report for 192.168.1.2
輸出
Your Gateway: 192.168.1.1
192.168.1.2
192.168.1.8
192.168.1.6
注:我添加了一個用於第一線
稱爲'Your Gateway:'
小句話我注意到你也想打開端口的IP地址。假如匹配,你可以通過提供NMAP開放的端口給此次被消息。也許我們也可以找到這種模式。
這看起來像你得到你想要的,但你不想DNS解析?使用'-n'標誌來'nmap'。 – 2014-12-07 19:00:24