哇?用于 nmap 扫描的输出

awk? for output of nmap scan

我正在编写一个脚本来解析 nmap 输出以获取易受攻击的系统及其 IP 地址。

nmap 内容如下所示:

    Nmap scan report for 10.x.x.x
    Host is up (-0.031s latency).

    PORT    STATE SERVICE
    445/tcp open  microsoft-ds
    MAC Address: 00:50:56:89:6E:4B (VMware)

    Host script results:
    | smb-vuln-cve2009-3103: 
    |   VULNERABLE:
    |   SMBv2 exploit (CVE-2009-3103, Microsoft Security Advisory 975497)
    |     State: VULNERABLE
    |     IDs:  CVE:CVE-2009-3103
    |           Array index error in the SMBv2 protocol implementation in srv2.sys in Microsoft Windows Vista Gold, SP1, and SP2,
    |           Windows Server 2008 Gold and SP2, and Windows 7 RC allows remote attackers to execute arbitrary code or cause a
    |           denial of service (system crash) via an & (ampersand) character in a Process ID High header field in a NEGOTIATE

寻找这样的输出(如果可能的话):

    10.x.x.x
    SMBv2 exploit (CVE-2009-3103, Microsoft Security Advisory 975497)
    State: VULNERABLE

    Next Entry...

    Next Entry...

知道怎么做吗???感谢您花时间查看此内容...

如果您使用 Nmap 7.50 或更新版本,您可以将 --script-args vulns.short 添加到您的命令中,输出将缩短为:

| smb-vuln-cve2009-3103: 
|_  10.x.x.x VULNERABLE CVE-2009-3103

这更容易解析,因为所有必要的信息都在一行中。