# EDR端點驗證操作說明 ###### tags: `powershell` `winlogbeat` `sysmon` ## 1. 驗證工具&服務運作正常 :::info 為求方便此處Elasticsearch統一稱呼ES ::: * **查詢 sysmon 指令** + `Get-Service -Name Sysmon64` * **查詢 winlogbeat 指令** + `Get-Service -Name winlogbeat` * **確認 ES 運作正常 & 確認winlogbeat有傳送Event log到ES** + 開啟ES,執行 `elasticsearch-7.15.2\bin\elasticsearch.bat` + 查詢ES狀態 (透過Terminal執行) + 指令介紹: + `http://localhost:9200/[_cat]/[indices][?v]` + 參數介紹: + _cat : 提供查詢ES所有命令類。 + indices : 查ES中所有的Index資訊。 + v : 顯示標題,可選。 + 輸入指令: `curl -XGET http://localhost:9200/_cat/indices?v` ![](https://i.imgur.com/ySyxAz7.png) + 查詢ES內的事件紀錄資料 (透過Terminal執行) + 指令介紹: + `http://localhost:9200/[index]/[_search]?[q=t]` + 參數介紹: + index: ES的Index + _search: 查詢功能,預設Index全部。 + q: 查詢的內容,可選。 + 輸入指令: `curl -XGET http://localhost:9200/winlogbeat-2022.10.03/_search?q=Microsoft-Windows-PowerShell` ![](https://i.imgur.com/rvcCIHC.png) --- ## 2. 驗證sysmon有紀錄windows事件 :::info 駭客通常會清除自己的軌跡,可能使用wevtutil清除事件檢視器上的log,故使用此指令當作後續「AI模型捕捉到的可疑行為」做驗證。 ::: * **開啟Sysmon資料夾查看Security 事件檔案** + 查看`C:\Windows\System32\winevt\Logs\Security.evtx`檔案大小。 ![](https://i.imgur.com/Zb7YlUr.png) * **查看事件紀錄被清除** + 系統管理員權限開啟cmd,執行指令`wevtutil cl Security` + wevtutil: Windows命令,清除記錄檔 + cl: 指定的事件記錄檔清除事件。 + 查看檔案`C:\Windows\System32\winevt\Logs\Security.evtx`是否清空(68K)。 ![](https://i.imgur.com/S6vbyMP.png) * **確定sysmon有紀錄此事件log** + 開啟事件檢視器,到sysmon目錄,篩選目前記錄事件識別碼為1 ![](https://i.imgur.com/KuBy7ZT.png) + wevtutil指令被sysmon紀錄下來 + ProcessId:事件檢視器log id唯一值編號 + Commandline:指令內容 + 已記錄(D):事件log時間 ![](https://i.imgur.com/xL0STxY.png) --- ## 3. 驗證winlogbeat有傳送wevtutil log 到 ES * **查看index內wevtutil的event log** + 透過給定的條件查詢ES (透過Terminal執行) + 指令介紹: + `http://localhost:9200/[index]/[_search][?q=26632]` + 參數介紹: + index: ES 的 index + _search: 查詢功能,預設Index全部 + q: 查詢內容,可選 + 指令:`curl -XGET http://localhost:9200/winlogbeat-2022.10.07/_search?q=26632` ![](https://i.imgur.com/tTVtvXk.png) * 有ES Head則更直觀的查看winlogbeat傳送 ![](https://i.imgur.com/b73riTs.png) --- :::danger 建議先關閉winlogbeat服務再做ES DB刪除,可能會發生有winlogbeat傳送事件到一半找不到ES卡住。 :::