使用GeoLite2資料庫幫助Wireshark 快速判斷IP的所在位置,並利用Windows PID找出惡意程式。
原文:https://medium.com/blacksecurity/securityanalysiswithwireshark1-51b4a54ba483

對於Wireshark 維基百科的介紹:
Wireshark是一個免費開源的網路封包分析軟體。網路封包分析軟體的功能是截取網路封包,並盡可能顯示出最為詳細的網路封包資料。
不過會看這篇文章的大概對網路都有一點概念了。

下載點:
https://www.wireshark.org/download.html
安裝地理位置資訊資料庫-GeoLite2
安裝過程就不贅述,這邊想介紹一個方便的資料庫,可以將攔截到的封包快速判斷出國家、公司等地理資訊位置。
(這邊Wireshark後面的Country、City、AS NUMBER 預設都是空的)

下載 GeoLite2 Free Downloadable Databases
https://dev.maxmind.com/geoip/geoip2/geolite2/

這邊要下載三個檔案,格式為MaxMind DB,不要下載到CSV Format:
- City
- Country
- AS Number (網路管理者會知道AS Number在網路世界的用處 這裡不贅述)
安裝
檔案下載後會有三個壓縮檔,我們分別將檔案解壓縮到你需要的位置
這邊範例放在 :
C:\GEO

開啟Wireshark ,點選左上的Edit->Preferences

Name Resolution ->MaxMind Database Directories

將解壓縮後的路徑選到資料庫內,切記必須選到子目錄(選GeoLite2-XXXXX)

實際使用
首先我想先改一下Wireshark的時間顯示
對著Time選右鍵->Edit Column->Type選Absolute date, as YYYY-MM-DD and time
這樣看起來比較順眼,而且比較好看。

接著請自己錄製一段封包後按暫停,並點選上方的 Statistic ->Endpoint


這邊可以判斷幾個資安的議題:
- Country : 是否有不應該的國家出現。
- AS Number可以判斷公司 ,可學習CCNA認證會比較清楚
- Address也幫你統計出來了,這樣篩選判斷更快
補充:
一開始錄製封包時候可以先設定將廣播與群播濾掉,避免太多垃圾資訊

回到封包分析,來過濾想看到的資料,對想要的IP資訊右鍵
Apply as Filter->Selected ,反之Not Selected 是除了這個以外都要
這邊用錄到的Netskope這個軟體連線來舉例:

過濾完後回到主畫面就會跑出相關的IP
看一下上面篩選的指令為:
ip.addr==103.219.79.35
這裡是將有關IP給篩出來,而不是只有Source或Destination

黑色底代表封包有些問題,像是Bad TCP或一些狀態改變
常見的綠色:HTTP 明碼或利用一些手段解析加密流量後的HTTP2、UDP是淺藍色、加密的流量TLS是紫色、淺黃色是SMB(網路芳鄰等)

補充: SMB指令判斷封包異常
ip.src == 192.168.1.0/24 and (tcp.port in {139 445} or udp.port in {135 136 137 138})and not ip.dst == 192.168.1.0/24
ip來源為192.168.1.0/24下,ip是TCP的139 445 port 或 UPD的135–138 port 都要包含 ,並排除目的地是192.168.1.0/24(內網)
因為SMB對外傳輸資料可能有問題,所以這邊將可能走的Port找出來並排除往內網發送資訊的封包,減少不必要的訊息。
追蹤IP的PID
終於找到了這個封包,讓我們來看一下我們的電腦他的Process位置
使用CMD的指令(包含了Windows Process 的 PID )
netstat -ano -p tcp


我們輸入完指令後,會看到現在Windows上建立的連線如圖:

Source : 192.168.144:26780 (IP+Port)
對象是103.219.79.25並走443 port 出去 (https)
在系統上PID為5328
追蹤程式在何處
那接下來看一下我們工作管理員,我對狀態選右鍵,打開PID與命令列

找到對應的PID,並找到程式的位置

其實這是一隻合法的惡意程式XD
專門來監控電腦活動的一套軟體

Summary
Wireshark 對於資安人員分析ARP、PortScan、SQL injection、SMB Attack(勒索軟體)都可以輕易地做到,並做出判斷。
封包分析這塊領域就要推一下封包大神劉德民,從C++、組合語言到資料庫、網路封包的分析經驗真的很厲害。
若您喜歡我的文章,歡迎按下「拍手」與Liker按讚給我支持並轉發給你的朋友們(可以多拍幾下手喔),或是「Follow」我,讓我提供文章給您。
也歡迎繼續閱讀:
網路管理系列
https://medium.com/blacksecurity/tagged/network
CTF Write-up 系列
https://medium.com/blacksecurity/tagged/ctf
財務金融系列
https://medium.com/blacksecurity/tagged/finance
沒有留言:
張貼留言