【问题标题】:grep nmap output , print select linesgrep nmap 输出,打印选择行
【发布时间】:2020-04-29 08:39:15
【问题描述】:

我刚刚完成了对我内部网络上的主机的扫描...它对 smb 很敏感,我需要从扫描结果中 grep 选择行

    root@kali:~# nmap -p445 --script smb-vuln-* 192.168.99.50
Starting Nmap 7.80 ( https://nmap.org ) at 2020-01-13 00:21 EET
Nmap scan report for 192.168.99.50
Host is up (0.19s latency).

PORT    STATE SERVICE
445/tcp open  microsoft-ds
MAC Address: 00:50:56:BA:7F:57 (VMware)

Host script results:
| smb-vuln-ms08-067: 
|   VULNERABLE:
|   Microsoft Windows system vulnerable to remote code execution (MS08-067)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2008-4250
|           The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, Server 2003 SP1 and SP2,
|           Vista Gold and SP1, Server 2008, and 7 Pre-Beta allows remote attackers to execute arbitrary
|           code via a crafted RPC request that triggers the overflow during path canonicalization.
|           
|     Disclosure date: 2008-10-23
|     References:
|       https://technet.microsoft.com/en-us/library/security/ms08-067.aspx
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4250
|_smb-vuln-ms10-054: false
|_smb-vuln-ms10-061: false
| smb-vuln-ms17-010: 
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|        servers (ms17-010).
|           
|     Disclosure date: 2017-03-14
|     References:
|       https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
|       https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143

Nmap done: 1 IP address (1 host up) scanned in 7.11 seconds

我只想grep testes vuln的名称和状态:像这样

| smb-vuln-ms08-067: 
|   VULNERABLE:
| smb-vuln-ms10-054: false
|_smb-vuln-ms10-061: false
| smb-vuln-ms17-010: 
|   VULNERABLE:

【问题讨论】:

    标签: grep nmap scanning


    【解决方案1】:

    通过下一个管道过滤nmap的输出:

    sed -e '/^..smb-vuln-[^:]*: false/p' -e '/^..smb-vuln-[^:]*: *$/{n;p}' -e d
    

    解释:

    1. 第一个 sed 命令打印以特定模式开头的行 并以“:假”结尾
    2. 第二个命令打印开始的行 具有相同的模式,但在“:”之后没有任何内容,还有 下一行; {n;p} 表示添加下一行并打印
    3. 第三条命令d 会从输出中删除所有其他内容

    【讨论】:

      猜你喜欢
      • 2016-07-15
      • 1970-01-01
      • 2016-08-30
      • 2013-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多