跳轉至內容

蟻群/PCAP

來自華夏公益教科書

使用蟻群解析 PCAP 檔案

對於您的 PCAP 檔案

    1. Save your PCAP file as a text file (this will be further referred to as <pcap filename>)

注意:您的自定義指令碼將自動儲存到以下位置

    .antfarm/scripts

當您在提示符($)處執行以下命令時

    $ antfarm

您將在“custom”下看到您自定義指令碼的名稱。

在您的 PCAP 檔案上執行蟻群 pcap 指令碼(除非檔名的一部分,否則不要在檔名中包含方括號)

    2. Run the following command at the prompt:
    $ antfarm -e <environment name> custom <PCAP script filename> <PCAP text file>
    3. For Antfarm version 0.3.0, the parse-pcap-file requires that network entries already exist in the database
       for BOTH the source IP and destination IP for any record in the pcap file or it will quietly ignore the record.
       For the newer version of Antfarm, if you use the—create-new-networks flag, it will create the network entry for 
       any new IPs.

對於單個 PCAP 檔案,請使用

    $ antfarm -e <environment name> custom <PCAP script> --create-new-networks <PCAP text file>

對於整個 PCAP 檔案目錄,請使用

    $ antfarm -e <environment name> custom <PCAP script> --create-new-newtorks <PCAP directory name/>

此時,您已經使用蟻群中的自定義 PCAP 指令碼(<PCAP 指令碼檔名>)解析了您的 pcap 檔案(<PCAP 文字檔案>),並且已將解析的資訊儲存到您的環境(<環境名稱>)中。

您可以透過執行以下命令在蟻群中檢視輸出(4. 對於流量檢視,5. 對於網路檢視)

    4. $ antfarm -e <environment name> viz display-traffic
    5. $ antfarm -e <environment name> viz display-networks

當從較大的 PCAP 檔案顯示流量流時,視覺效果在螢幕上變得難以閱讀。幸運的是,有一個選項可以幫助最大程度地減少這種情況。“collapse-ports”選項允許您僅為在 PCAP 檔案中發現的每個埠號包含一個節點。

    6. $ antfarm -e <environment name> viz display-traffic—collapse-ports

最新版本的蟻群顯示是靜態的,使用上面的命令。如果您想檢視顯示的動畫版本,請使用以下命令(以顯示網路為例)

    7. $ antfarm viz display-networks—active

有時,生成的 PCAP 檔案太大,請使用以下命令將 PCAP 檔案縮小到更合理的大小(透過資料包數量)

    8. $ editcap -r <Original PCAP Filename> <New PCAP Filename> <range of packets>
    Example:
    $ editcap -r Old_PCAP_File New_PCAP_File 5001-7200
    This example only takes packet numbers 5001-7200 from the old PCAP file and puts them in the new PCAP file.

示例 PCAP 指令碼

華夏公益教科書