starPt
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    17
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # wireshark 惡意流量分析 ###### tags: `malware` ## 打造客製化的 wireshark 欄位 一般的 wireshark 不是專門用來做惡意流量分析的,所以有些欄位不太需要而需要的欄位又沒在上面,所幸 wireshark 這個神器可以方便的客製化,所以很輕易的打造專屬自己的惡意流量分析工具是非常容易的 下面的資料都是從[這篇](https://unit42.paloaltonetworks.com/unit42-customizing-wireshark-changing-column-display/)學來的 做惡意流量分析需要的幾個欄位: * time * source ip * source port * destination ip * destination port * host * server name * info ### 新增 source/destination port 預設的幾個欄位可以透過對著 column 欄位右鍵 -> column preference ![](https://i.imgur.com/5TvoGPN.png) 然後把不必要的欄位按 '-' 符號刪除,另外透過 '+' 符號新增欄位,這邊要新增的是 port 欄位,選單可以下拉找到 src/dest port (unresolved) 新增 ### 新增 domain name 欄位 接著要找 domain name ,這個可以從一堆封包中的 http 封包的 fragmenet windows 找到 HyperText Protocol 找到 Host ,對著 host 按右鍵然後選 apply as column 即可 ![](https://i.imgur.com/afjesni.png) 找 http 封包只要看 port 為 80 且不是那些 handshake 的封包即可 ### 新增 https host 欄位 在 fileter 輸入 `ssl.handshake.type == 1` 就可以找到 https 封包,然後從 fragment window 找到 TLS ,再從 TLS 找到 handshake protocol (複習一下 handshake protocol 負責非加密的部分),再從中找到 Extension: server name 找到最像 server name 的那行,一樣 apply as column 即可 ![](https://i.imgur.com/TGwSkhz.png) ![](https://i.imgur.com/fomOMc1.png) ### 總結 雖然目前還不知道為啥惡意流量要看這些東西,不過相信之後的教學一定會明白為什麼的,感謝 [Brad Ducan](https://twitter.com/malware_traffic) >< ## Using wireshark - Display Filter Expressions [學習來源](https://unit42.paloaltonetworks.com/using-wireshark-display-filter-expressions/) 這算是 Brad 教學的第二篇,這次多了一堆 malware-traffic ...,主要涵蓋以下幾個技術: * 感染路徑的跡象 * wireshark 顯示過濾器 * 保存過濾器 * 基於網頁的感染流量 * 基於其他種類的感染流量 ### 感染路徑的跡象 這邊主要講的是會惡意的大量發送垃圾郵件的 malware ,感染途徑通常是 windows 執行檔感染了主機 跡象從感染相關的網路流量而得,而跡象也會被當成入侵指標 (IOC) ,專業的人員會記錄這些網路流量的 * url * domain * ip address * protocol * ports 上述項目都可以透過 display filter 快速在 wireshark 定位 ### wireshark display filter expression display filter 會根據使用者的輸入提供一些幫助: * type * 輸入前幾個字串會顯示可以被接受的字串 * color * red * 目前輸入的字串不能跑 (not accepted) * green * 目前輸入的字串可以跑 * yellow * 可以跑但可能並未如預期執行 另外表達式的部分, wireshark display filter 採用 boolean expression ,以下是相關的 condition 寫法 * condition * AND: and/&& * OR: or/|| * EQUAL:eq/== 如果要取反的話,**不要用 expression != expression ,用 !(expression == expression)**,否則後面的 expression 會出錯 ### Filters for Web-Based Infection Traffic malware: Emotet and IcedID 這個 malware 流量是在 win7 host 上截下來, 這些流量中其中一部份是 SSDP request [1] 對我們來說其實不重要又很礙眼,一個簡單的 display filter expression 搞定: `(http.request or tls.handshake.type == 1) and !(udp.port == 1900)` 透過指定不要 udp port 為 1900 的封包即可過濾掉 SSDP request wireshark 其實可以用: `(http.request or tls.handshake.type == 1) and !(ssdp)` ![](https://i.imgur.com/fzvnRah.png) 以上過濾出來的就是從被感染的 host 發送出去的 http request 或 https 第一次做連線所發出的 [client hello](https://tools.ietf.org/html/rfc5246#section-7.4.1.2) package 不過這不是全部的感染指標,也有可能感染的 host 對 server connection 卻失敗( server 沒開或拒絕連線),這時候可以搜尋 tcp 的 syn segments 找到這種封包: `tcp.flags == 0x0002` 最終的 filter expression: `(http.request or tls.handshake.type == 1 or tcp.flags == 0x0002) and !(ssdp)` ![](https://i.imgur.com/iVpNyLc.png) host 對 217.165.2.133 的連接因為 server 問題沒回應導致有了 tcp syn segment 之所以只找 http, https 的封包是因為這個 malware 主要是透過 web 感染 [1]: SSDP 為一種應用於 UPnP 的協定, client 作為接受服務的端點發出 SSDP request 探查 lan 裡面有沒有能提供的服務, server 作為提供服務的一方則發出 SSDP request 告知 lan 其他端點自己可以提供服務。 ### Filters for Other Types of Infection Traffic 很多 malware 會用 web 以外的方式跟被感染的 host 互動,像是直接透過 ip address 或 domain name ,這時候檢查有無 domain 活動就很重要 直接用以下 expression 查詢有無 dns 活動: `(http.request or tls.handshake.type == 1 or tcp.flags == 0x0002 or dns) and !(ssdp)` #### DNS activity ![](https://i.imgur.com/EfO60yy.png) 該例子是 Nanocore RAT ,可以看到先是透過 http 從 www.merceds-club-bg[.]com 下載了 mko.exe 然後透過 tcp 去連 franex.sytes[.]net 和 franexserver.dnsduck[.]org 兩個 host #### ftp 另一種是利用常見的 protocol 如 ftp 做連接,以某個 ftp malware 來看 ![](https://i.imgur.com/wv5XDuj.png) 可以看到 malware 向 dns 請求解析 ftp.totallyanonymous[.]com 的 ip 然後用 ftp 連接 (port 21),不過因為 filter expression 沒有納入 ftp 所以看不到相關活動 :::warning 中間有一段用 http 連接不確定在幹嘛,根據 blog 所說應該是先連線到其他 server 然後紀錄 ip 確保該 ip 可以連到 ftp server ::: 知道透過 ftp 連接後,在 expression 輸入 `ftp` 就可以看到 ftp 相關的封包 ![](https://i.imgur.com/wr0BcIe.png) 從中可以發現幾個訊息: * user: schw@totallyanonymous[.]com * password: 520s984W * download file: * fc32.exe * 670720 bytes * o32.exe * 128000 bytes 另外再更下面的地方有用到 ftp 的 command: stor(相關命令參考[這邊](https://zh.wikipedia.org/wiki/FTP%E5%91%BD%E4%BB%A4%E5%88%97%E8%A1%A8)) ,表示上傳資料存到 ftp server ![](https://i.imgur.com/kw9fn7w.png) 因為 ftp 連線並沒有加密,所以我可以找到上傳什麼資料上去,因為這種屬於 data 傳輸,所以 google 了一下 wireshark 針對 ftp data 有沒有什麼 expression 好用,被我找到: `ftp-data.command` ![](https://i.imgur.com/DWxsWXp.png) 可以看到前半段是下載 o64.exe 的部分,後半段則是上傳 6R7MELYD6 到 server ,對著該行右鍵-> Follow -> TCP stream 可以看到完整的檔案內容: ![](https://i.imgur.com/QXiXhMM.png) ![](https://i.imgur.com/6l6cObk.png) #### smtp 除了 ftp , malware 也可能透過 smtp 來傳播,像是 spambot malware 就會從感染的主機往外發送成千上萬封的垃圾郵件 這次例子換成另一個不知名的 spambot malware ,一樣的過濾起手式: `(http.request or tls.handshake.type == 1 or tcp.flags == 0x0002 or dns) and !(ssdp)` ![](https://i.imgur.com/M7847Xf.png) 可以發現大量的請求 dns server 解析 smtp 相關的 server ip 且後面的 465, 587 port 為常見的 email port 更可以確定這件事 知道跟 smtp 有關就直接過濾 smtp 的封包就好 `smtp` ![](https://i.imgur.com/aN13cDq.png) 現今大多數的 SMTP 都是採用 encrypted smtp (port 587 的應該都是 ESMTP) 但還是可以碰碰運氣搜尋有沒有包含以下字串: * From: * Message-ID: * Subject: 搜尋的 filter expression: `smtp contains "From:"` 依此類推(**Wireshark 是 case-sensitive**) ![](https://i.imgur.com/BHM9taD.png) 一樣可以透過 follow tcp stream 的方式看內容是什麼: ![](https://i.imgur.com/M3yaRtK.png) 下面好像是用 base64 encode ,不過我沒查看 ### 保存常用的 expression 過濾起手式可以保存在 wireshark 內,不用每次都打: ![](https://i.imgur.com/uw0zv7d.png) label 填這項 filter expression 名稱 filter 填 expression 保存即可 * basic * (http.request or ssl.handshake.type == 1) and !(udp.port eq 1900) * basic+ * (http.request or ssl.handshake.type == 1 or tcp.flags eq 0x0002) and !(udp.port eq 1900) * basic+DNS * (http.request or ssl.handshake.type == 1 or tcp.flags eq 0x0002 or dns) and !(udp.port eq 1900) ### 總結 原本想說有個基本概念就好,不過實際操作後覺得還是滿有趣的,很像偵探在找線索XD ,不過對於一些常見的 protocol 還是要知道一些基本的知識分析起來才比較有效率 ## 識別 hosts 和 users 今天這篇有滿多不知道的名詞...雖然有紀錄些基本的筆記,但細節還要考究一下 host info 可以用以下幾種封包識別: * Host information from DHCP * Host information from NBNS * Device model and operating system from HTTP user-agent * Windows user accounts from kerberos 其中 NBNS 和 kerberos 是沒接觸過的,所以要先找一下資料 * NBNS: NBNS 應該是 DNS 的前輩,功用跟 DNS 差不多,都是把 hostname 和 ip 做對應,目前應該是因為向下兼容的原因將 NBNS 保存在 TCP 協定裏面 * Kerberos: MIT 發展出的協定,專門用於在不安全的網路通訊環境下做身分驗證,主要透過對稱加密實現,不過也有公鑰加密方法,而 windows 在 windows 2000 年後將 kerberos 作為默認認證方法 keberos 的傳輸方法主要是透過公正第三方對通訊的兩方進行身分驗證然後發送一個暫時性的 session key (用用戶的密碼雜湊後的密鑰加密過),並將此 key 用作通訊的密鑰用,這也是對稱密碼解決密碼配送問題的方法之一──密鑰分配中心 ### DHCP 識別 hostname filter expression: `dhcp` 找 dhcp request -> DHCP frame ,找到 client identifier 和 hostname ![](https://i.imgur.com/Y6rqeRo.png) 資訊: * ip address: 172.16.1.207 * MAC: 7c:6d:62:d2:e3:4f * hostname: Rogers-iPad 這邊可以猜測是從 ipad 發出,不過不要太相信這個資訊 :::info 教學中的 bootstrap protocol 其實是 dhcp protocol 的前身,現在 wireshark 都用 dhcp protocol 所以名稱不一樣是很正常的 ::: ### NBNS 識別 hostname filter expression: `nbns` ![](https://i.imgur.com/LjmwoI1.png) 資訊: * src ip: 10.2.4.101 * mac: 00:01:e6:69:53:5a * hostname: MARTIN-WIN-PC 打開 NetBIOS Name Service 也可以看到: ![](https://i.imgur.com/xsBEoCI.png) ### 識別出設備和操作系統 http 的 user-agent field 會告訴伺服器目前是用什麼 browser 連上去的,好讓伺服器針對工具提供不同的功能,不過 user-agent 可以亂改(連開發人員都在改 XD),所以現在看起來比較雜亂,但還是有有用的資訊 [參考](https://yulun.me/2013/mozilla5-0-always-user-agent-string/) #### PC 因為要找出發送流量的機器的資訊,所以要透過 http request 來看 filter expression: `http.request and !(ssdp)` 看到發送到 ucla[.]com 的 request 並用 tcp stream 查看: ![](https://i.imgur.com/tXpayWL.png) 資訊: * OS: Win7 x64 * Browser: Chrome 關於這個 field 那麼亂的原因可以看上面的參考資料 XD Windows NT 6.1 的部分是 windows OS 的實際作業系統版本, 使用該 kernel 版本的發行有兩個: windows 7 和 windows 2008 r2 ,所以可以看出是透過 win 7 x64 的作業系統配上 chrome 的瀏覽器 (因為其他都是 apple 的瀏覽器 XD , Mozilla 則是每個 user-agent 都會有) #### Mobile ##### Android 手機的部分, android 會提供設備型號和安卓版本 filter expression: `http.request` 因為手機沒有一堆 ssdp packet 的困擾,所以直接 http.request 就可以了 ![](https://i.imgur.com/kpqfJ3A.png) 資訊: * android version: 7.1.2 * device model: LM-X210APM google 一下型號就知道這是台 lg 的手機 ##### Apple 蘋果的不會提供設備型號,只會告訴你是 ipad, iphone filter expression: `http.request` ![](https://i.imgur.com/oyLwwVH.png) 資訊: * IPhone * OS version: IOS 12.1.3 #### 幾個注意事項 1. 不是所有 http traffic 都是透過 browser 來傳輸的,要檢查其他 http request 2. HTTPS 的 header 和 content 都是不可視的 ### Kerberos filter expression: `kerberos` kerberos 協定使用者會先向密鑰分配中心發送 AS-req 的封包,告知準備要傳 進行通訊,所以鎖定 as-req 的封包 ![](https://i.imgur.com/yQMfnxi.png) 資訊: * Client Name: johnson-pc$ 想看發送雙方的名稱可以對著 CNameString 右鍵 -> apply as column 新增一個 column 用來觀察 ![](https://i.imgur.com/KbvzgSe.png) kerberos 中 hostname 會以 $ 結尾,而 user account 不會 ## 從 wireshark 中 export object 在分析惡意流量時會需要從可疑流量中提取 malware 之類的物件,以下講授幾種協定的 export object 方法: * HTTP * SMTP * FTP * SMB :::info SMB 是微軟開發的網路檔案分享系統(Common Internet File System) ,他能共享檔案、 serial port 、 printer 、 通訊等資源以及 IPC 等功能 ::: ### HTTP #### filter filter expression: `http.request` ![](https://i.imgur.com/H1pBZ1W.png) 可以看到 host 對 smart-fax[.]com 發出 http request ,要求下列檔案: 1. Invoice&MSO-Request.doc 2. knr.exe #### export 可以從 tool bar 上 file -> export object -> http 選擇要 export 的 object ![](https://i.imgur.com/cowPHlP.png) ![](https://i.imgur.com/8HjVvlA.png) content type 是透過 http header 決定的,**有些 malware 會竄改欄位躲避檢查** #### 分析 因為是 windows 的 malware ,保險一點在 mac 或是 linux 上分析,透過 file 指令可以大概看一下檔案類型, sha256sum 則可以確定是同個檔案 等等再到 linux #### 查看網頁 除了檔案,網頁內容也可以透過相同的方式得到 (網頁本質上就是瀏覽器載入 server 的網頁檔案並呈現) 從一樣的表達式過濾後可以看到該流量應該是訪問了一個網站: ![](https://i.imgur.com/BCaKLwS.png) 一樣的方式 export 保存為 html 檔再用 browser 開啟就是一個假造的 paypal 網頁 ![](https://i.imgur.com/ww5NvKZ.png) ### SMB 有些 malware 會透過 SMB 的 Activity Directory 傳播 AD 為 Windows server 中負責架構中大型網路管理服務,其管理範圍包括: user, group, computer, controller, mail etc. 這次要分析的是一個叫 trickbot 的 malware 從感染的主機 10.6.26.110 到 10.6.26.6 controller 散播的流量 #### export tool bar -> file -> export objects -> SMB ![](https://i.imgur.com/doaNIiM.png) #### 分析 從 packet 7058 和 7936 可以看到傳輸了兩個檔案: * \WINDOWS\d0p2nc6ka3f_fixhohlycj4ovqfcy_smchzo_ub83urjpphrwahjwhv_o5c0fvf6.exe * \WINDOWS\oiku9bu68cxqenfmcsos2aek6t07_guuisgxhllixv8dx2eemqddnhyh46l8n_di.exe 特別注意到 content type 中有 100% ,這代表檔案傳輸過程中無丟失 當然這邊跟 http 一樣可以 save 再分析 ### SMTP 也有 malware 感染後專門發送大量惡意或垃圾郵件,稱之 spambot #### filter filter expression: `smtp.data.fragment` ![](https://i.imgur.com/52tHBWt.png) 可以看到大量郵件內容 #### export SMTP 的 export 一樣是透過 tool bar -> file -> export objects -> IMF 這邊的 IMF 代表 Internet Message Format ![](https://i.imgur.com/lgrorlL.png) 下載來的檔案格式為 eml ,應該是 email 縮寫,可以透過 text editor 打開: ![](https://i.imgur.com/HZ91Mb1.png) ### FTP #### filter FTP 可以先看一下 command: filter expression: `ftp.request.command` ![](https://i.imgur.com/gSkNvTM.png) 可以看到 username, password, 檔案 接下來鎖定 ftp 檔案的部分 filter expression: `ftp-data` ![](https://i.imgur.com/Us0CiOT.png) #### export 這邊不能 export objects ,但是可以直接透過 follow tcp stream 拿到檔案內容 ![](https://i.imgur.com/wBelfnJ.png) 將檔案用 raw 的方式保存下來就是完整的檔案了 另外可以將 sha256sum 的結果送去 virustotal 檢查 ![](https://i.imgur.com/11u40xr.png) 其他檔案照做即可 #### 分析 html 當分析 ftp traffic 要特別留意從 host 存回 ftp server 的 html 檔案 (其他格式不確定...) ,因為每次被感染的都會回傳同樣的 html 到 server filter expression: `ftp.request.command` ![](https://i.imgur.com/ESy0ALE.png) 因為要從 ftp-data 找 html 檔案,可以透過 contains 語法找特定 pattern filter expression: `ftp-data.command contains html` ![](https://i.imgur.com/Df8O6ag.png) 可以發現 malware traffic 分別向 52202, 57791, 55045, 57283, 61099 幾個 port 傳輸了相同檔名的 html 檔案 一樣用 tcp stream 的方式並用 raw 的格式保存下來 打開可以發現是蒐集到的 accounts 和 password 等資訊,五個都一樣 ## 案例分析: TrickBot distributed from malspam ### 初步分析 這邊純粹就是案例分析,利用之前學的技術分析用 spambot 散播的 trickbot malware 我試著用之前學到的技巧快速分析整個流量,詳細版本在後面 (畢竟還是太青澀了,很多東西沒分析到...) 用 wireshark 打開 pcap 後翻了一下封包看是屬於哪個協定的,找到有: * NBNS * DNS * HTTP * HTTPS/TLS/SSL 根據 DHCP 的封包判定 host 的一些資訊: ![](https://i.imgur.com/O5oeZiy.png) * hostname: Hewlettp_lc * ip: 10.9.25.101 * MAC: 00:08:02:1c:47:ae 接下來依序看每個協定的封包在幹啥: * NBNS * Register WORKGROUP * Register BACHMAN-BTO-PC * DNS * www.dchristjan[.]com -> 23.229.232[.]193 * wpad[.]localdomain -> * api.bing[.]com -> 13.107.5[.]80 * www.bing[.]com -> 204.79.197[.]200 * iecvlist.microsoft[.]com -> 72.21.81[.]200 * r20swj13mr.microsoft[.]com -> 72.21.81[.]200 * dns.msftncsi[.]com -> 131.107.255[.]255 * time.windows[.]com -> 13.86.101[.]172 * HTTP * www.dchristjan[.]co -> download dd05ce3a-a9c9-4018-8252-d579eed1e670.zip * 144.91.69[.]195 -> solar.php * www.download.windowsupdate[.]com -> authrootstl.cab * 170.238.117[.]187 * 185.98.87[.]185 -> tablone.png & samerton.png * 170.238.117[.]187:8082 * HTTPS/SSL/TLS * iecvlist.microsoft.com * r20swj13mr.microsoft.com * ident.me * www.googleapis.com * accounts.google.com * mtalk.google.com * android.clients.google.com * www.gstatic.com #### DHCP 和 NBNS 裡面最不熟的就是 DHCP 和 NBNS DHCP 從 Wiki 上來看應該是 client 向 server 索取動態 ip ,所以 infected machine 應該要看 client identifier 的資訊 NBNS 則是類似 DNS 的服務,不過解析名稱的工作是 [WINS](https://zh.wikipedia.org/wiki/WINS) 處理,以下是常見的場景: 1. WINS 用戶端(主機 A)=> 在WINS 登記 自己的主機名稱及IP 2. WINS 用戶端(主機 B)=> 去尋問 A 主機所在位址(IP) 3. WINS-伺服器回應給(B主機)A 的 IP 位址 (192.168.100.20) 回覆。 所以在流量中看到的 register 應該就是第一步的部分 #### DNS dns 是用來解析域名,所以透過 dns 可以看到機器想要訪問哪個網站,列表中有不少個是正常的網站滿令人問號的... #### HTTP http 就熟悉許多,看到機器去訪問網站還有下載 zip, php, png 等檔案, zip 有 export 出來, php 和 png 以為是普通網頁檔案就沒看 (就是這邊太嫩了....QQ) #### HTTPS 因為加密的緣故,我只看到跟哪個網站連接,當然名字都很奇怪,不過因為連接被加密過所以沒啥東西好看,就放棄觀察 (這邊也不對 QQ) ### 正式分析 #### filter and classification 透過之前的 filter expression: basic 過濾掉一些沒用的後,可以關注到以下的流量封包: * ip checked * http/ssl/tls 到 port 443, 447, 449 * tcp port 8082 * http request 要求一些 png 檔案 **以協定、 port 做個簡單的分類** #### analysis objects 從 http 流量中可以明顯發現下載了一個 .zip 檔案和看似網頁的 solar.php ![](https://i.imgur.com/WHPS1x9.png) 但透過 follow tcp stream 卻發現: ![](https://i.imgur.com/nHyzv4U.png) 首先看到 content-type: applicatoin/octet-stream ,根據[此篇](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types) octet-stream 屬於那種未知的應用程式, browser 不會直接執行 content-disposition 的 filename 則說明該檔名為 phn34ycjtghm.exe ,而下面的內容則可以透過最開始的 MZ 看出是一個 windows 執行檔,因此這個 solar.php 實際上是一個執行檔! **看流量不要被顯示檔名騙了, 要實際看過內容才能做判斷** 載完執行檔後接下來匪夷所思的對一堆 port 443 嘗試進行 tcp 連接,直到最後對 187.58.56[.]26 才成功 ![](https://i.imgur.com/ymeNnZ8.png) 接下來會遇到一些 https 流量,之前覺得 https 流量都被加密過沒啥好看,但仔細觀察憑證的部分: ![](https://i.imgur.com/UF9Lg4N.png) 跟正常的憑證其實長的不太一樣,挑一個 https 連到正常網站的憑證比對下: ![](https://i.imgur.com/VMcr8Ws.png) 很多 malware 會對被感染的機器做 ip checked ,用一些正常合法的網站去檢查,以下是常見列表: * api.ip[.]sb * checkip.amazonaws[.]com * icanhazip[.]com * ident[.]me * ip.anysrc[.]net * ipecho[.]net * ipinfo[.]io * myexternalip[.]com * wtfismyip[.]com 再往下看,可以看到有個連接到 port 8082 的 http post 流量,透過 follow tcp stream 可以發現: ![](https://i.imgur.com/6O85CyM.png) ![](https://i.imgur.com/k7idzu1.png) 上傳了受害者的帳密和正在執行的 process 列表 **看到可疑且可以分析的流量就盡量去分析,看看實際上到底做了什麼,不要放過** 再往下看,可以看到一些透過 http get 下載的 png 檔,一樣透過 follow tcp stream 查看: ![](https://i.imgur.com/Acet4gR.png) 可以確定是一個執行檔,這些執行檔是用來感染在 AD 中有漏洞的 domain server (不知道從何判定,可能要實際分析 malware) **封包之間可能有間接的關係,需要深入分析 malware** ## 案例分析: trickbot distributed from other malware 這次分析從 Emotet 下載 trickbot 然後執行的 malware traffic **惡意流量中可能包含數個 malware 的流量** 有經驗的分析師可以看出 Emotet 比較常用 http 而 trickbot 比較常用 https/ssl/tls 控制 C2 ![](https://i.imgur.com/SPNUciF.png) 根據文章敘述, 10.9.25.102 為 ad 中的 windows client 而 10.9.25.9 則是 domain controller (沒明說怎麼知道,當作是因為環境設定如此),這邊主要探討 malware 如何從 infected window client 感染到 domain controller 從 basic+ 可以看到 10.9.25.102 從 185.98.87.185 下載了 wredneg2.png ,實際上是 trickbot 執行檔 ![](https://i.imgur.com/PtLlii0.png) :::info 我可以看的出這是 malware 但看不出哪裡有線索說明這是 trickbot malware = = ::: 如果看向下載 wredneg2.png 前的 tcp syn 的話,打開 tcp stream 會發現: ![](https://i.imgur.com/PyqdNoj.png) ![](https://i.imgur.com/6XFFx4F.png) 根據文章,這些不尋常的流量很可能就是 Malware 利用 SMB 漏洞發送 eternel blue 的流量 :::danger 這篇文章講的不清不楚,我覺得有必要再分析下其他類似的樣本 ::: ## 案例分析: Ursnif 從這個案例分析會學到以下幾個重點: * Ursnif distribution methods * Categories of Ursnif traffic * Five examples of pcaps from Ursnif infections ### 1. Distribution method usrnif 通常由 web-based 或者 malspam 傳播,也有成為其他 malware 後續攻擊的案例,以下是利用 malspam 常見的散播方法: ![](https://i.imgur.com/syINBKm.jpg) ### 2. Categories of Ursnif traffic 簡單粗分為: 1. 利用 https post-infection 的 2. 不是利用 https post-infection 的 不過這兩種方法之後幹的事情好像都差不多... #### Usrnif without https ![](https://i.imgur.com/xbrxPIN.png) 流量大多是 http 和 dns 組成,直接用 `http.request` 查看: ![](https://i.imgur.com/LG6EdAR.png) 大多是由 GET 和 POST 這兩個 http method 組成的封包,而 post 封包用 tcp stream 來看: ![](https://i.imgur.com/19LNeBG.png) 這個看不出所以然....,但是下面這個: ![](https://i.imgur.com/Ho8ipXb.png) 猜測是上傳 log 到這端亂七八糟的目錄下 根據文章: * 前面 GET 到亂七八糟的目錄是由 ursnif 產生 * 使用這個 domain: w8.wensa[.]at * GET t64.dat 則是下載額外的資料 * 當 ursnif 存在於登錄檔時發送 GET 和 POST * 改成這個 domain: h1.wensa[.]at :::warning 從發送時間的確可以看出一開始用 w8.wensa[.]at GET 之後用 h1.wensa[.]at ,但我不知道從何得知當 domain 轉成 h1.wensa[.]at 是在登錄檔的時候發送... ::: 那一串奇怪目錄的模式跟其他感染案例比對會發現在 2019 年 10 月的 Hancitor 也曾出現過: (以下我用 `ip.addr == 8.208.24.139 and http.request` 來過濾 ![](https://i.imgur.com/WSe7jnV.png) 可以看出一開始都是用不同的 domain name GET 一堆亂七八糟的目錄,之後會 GET 一個 s64.dat 檔案,最後改 domain name 繼續 GET 或 POST 任何不用 https 的 ursnif 都具有類似的 pattern #### Ursnif with https 下面這流量已經剔除掉無關的封包了(原來我一直在做簡單版的...) ![](https://i.imgur.com/Tg4Xg1V.png) 從第一個封包可以看出是下載 malware ,應該就是 ursnif , export 後丟到 virustotal ,有些 AV 識別出是 ursnif ![](https://i.imgur.com/TCd74Ka.png) 從 DIE 看不出有加殼但是 data section 來看也差太多,感覺有動手腳 ![](https://i.imgur.com/2uA2mjT.png) 從封包的 host 來看,可以看出之後的 bjanicki[.]com 是之後產生的封包,跟之前一樣用一堆字母數字拼湊出來的目錄 GET ![](https://i.imgur.com/4D1GTxA.png) 下面就是 Ursnif 對 prodrigo29lbkf20[.]com 進行 https/ssl/tls 連線 按之前路子, https 也是有東西可以分析的,打開第一個 server hello ,觀察其憑證: ![](https://i.imgur.com/fvDtg6z.png) 明顯是個亂七八糟的憑證 另外還有一點可以注意,被感染的 windows host 會透過 opendns[.]com 確認自己的 ip ,透過 `dns.qry.name contains opendns` 過濾: ![](https://i.imgur.com/HsB9Ygy.png) 這應該也可以當作一個特徵 ### Ursnif with follow-up malware 這個案例一樣是剔除了其他不必要的封包,分析起來很方便 XD 比較不一樣的是這次 ursnif 又下載了其他後續的 malware 首先透過 basic 分析: ![](https://i.imgur.com/ZytYJL4.png) 第一個封包下載了 mateii8.cab ,沒意外應該是 ursnif ,保險起見分析下: ![](https://i.imgur.com/rqMR6cX.png) :::info 我必須說這些 malware 名字沒有統一看起來很難過 ::: 後面的流量都是從 ursnif 製造出來的,不過接下來的三個送往 google 的封包在感染的過程中看起來毫無作用,懷疑是 'decoy traffic' ,下面的 443 port 的 gmail 和 www.google.com 也可以被歸類成 'decoy traffic' 剔除這些流量,我們的目標放在 ghdy656262oe[.]com 這個 host 即可,可以看出他的封包流量模式跟之前的案例滿像的 ![](https://i.imgur.com/TOEwpyM.png) 第三個封包後開始收到 200 response 然後 GET 一堆字母數字組合的目錄和結尾為 avi 的檔案,而且因為前兩次的 404 , malware 開始試圖解析 tnzf3380au[.]top 和 xijamaalj[.]com ,不過兩個域名都找不到(分析到這邊覺得很好笑 XD) ![](https://i.imgur.com/z6Tvm7S.png) 最後下載回一個叫 jjwekr.rar 的檔案, exports 後丟到 virustotal 分析: ![](https://i.imgur.com/NUsITrh.png) 沒有錯!什麼都找不到,推測這個檔案應該是已經被加密過,所以解密前無法分析。 ### Usrnif infection with Dridex 首先用 basic filter 過濾後: ![](https://i.imgur.com/YG6eots.png) 可以發現跟之前的 usrnif 封包很像,都是先從網站下載一個執行檔,該執行檔產生的流量都是用 HTTP GET 一串用字母數字組成的目錄,然後接續一段 https ,最後下載一個 rar 檔。 有了之前的經驗可以預想第一個執行檔應該就是 usrnif 的 malware ,不過還是要檢查一下: ![](https://i.imgur.com/1fMJ4r6.png) 結果這次沒半個名字跟 Usrnif 有關 XD 同樣的這次的流量也有 decoy traffic (www.google.com 和 gmail.com) ,而 malware infection persistent 後會發送向 port 443 的 https 封包,最後用 http 從 startupshirt[.]my 下載另外的 malware ![](https://i.imgur.com/JBEvfYi.png) 後面的 https 封包是由最後下載的 malware 發出的。 :::info 這邊我要暫停一下思考兩個問題: 1. 到底怎麼從這些封包中判定那些是 after persistence 那些不是? 推測應該是從有無更改 register key 判定 3. 所謂 persistence through windows registry 到底是怎麼一回事? [筆記](https://hackmd.io/2O3rYsWlQ7-oWyIc6DDFzw) ::: 由 jjasndeqw.rar 接續後,接連向 94.140.114[.]6 和 5.61.34[.]51 傳送 https 封包 這部分是 Dridex 的 post infection ,觀察其憑證 ![](https://i.imgur.com/cnMTNhM.png) ![](https://i.imgur.com/BmSPBEm.png) 跟原先的 Ursnif 的憑證長的不同,這些屬於 Dridex post-infection 的特徵 ### Evaluation 接下來這個例子也是由 ursnif 再散播 Dridex ,開始前先設立幾個練習目標: * 哪個 url return ursnif malware ? * 下載完 ursnif 後它會嘗試跟幾個 domain 做 http get ,那些是成功的? * 那些 domain 是 ursnif 成功滲透保存後進行 https 連接的? * 哪個 url 下載結尾為 .rar 的 Malware ? * Dridex 用哪個 url 進行 post infection ? 1. 哪個 url return ursnif malware ? ![](https://i.imgur.com/buundf4.png) 根據這個封包,可以判斷是: hxxp://ritalislum[.]com/obedle/zarref.php?l=sopopf8.cab 下載 2. 下載完 ursnif 後它會嘗試跟幾個 domain 做 http get ,那些是成功的? :::danger 這些原本的答案是錯的 * www.bing[.]com * 200 OK * k55gaisi[.]com * 404 not found * bon11ljgarry[.]com * 200 OK * www.search-error[.]com * 200 OK * leinwqua[.]com * 200 OK 比較有趣的是 malware 把 bon11ljarry[.]com 當關鍵字餵給 search-error[.]com ::: 首先 http request 到 k55gaisi[.]com 後 404 ,接下來的 bon11ljgarry[.]com 封包會用 search-error[.]com redirect 走,後面的 leinwqua[.]com 也是一樣 最後在這些封包中終於回傳 200 response: ![](https://i.imgur.com/x0uxXWZ.png) ![](https://i.imgur.com/XTH6r06.png) 3. 那些 domain 是 ursnif 成功滲透保存後進行 https 連接的? 雖然不是很懂......但猜測應該是下一個下載 malware 前的 https 會是 persistence 後進行 https 連接,根據流量判斷: ![](https://i.imgur.com/rluIhRF.png) 不過這個 www.download.windowsupdate[.]com 看起來像是正常的,連下載的 cab 也經過 virustotal 沒發現問題... :::danger 如果這個是正常的,那 after persistence 的封包應該連下面三個連到 n9maryjanef[.]com 也是屬於 after persistence 後用 https 連接的部分 ::: 上面的回答半對,當 Ursnif Persistence 後不會再使用 http get request ,所以到上一個問題的那幾個封包後,開始出現送往 n9maryjanef[.]com 這些封包就可以判斷是 Ursnif persistence 後進行的 https 連接。 上述關於是否為 Ursnif 的 https 連線,可以透過查看其 server hello 的憑證跟之前的案例做比對就知道了。 4. 哪個 url 下載結尾為 .rar 的 Malware ? url: testedsolutionbe[.]com/wp-content/plugins/apikey/uaasdqweeeeqsd.rar 5. Dridex 用哪個 url 進行 post infection ? 根據前面的答案,我們可以剔除掉 n9maryjanef[.]com 的流量,因為這是 Ursnif 的,那再扣掉 decoy traffic ,剩下的就只有: ![](https://i.imgur.com/hwRaF1j.png) 到這邊 Brad 教學就告一段落了,剩下應該會試著做一下練習和學習惡意程式分析。 ## 案例分析: Qbot 我先嘗試自己觀察一遍整個流量了,所以以下就節錄自教學和自己先前的筆記,再點出自己的不足 ### malspam 下載 zip 首先根據整個流量可以判斷出感染的流程圖 ![](https://i.imgur.com/4vf7CFk.png) 根據我觀察的結果,我自己沒看到 email 傳播和沒有解壓縮 zip 得到 vbs 檔案,我是有看到 zip 但是當時不知道怎麼將大檔案拉下來(看完做法覺得自己好笨 ==) 根據教學的截圖,當時的郵件是長這樣的: ![](https://i.imgur.com/JMCcvg3.png) 這部分應該是作者自己測試的時候截圖下來,反正我是沒有從流量中下載 zip 檔案前看到郵件的跡象 (從 port 來看的話) ![](https://i.imgur.com/GaXkz8M.png) 下載 zip 檔案的網址是: `hxxp://bhatner[.]com/wp-content/uploads/2020/01/ahead/9312.zip` 這個網址已經列入 [urlhaus](https://urlhaus.abuse.ch/) 這個專門收集惡意網址的名單中,當然還有其他 url 這邊就不全部列出 但從 export objects -> http 發現一堆 9312.zip ![](https://i.imgur.com/YQBZDL1.png) 但是從 tcp stream 上來看只有一次的 response ...,暫且不管它,先想辦法把 zip 提取出來,從 export objects 提取肯定是不行的(太多了),想辦法從 tcp stream 拿,方法是: 1. 只選取 response 部分 ![](https://i.imgur.com/spIFv6h.png) 2. 用 raw 保存 ![](https://i.imgur.com/3H1d28u.png) 3. 存起來 ![](https://i.imgur.com/hTjQm3c.png) 4. 用 hex 修改掉 response header zip 的 file format 開頭是 PK ,前面都是 header 都要刪掉 ![](https://i.imgur.com/UR5EztF.png) ![](https://i.imgur.com/whgUyAM.png) 成功打開 ![](https://i.imgur.com/PwtSNpW.png) 打開 vbs 發現是混淆過的,暫時不細究,教學也給出在[沙盒](https://app.any.run/tasks/e2c36659-1070-4665-991c-245e900245b7/)的分析結果,據說是給出了 Qakbot malware 的下載網址 ![](https://i.imgur.com/68sioVn.png) ### VBS 下載 Qakbot 從 basic filter 可以看到下載完 zip 接下來就是 44444.png ![](https://i.imgur.com/hkoW29z.png) 從 2019 年 12 月開始, Qakbot 大量採用 44444.png 或 444444.png 當檔名,教學有給出一系列的網址 根據之前的經驗,我有 exports png 出來看並丟到 [virustotal](https://www.virustotal.com/gui/file/56ee803fa903ab477f939b3894af6771aebf0138abe38ae8e3c41cf96bbb0f2a/detection) ,不少 AV 都能發出警告,不錯 ![](https://i.imgur.com/VE600X7.png) ### HTTPS post infection 下載完 Qakbot 後會出現一堆 https 連線 ![](https://i.imgur.com/2dJDLmM.png) 前面幾個很正常,不正常的是後面沒有 hostname 的,因為這種 https 連線之前有學過可以用憑證內容判斷是否正常,於是我就找了 handshake.type == 2 的部分,發現: ![](https://i.imgur.com/TbaGk8n.png) 這個教學中也有點出來 ### Other post infection 後面還有幾個流量也是利用同個 ip 進行感染 ![](https://i.imgur.com/tVPy8lN.png) 可以發現中間夾帶了一個 speedof 網站,這是正常的網站但很常出現在 Qakbot 感染流量中,可以視為一個感染跡象 之後又用 http 對 store.privateoffice[.]com 要了這個網頁 ![](https://i.imgur.com/PyiiwJm.png) 教學上說 Qakbot 會用 chrome, firefox, ie 瀏覽器打開這個網站,但擷取封包的虛擬機上沒有裝 chrome 和 firefox 所以只會打開 ie 的 打開該 http response ,看起來會 4 秒後刷新頁面到 msn ,看不出在衝三小 ![](https://i.imgur.com/D4WaejJ.png) 另外還有其他 email 流量,但我一直用 basic 去過濾,所以沒發現... 關掉 http, https, dns, nbns, mdns 等雜項,從眾多封包中可以看到幾個 25, 110, 587, 995 等幾個 port ,這些 port 都跟郵件協定有關 這樣就可以用 `smtp or imap or pop` 等協定過濾 :::info 因為找起來太麻煩,可以用 `tcp.port < 1000` 快速定位 :::

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully