<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    Nmap結合vulscan和nmap-vulner掃描結果解析

    007bug2021-07-06 16:19:01

    工作需求

    工作過程中遇到高危端口掃描的需求,客戶要求對目標資產進行全端口掃描,并將開放的端口及該端口可能存在的CVE漏洞進行格式化輸出。由于目標較多,且客戶無POC探測需求。

    故使用nmap+vulscan+nmap-vulner+python腳本,基于軟件版本進行掃描并編寫python腳本將xml文檔解析為excel格式輸出

    基本知識-nmap常用參數

    復習一下nmap常見參數

    -sS          SYN半連接掃描,需root權限

    -sT          TCP三次握手掃描,較慢,不建議使用

    -sV          探測端口服務banner信息

    -Pn          不進行主機存活掃描,直接掃描指定端口

    -v           在shell界面顯示當前掃描過程

    -oN/oX/oG   將nmap掃描結果輸出為正常/XML/grep格式,建議格式為xml,掃描結果更完整,更易解析。

    -iL  file      讀取文本內容作為掃描目標

    --script xxx  使用內置腳本進行掃描

    NSE內置腳本下載安裝

    nmap-vulner和vulscan都是為了增強Nmap的版本檢測,為特定服務(如SSH,RDP,SMB等)生成相關的CVE信息。

    nmap-vulner腳本下載

    進入到nmap內置腳本目錄下

    cd /usr/share/nmap/script/

    下載腳本

    git clone https://github.com/vulnersCom/nmap-vulners.git

    更新腳本庫

    nmap --script-updatedb

    vulscan腳本下載

    進入到nmap內置腳本目錄下

    cd /usr/share/nmap/script/

    下載腳本

    git clone https://github.com/scipag/vulscan.git

    更新漏洞庫

    cd vulscan/utilities/updater/

    chmod+x updateFiles.sh

    ./updateFiles.sh

    掃描

    命令:

    結合vulscan和nmap-vulners兩個腳本進行掃描

    nmap --script nmap-vulners/ --script-args vulscandb=scriptvuldb.csv -sV -Pn 10.211.55.7 10.211.55.3 -v -p1-65535 -T4 --oX nmap.xml

    XML解析

    Python解析腳本如下:

    # -*- coding: UTF-8 -*-
    # @Time :2021/7/5 10:08 上午
    # @File :nmap_parser.py
    
    import xml.dom.minidom as xmldom
    import openpyxl
    
    firstline_list=["IP地址","開放端口","應用軟件","軟件版本","CVE漏洞編號"]
    info_list=[]
    
    with open("nmapxml.xml", "r", encoding="utf-8") as f:
    dom = xmldom.parse(f)  # 讀取xml文件
    root = dom.documentElement  # 獲得xml文件中的元素對象
    a = root.childNodes  # 獲得所有子節點
    
    # def ip_info():
    #     global ip_list
    #     for i1 in a:
    #         if i1.nodeName=="hosthint":
    #             ip=i1.getElementsByTagName("address")
    #             for i2 in ip:
    #                 if i2.getAttribute("addrtype") == "ipv4":
    #                     host=i2.getAttribute("addr")
    #                     ip_list.append(host)
    #         else:
    #             pass
    
    def port_info():
    host=root.getElementsByTagName("host")
    for i1 in host:
    a=i1.childNodes
    for i2 in a:
    if i2.nodeName=="address":
    if i2.getAttribute("addrtype")=="ipv4":
    # ip_list.append((i2.getAttribute("addr")))
    host=i2.getAttribute("addr")
    # ip_list.append(host)
    # print("存活主機:",host)  #輸出ip地址
    if i2.nodeName=="ports":
    # print(host)
    b=i2.childNodes
    for i3 in b:
    x=0
    x=x+1
    if i3.nodeName=="port":
    c=i3.childNodes
    for i4 in c:
    if i4.nodeName=="service":
    # print("port")
    #有幾個開放端口就有幾個ip地址
    # sheet.cell(row=1, column=i + 1).value = i3.getAttribute("portid")
    # port_info=i3.getAttribute("portid")+i4.getAttribute("product")+i4.getAttribute("version")
    # port_list.append(i3.getAttribute("portid"))
    # version_list.append(i4.getAttribute("product"))
    # version_list.append(i4.getAttribute("version"))
    
    portid=i3.getAttribute("portid")
    a=i4.getAttribute("product")
    product=a.replace(" ","")
    
    version=i4.getAttribute("version")
    info=host+" "+portid+" "+product+" "+version
    info_list.append(info)
    print("存活主機:",host,"開放端口:",portid,"banner:",product,version)#輸出端口banner
    
    if i4.nodeName=="script":
    d=i4.childNodes
    for i5 in d:
    if i5.nodeName =="table":
    e=i5.childNodes
    for i6 in e:
    if i6.nodeName == "table":
    f=i6.childNodes
    cve=' '
    for i7 in f:
    if i7.nodeName == "elem" and i7.getAttribute("key") == "id" and str(i7.firstChild.data).startswith("CVE"):
    # name1 = str(i7.firstChild.data)
    # # print(name1)
    # if name1.startswith("CVE"):
    #     vul_info=name1
    cve=i7.firstChild.data
    # vul_list.append(i7.firstChild.data)
    # print("CVE編號:",cve)
    info = host + " " + portid + " " + product + " " + version+" "+cve
    info_list.append(info)
    
    
    def data2excel():
    book = openpyxl.Workbook()
    sheet = book.active
    index=0
    for i in range(len(firstline_list)):
    sheet.cell(row=1,column=i+1).value=firstline_list[i]
    for i1 in info_list:
    index +=1
    listA=i1.split(" ",6)
    sheet.append(listA)
    book.save('nmap2excel.xlsx')
    
    
    
    if __name__ == '__main__':
    port_info()
    data2excel()
    

    解析結果如下:

    xml2excel輸出如下:

    nmaphost
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    網絡掃描:系統識別
    2021-08-02 16:57:52
    通過工具識別目標主機上的服務指紋信息。
    網絡掃描:服務識別
    2021-08-01 07:03:59
    這里的服務是指系統中用來提供服務的一些程序,如文件傳輸服務(FTP)、遠程登錄服務(SSH)等,在這些服務中包括一些指紋信息,如端口、服務名、提供商及版本等。本文介紹對服務信息進行識別的方法。
    標志信息是指一些主機或服務響應的歡迎信息或版本信息。例如,登錄FTP服務后,可能返回的標志信息為220(vsFTPd 3.0.3)或220 Welcome to blah FTP service.。這些信息可以幫測試人員確認服務類型。本文介紹獲取標志信息的方法。
    在實施局域網掃描之前,需要對其網絡環境有所了解,如網絡范圍、經過的路由等,然后才可以確定掃描的目標。本文對局域網網絡環境進行簡單介紹。
    vulnhub 靶場 napping
    2022-09-29 07:34:39
    信息收集主機發現:sudo nmap -sn 192.168.56.1/24. -sC Performs a script scan using the default set of scripts. It is equivalent to --script=default. Some of the scripts in this category are considered intrusive and should not be run against a target network without permission.-sV Enables version detection, as discussed above. Alternatively, you can use -A, which enables version detection among other things.-p This option specifies which ports you want to scan and overrides the default. Individual port numbers are OK, as are ranges separated by a hyphen . The beginning and/or end values of a range may be omitted, causing Nmap to use 1 and 65535, respectively. So you can specify -p- to scan ports from 1 through 65535. Scanning port zero is allowed if
    使用nmap+vulscan+nmap-vulner+python腳本,基于軟件版本進行掃描并編寫python腳本將xml文檔解析為excel格式輸出
    近期對nmap的操作系統識別功能造了個輪子,用golang實現了一遍,想未來能用于掃描器,資產發現/管理系統
    Nmap滲透測試指南
    2022-04-20 13:05:55
    nmap -sS -Pn -n --open --min-hostgroup 4 --min-parallelism 1024 --host-timeout 30 -T4 -v -oG E:\ip\result3.txt -iL E:\ip\ip.txt
    利用nmap腳本對MS SQL Server 進行滲透測試,獲取目標用戶名、數據庫表等信息。獲取數據庫版本信息使用ms-sql-info腳本獲取目標數據庫版本等信息nmap -p 14
    Nmap 經常使用的場景及用法。
    007bug
    暫無描述
      亚洲 欧美 自拍 唯美 另类