在Windows平台利用sysmon進行安全分析
Sysmon是由Windows Sysinternals出品的Sysinternals系列中的工具。它以系統服務和設備驅動程序的方法安裝在系統上,並保持常駐性,是一款輕量級且強大的安全監控工具。
1、安裝使用
下載鏈接:https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon
下載后解壓,里面覆蓋了32位和64位平台的程序。
Copyright (C) 2014-2020 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com
Usage:
Install: Sysmon64.exe -i [<configfile>]
Update configuration: Sysmon64.exe -c [<configfile>]
Install event manifest: Sysmon64.exe -m
Print schema: Sysmon64.exe -s
Uninstall: Sysmon64.exe -u [force]
-c Update configuration of an installed Sysmon driver or dump the
current configuration if no other argument is provided. Optionally
take a configuration file.
-i Install service and driver. Optionally take a configuration file.
-m Install the event manifest (done on service install as well).
-s Print configuration schema definition of the specified version.
Specify 'all' to dump all schema versions (default is latest).
-u Uninstall service and driver. Adding force causes uninstall to proceed
even when some components are not installed.
The service logs events immediately and the driver installs as a boot-start driver to capture activity from early in
the boot that the service will write to the event log when it starts.
On Vista and higher, events are stored in "Applications and Services Logs/Microsoft/Windows/Sysmon/Operational". On
older systems, events are written to the System event log.
Use the '-? config' command for configuration file documentation.More examples are available on the Sysinternals
website.
Specify -accepteula to automatically accept the EULA on installation, otherwise you will be interactively prompted to
accept it.
Neither install nor uninstall requires a reboot.
最常用的安裝方式:
sysmon -accepteula –i -n
推薦使用大佬們配置好的配置文件,以下給出的配置文件鏈接預定義了高質量的事件跟蹤模板:
https://github.com/SwiftOnSecurity/sysmon-config
sysmon.exe -accepteula -i sysmonconfig-export.xml #指定使用該配置文件進行安裝
2、分析范例:使用CS馬進行分析
sysmon的日志記錄在windows事件查看器--應用程序和服務日志--Microsoft--windows--sysmon,逐級展開進入到sysmon下:
為了便於分析,這里手動清空下。
CS生成使用office宏的payload,直接執行:
上圖可以看到已經上線了。接下來到sysmon里看下能不能找到蛛絲馬跡
前兩個是指在explorer環境下使用word打開了這個文檔,然后又調用了rundll32.exe,重點從第三個“CreateRemoteThread detected:”開始細看
將winword進程注入到rundll32.exe實現程序隱藏,新的進程ID是1056。
向teamserver服務器的外聯請求:
Network connection detected為網絡連接事件
進程ID1056,進程名為rundll32.exe跟上面是貼合的。目標端口80 目標IP為teamserver的IP地址。
附:sysmon所有事件對應的官方定義和解釋
https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon
3、sysmon輔助分析工具
sysmon雖然很方便,可以在日志管理中進行分析日志,但仍不夠直觀,查詢不夠方便快速,以下介紹的三款sysmon輔助工具將大大提升使用sysmon的日志分析工具時的效率。
Sysmon View:離線Sysmon日志可視化工具。
Sysmon Shell: Sysmon配置實用程序。
Sysmon Box: Sysmon和網絡捕獲日志實用程序。
下載地址:https://github.com/nshalabi/SysmonTools
下載速度過慢,是因為做着沒有刪除.git文件夾導致里面夾雜了很多臨時文件還有代碼。本身這三個工具源文件是很小的。
3.1 sysmon view
進程的概覽信息
更快速的安全日志查詢
將日志中的線索自動按應用程序樹狀結構進行展示,可直接雙擊查詢
3.2 sysmon shell
sysmon shell里預定義了很多事件選項,可靈活自定義生成XML模板文件。
上圖的紅色標注部分就是本文開頭用的那個模板;
也可以打開這個模板然后自定義。
3.3 sysmon box
進入wireshark的安裝目錄,使用tshark或直接打開wireshark看哪個網卡是正在用的。
./tshark.exe -D #檢測正在使用的網卡
利用wireshark進行抓包,停止后自動生成pcap文件和sysmon view DB文件。
然后再sysmon view中進行可視化分析。