Sysmon部署与规则编写
前置说明
Sysmon(System Monitor)是 Sysinternals 出品的高级系统监控工具,以 Windows 服务 + 驱动的方式运行
它弥补了 Windows 原生事件日志的大量盲区,是 IR/Threat Hunting 的核心数据源
Sysmon 本身不做告警/检测,它只负责高质量的事件生成,检测逻辑由 SIEM/Sigma/Hayabusa 等完成
日志写入:Microsoft-Windows-Sysmon/Operational 通道
关联页面:03-事件日志分析 | 21-WMI事件订阅后门 | 31-Sysinternals套件
一、为什么需要 Sysmon 1.1 Windows 原生日志的盲区
能力
Windows 原生日志
Sysmon
进程创建(含命令行)
Security 4688(需开启审计策略)
Event ID 1(默认含完整命令行 + hash + 父进程 GUID)
网络连接
Security 5156(Windows Filtering Platform,信息有限)
Event ID 3(含源/目 IP:Port、进程、用户)
DLL 加载
无原生日志
Event ID 7(ImageLoaded,含 hash 和签名)
进程注入
无原生日志
Event ID 8(CreateRemoteThread)+ Event ID 10(ProcessAccess)
文件创建
无原生日志
Event ID 11(FileCreate,含 hash)
注册表操作
Security 4657(需开启 SACL)
Event ID 12/13/14(无需 SACL 配置)
DNS 查询
DNS Client 日志(需特殊开启)
Event ID 22(DNSQuery)
WMI 事件
无原生日志
Event ID 19/20/21
文件流(ADS)
无原生日志
Event ID 15(FileCreateStreamHash)
文件删除
无原生日志
Event ID 23/26(FileDelete)
进程篡改
无原生日志
Event ID 25(ProcessTampering)
结论:没有 Sysmon 的 Windows 系统在 IR 时是”半盲”状态
1.2 Sysmon 的优势 事件中包含 ProcessGUID ,可以跨事件关联同一进程的所有行为
事件中包含 文件 hash (MD5/SHA1/SHA256/IMPHASH),直接可对接 IOC
规则驱动 :可以精确控制记录什么、不记录什么,平衡覆盖面和性能
持久化为 Windows 服务 + 内核驱动,重启不丢失
日志写入标准 EVTX,可被 SIEM、Hayabusa、Sigma 等工具直接消费
二、安装与基础配置 2.1 安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Invoke-WebRequest -Uri "https://download.sysinternals.com/files/Sysmon.zip" ` -OutFile "$env:TEMP \Sysmon.zip" Expand-Archive -Path "$env:TEMP \Sysmon.zip" -DestinationPath "C:\Tools\Sysmon" C:\Tools\Sysmon\Sysmon64.exe -accepteula -i C:\Tools\Sysmon\Sysmon64.exe -accepteula -i C:\Tools\Sysmon\sysmonconfig.xml
2.2 验证安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Get-Service Sysmon64fltmc | findstr /i sysmon Sysmon64.exe -c Sysmon64.exe Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -MaxEvents 5 | Select-Object TimeCreated, Id, Message
2.3 更新配置 1 2 3 4 5 6 7 Sysmon64.exe -c C:\Tools\Sysmon\sysmonconfig_updated.xml Sysmon64.exe -c --
三、Sysmon 事件 ID 详解 3.1 进程相关事件 Event ID 1 — ProcessCreate(进程创建)
IR 价值:最高 — 记录每个进程的创建,含完整命令行
关键字段:
ProcessGuid: 全局唯一标识,用于跨事件关联
ProcessId: PID
Image: 进程完整路径
CommandLine: 完整命令行参数(核心信息 )
ParentProcessGuid / ParentProcessId / ParentImage / ParentCommandLine: 父进程信息
User: 运行用户
Hashes: 文件 hash
IntegrityLevel: 完整性级别(Low/Medium/High/System)
示例告警场景:
cmd.exe 的父进程是 winword.exe(钓鱼)
powershell.exe -enc <base64>(编码命令执行)
C:\Windows\Temp\*.exe 执行(临时目录中的可执行文件)
Event ID 5 — ProcessTerminate(进程终止)
IR 价值:中 — 结合 Event ID 1 计算进程运行时长
Event ID 8 — CreateRemoteThread(远程线程创建)
IR 价值:最高 — 进程注入的关键指标
关键字段:
SourceImage: 创建线程的进程
TargetImage: 被注入的目标进程
StartAddress / StartModule / StartFunction: 线程起始信息
典型告警:任何进程对 lsass.exe 创建远程线程
Event ID 10 — ProcessAccess(进程访问)
IR 价值:最高 — 检测 Mimikatz 等凭据提取工具
关键字段:
SourceImage: 发起访问的进程
TargetImage: 被访问的目标进程
GrantedAccess: 请求的访问权限
Mimikatz 典型模式:
GrantedAccess 包含 0x1010 或 0x1410(PROCESS_QUERY_LIMITED_INFORMATION + PROCESS_VM_READ)
TargetImage 是 lsass.exe
Event ID 25 — ProcessTampering(进程篡改)
IR 价值:高 — 检测 Process Hollowing / Process Herpaderping
当进程映像被修改或替换时触发
3.2 网络相关事件 Event ID 3 — NetworkConnect(网络连接)
IR 价值:高 — 记录进程级别的网络活动
关键字段:
Image: 发起连接的进程
User: 用户
Protocol: TCP/UDP
SourceIp / SourcePort: 源地址
DestinationIp / DestinationPort / DestinationHostname: 目标地址
Initiated: true(出站)/ false(入站)
注意:高流量环境下此事件量极大,需要精细 Filter
Event ID 22 — DNSQuery(DNS 查询)
IR 价值:高 — 记录进程的 DNS 解析请求
关键字段:
Image: 发起查询的进程
QueryName: 查询的域名
QueryResults: 解析结果
典型告警:
非浏览器进程查询动态 DNS(*.duckdns.org、*.no-ip.com)
异常长的子域名(可能是 DNS tunneling)
powershell.exe 或 rundll32.exe 的 DNS 查询
3.3 文件相关事件 Event ID 11 — FileCreate(文件创建)
IR 价值:高 — 追踪文件投放
关键字段:
Image: 创建文件的进程
TargetFilename: 被创建的文件完整路径
监控重点:
C:\Windows\System32\ 中的新 DLL
C:\Windows\Temp\ 中的 EXE
Startup 目录中的新文件
用户 profile 中的可执行文件
Event ID 15 — FileCreateStreamHash(文件流/ADS 创建)
IR 价值:高 — 检测 Alternate Data Stream 隐藏
当文件被创建且带有 ADS 时触发
攻击者可能在 ADS 中隐藏恶意 payload
Event ID 23 — FileDelete(文件删除,含归档)
IR 价值:高 — Sysmon 可以在文件被删除前归档保存
配置 ArchiveDirectory 后,Sysmon 会将被删除的文件保存到指定目录
这对恶意软件的自删除行为极为有价值
Event ID 26 — FileDeleteDetected(文件删除记录)
仅记录删除事件,不归档文件(比 Event ID 23 轻量)
3.4 注册表相关事件 Event ID 12 — RegistryEvent (Object create/delete)
Event ID 13 — RegistryEvent (Value Set)
Event ID 14 — RegistryEvent (Key/Value Rename)
关键字段:
Image: 操作注册表的进程
EventType: CreateKey / DeleteKey / SetValue / RenameKey
TargetObject: 注册表路径
Details: 设置的值(Event ID 13)
监控重点路径:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKLM\SYSTEM\CurrentControlSet\Services
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
3.5 DLL 加载与 WMI 事件 Event ID 7 — ImageLoaded(DLL 加载)
IR 价值:高 — 检测 DLL 劫持/侧加载
关键字段:
Image: 加载 DLL 的进程
ImageLoaded: DLL 完整路径
Hashes: DLL 的 hash
Signed / Signature / SignatureStatus: 签名信息
注意:此事件量极大 ,必须配合精确的 Filter 使用
Event ID 19/20/21 — WMI 事件
Event ID 19: WmiEventFilter(事件过滤器创建)
Event ID 20: WmiEventConsumer(事件消费者创建)
Event ID 21: WmiEventConsumerToFilter(绑定关系创建)
IR 价值:高 — 检测 WMI 持久化后门
参见 21-WMI事件订阅后门
3.6 Event ID 完整速查表
ID
事件名
IR 价值
事件量
1
ProcessCreate
最高
中
2
FileCreateTime
低
大
3
NetworkConnect
高
极大
4
Sysmon Service State
低
极小
5
ProcessTerminate
中
中
6
DriverLoad
中
小
7
ImageLoaded (DLL)
高
极大
8
CreateRemoteThread
最高
小
9
RawAccessRead
中
小
10
ProcessAccess
最高
极大
11
FileCreate
高
大
12
RegistryCreate/Delete
高
大
13
RegistryValueSet
高
大
14
RegistryRename
中
小
15
FileCreateStreamHash
高
小
16
Sysmon Config Change
低
极小
17
PipeCreated
中
小
18
PipeConnected
中
小
19
WmiFilterCreate
高
极小
20
WmiConsumerCreate
高
极小
21
WmiConsumerBind
高
极小
22
DNSQuery
高
大
23
FileDelete (archive)
高
中
24
ClipboardChange
中
小
25
ProcessTampering
高
极小
26
FileDeleteDetected
高
中
27
FileBlockExecutable
中
小
28
FileBlockShredding
中
小
29
FileExecutableDetected
中
中
四、配置文件结构 4.1 XML 配置基本结构 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 <Sysmon schemaversion ="4.90" > <HashAlgorithms > md5,sha256,IMPHASH</HashAlgorithms > <DnsLookup > false</DnsLookup > <ArchiveDirectory > C:\SysmonArchive</ArchiveDirectory > <EventFiltering > <RuleGroup name ="Process Creation Rules" groupRelation ="or" > <ProcessCreate onmatch ="include" > </ProcessCreate > </RuleGroup > <RuleGroup name ="Network Rules" groupRelation ="or" > <NetworkConnect onmatch ="exclude" > </NetworkConnect > </RuleGroup > </EventFiltering > </Sysmon >
4.2 Include vs Exclude 逻辑 **onmatch="include"**:只记录匹配规则的事件(白名单模式)
匹配 → 记录
不匹配 → 丢弃
**onmatch="exclude"**:记录所有事件,除了匹配规则的(黑名单模式)
匹配 → 丢弃
不匹配 → 记录
最佳实践:
大多数事件类型使用 exclude(记录一切,排除已知噪音)
高容量事件(Event ID 7 ImageLoaded、Event ID 10 ProcessAccess)使用 include(只记录关心的)
如果同时有 include 和 exclude RuleGroup(不同 RuleGroup),处理顺序:
Sysmon 15+ 版本支持在同一事件类型中使用多个 RuleGroup
include 先处理,exclude 后处理
4.3 条件匹配操作符
操作符
说明
示例
is
精确匹配
<Image condition="is">C:\Windows\System32\cmd.exe</Image>
is not
不等于
<Image condition="is not">...</Image>
contains
包含
<CommandLine condition="contains">-enc</CommandLine>
contains any
包含任意一个(; 分隔)
<CommandLine condition="contains any">-enc;-nop;-w hidden</CommandLine>
contains all
包含所有
<CommandLine condition="contains all">net;user;/add</CommandLine>
excludes
不包含
<Image condition="excludes">System32</Image>
excludes any
不包含任意一个
<Image condition="excludes any">System32;SysWOW64</Image>
excludes all
不包含所有
<Image condition="excludes all">...</Image>
begin with
以…开头
<TargetFilename condition="begin with">C:\Windows\</TargetFilename>
end with
以…结尾
<TargetFilename condition="end with">.exe</TargetFilename>
image
匹配路径中的文件名部分
<Image condition="image">cmd.exe</Image>
4.4 RuleGroup 与 groupRelation 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <RuleGroup name ="Suspicious Process" groupRelation ="or" > <ProcessCreate onmatch ="include" > <Image condition ="end with" > .ps1</Image > <Image condition ="end with" > .vbs</Image > </ProcessCreate > </RuleGroup > <RuleGroup name ="Mimikatz Detection" groupRelation ="and" > <ProcessAccess onmatch ="include" > <TargetImage condition ="is" > C:\Windows\system32\lsass.exe</TargetImage > <GrantedAccess condition ="is" > 0x1010</GrantedAccess > </ProcessAccess > </RuleGroup >
五、推荐配置方案 5.1 SwiftOnSecurity/sysmon-config GitHub: https://github.com/SwiftOnSecurity/sysmon-config
特点:
最广泛使用的 Sysmon 配置
以 exclude 模式为主,记录大量事件并排除已知噪音
详细的注释说明每条规则的原因
适合作为起始配置,在此基础上定制
1 2 3 4 Invoke-WebRequest -Uri "https://raw.githubusercontent.com/SwiftOnSecurity/sysmon-config/master/sysmonconfig-export.xml" ` -OutFile "C:\Tools\Sysmon\sysmonconfig-swift.xml" Sysmon64.exe -c C:\Tools\Sysmon\sysmonconfig-swift .xml
5.2 Olaf Hartong / sysmon-modular GitHub: https://github.com/olafhartong/sysmon-modular
特点:
模块化配置,每个 Event ID 有独立的配置文件
使用 merge-sysmonconfig.ps1 合并为最终配置
更容易维护和定制
与 MITRE ATT&CK 映射
1 2 3 4 5 6 7 8 9 10 git clone https://github.com/olafhartong/sysmon-modular .git cd sysmon-modular .\Merge-SysmonXml .ps1 -Path . -AsHashTable | Out-File sysmonconfig-merged .xml -Encoding UTF8 Sysmon64.exe -c sysmonconfig-merged .xml
5.3 配置选择建议
场景
推荐配置
原因
快速部署
SwiftOnSecurity
开箱即用、社区验证
企业定制
sysmon-modular
模块化便于按需增减
最大覆盖
自定义 exclude-all 配置
最全面但日志量大
性能敏感
精简 include 配置
只监控高价值事件
六、自定义规则编写实战 6.1 检测 PowerShell Download Cradle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <RuleGroup name ="PowerShell Download Cradle" groupRelation ="or" > <ProcessCreate onmatch ="include" > <CommandLine condition ="contains any" > Invoke-WebRequest;IWR;Invoke-RestMethod;IRM; wget;curl;DownloadString;DownloadFile; DownloadData;Net.WebClient;Start-BitsTransfer; BitsTransfer;Invoke-Expression;IEX </CommandLine > <ParentImage condition ="image" > powershell.exe</ParentImage > </ProcessCreate > </RuleGroup > <RuleGroup name ="Encoded PowerShell" groupRelation ="or" > <ProcessCreate onmatch ="include" > <CommandLine condition ="contains any" > -enc;-encodedcommand;-e JAB;-e SQBFAF;-e SQBuAH;-e SABFAF; -e cwBhA;-e aQBmA;-e aQBlA;-e dgBhAH;-e bgBhAG0A </CommandLine > </ProcessCreate > </RuleGroup >
6.2 检测 LSASS 凭据提取(Mimikatz) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 <RuleGroup name ="LSASS Access Detection" groupRelation ="and" > <ProcessAccess onmatch ="include" > <TargetImage condition ="is" > C:\Windows\system32\lsass.exe</TargetImage > <GrantedAccess condition ="is any" > 0x1010;0x1410;0x1438;0x143a;0x1fffff;0x1010;0x40 </GrantedAccess > </ProcessAccess > </RuleGroup > <RuleGroup name ="LSASS Access Exclusion" groupRelation ="or" > <ProcessAccess onmatch ="exclude" > <SourceImage condition ="is" > C:\Windows\system32\wbem\wmiprvse.exe</SourceImage > <SourceImage condition ="is" > C:\Windows\system32\svchost.exe</SourceImage > <SourceImage condition ="is" > C:\Windows\system32\lsass.exe</SourceImage > <SourceImage condition ="is" > C:\Windows\system32\csrss.exe</SourceImage > <SourceImage condition ="begin with" > C:\Program Files\Windows Defender\</SourceImage > <SourceImage condition ="begin with" > C:\ProgramData\Microsoft\Windows Defender\</SourceImage > </ProcessAccess > </RuleGroup >
6.3 检测 DLL 注入(CreateRemoteThread) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <RuleGroup name ="Remote Thread Injection" groupRelation ="or" > <CreateRemoteThread onmatch ="exclude" > <SourceImage condition ="is" > C:\Windows\system32\csrss.exe</SourceImage > <SourceImage condition ="is" > C:\Windows\system32\wininit.exe</SourceImage > <SourceImage condition ="is" > C:\Windows\system32\winlogon.exe</SourceImage > <SourceImage condition ="is" > C:\Windows\system32\services.exe</SourceImage > <SourceImage condition ="begin with" > C:\Program Files\</SourceImage > <SourceImage condition ="begin with" > C:\Program Files (x86)\</SourceImage > </CreateRemoteThread > </RuleGroup > <RuleGroup name ="LSASS Thread Injection" groupRelation ="or" > <CreateRemoteThread onmatch ="include" > <TargetImage condition ="is" > C:\Windows\system32\lsass.exe</TargetImage > </CreateRemoteThread > </RuleGroup >
6.4 检测可疑 DNS 查询 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 <RuleGroup name ="Suspicious DNS" groupRelation ="or" > <DnsQuery onmatch ="include" > <QueryName condition ="end with" > .duckdns.org</QueryName > <QueryName condition ="end with" > .no-ip.com</QueryName > <QueryName condition ="end with" > .no-ip.org</QueryName > <QueryName condition ="end with" > .ddns.net</QueryName > <QueryName condition ="end with" > .hopto.org</QueryName > <QueryName condition ="end with" > .zapto.org</QueryName > <QueryName condition ="end with" > .serveftp.com</QueryName > <QueryName condition ="contains" > pastebin.com</QueryName > <QueryName condition ="contains" > raw.githubusercontent.com</QueryName > <QueryName condition ="end with" > .onion</QueryName > <QueryName condition ="end with" > .tor2web.org</QueryName > </DnsQuery > </RuleGroup > <RuleGroup name ="Non-Browser DNS" groupRelation ="or" > <DnsQuery onmatch ="include" > <Image condition ="image" > powershell.exe</Image > <Image condition ="image" > cmd.exe</Image > <Image condition ="image" > rundll32.exe</Image > <Image condition ="image" > regsvr32.exe</Image > <Image condition ="image" > mshta.exe</Image > <Image condition ="image" > wscript.exe</Image > <Image condition ="image" > cscript.exe</Image > </DnsQuery > </RuleGroup >
6.5 检测 WMI 持久化 1 2 3 4 5 6 <RuleGroup name ="WMI Persistence" groupRelation ="or" > <WmiEvent onmatch ="exclude" > </WmiEvent > </RuleGroup >
WMI 事件订阅(Event ID 19/20/21)在正常系统中极为罕见
任何 WMI 事件订阅的创建都应当被视为高优先级告警
6.6 检测可疑文件创建 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <RuleGroup name ="Suspicious File Creation" groupRelation ="or" > <FileCreate onmatch ="include" > <TargetFilename condition ="contains" > \Start Menu\Programs\Startup\</TargetFilename > <TargetFilename condition ="begin with" > C:\Windows\System32\</TargetFilename > <TargetFilename condition ="begin with" > C:\Windows\SysWOW64\</TargetFilename > <TargetFilename condition ="contains" > \Temp\</TargetFilename > <TargetFilename condition ="end with" > .exe</TargetFilename > <TargetFilename condition ="end with" > .dll</TargetFilename > <TargetFilename condition ="end with" > .bat</TargetFilename > <TargetFilename condition ="end with" > .ps1</TargetFilename > <TargetFilename condition ="end with" > .vbs</TargetFilename > <TargetFilename condition ="end with" > .hta</TargetFilename > <TargetFilename condition ="end with" > .scr</TargetFilename > </FileCreate > </RuleGroup >
七、Sysmon 作为取证制品源 7.1 使用 PowerShell 查询 Sysmon 日志 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -FilterXPath "*[System[EventID=1]]" -MaxEvents 50 | ForEach-Object { $xml = [xml ]$_ .ToXml() [PSCustomObject ]@ { Time = $_ .TimeCreated Image = ($xml .Event.EventData.Data | Where-Object Name -eq 'Image' ).'#text' CommandLine = ($xml .Event.EventData.Data | Where-Object Name -eq 'CommandLine' ).'#text' ParentImage = ($xml .Event.EventData.Data | Where-Object Name -eq 'ParentImage' ).'#text' User = ($xml .Event.EventData.Data | Where-Object Name -eq 'User' ).'#text' } } | Format-Table -AutoSize Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -FilterXPath "*[System[EventID=3]]" -MaxEvents 50 | ForEach-Object { $xml = [xml ]$_ .ToXml() [PSCustomObject ]@ { Time = $_ .TimeCreated Image = ($xml .Event.EventData.Data | Where-Object Name -eq 'Image' ).'#text' DestIP = ($xml .Event.EventData.Data | Where-Object Name -eq 'DestinationIp' ).'#text' DestPort = ($xml .Event.EventData.Data | Where-Object Name -eq 'DestinationPort' ).'#text' } } | Format-Table -AutoSize Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -FilterXPath "*[System[EventID=22]]" -MaxEvents 50 | ForEach-Object { $xml = [xml ]$_ .ToXml() [PSCustomObject ]@ { Time = $_ .TimeCreated Image = ($xml .Event.EventData.Data | Where-Object Name -eq 'Image' ).'#text' QueryName = ($xml .Event.EventData.Data | Where-Object Name -eq 'QueryName' ).'#text' } } | Format-Table -AutoSize
7.2 离线分析 Sysmon EVTX 1 2 3 4 5 6 7 8 EvtxECmd.exe -f "C:\Evidence\Microsoft-Windows-Sysmon%4Operational.evtx" --csv C:\Evidence\parsed\ --csvf sysmon_parsed.csv hayabusa.exe csv-timeline -f "C:\Evidence\Microsoft-Windows-Sysmon%4Operational.evtx" -o C:\Evidence\sysmon_timeline.csv chainsaw hunt "C:\Evidence\Microsoft-Windows-Sysmon%4Operational.evtx" -s sigma_rules/ --mapping mappings/sigma-event-logs-all .yml
参见 33-事件日志分析工具 获取更多工具详情
八、性能调优 8.1 高容量事件的处理策略
事件
策略
原因
Event ID 7 (ImageLoaded)
使用 include,只监控特定路径
DLL 加载量极大
Event ID 10 (ProcessAccess)
使用 include + exclude 结合
进程间访问频繁
Event ID 3 (NetworkConnect)
排除已知高频合法连接
网络活动量大
Event ID 12/13 (Registry)
排除已知系统噪音路径
注册表操作频繁
Event ID 11 (FileCreate)
排除临时文件、日志文件
文件创建频繁
8.2 监控 Sysmon 自身性能 1 2 3 4 5 6 7 8 9 10 11 12 $sysmonLog = Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -MaxEvents 1000 $timeSpan = $sysmonLog [0 ].TimeCreated - $sysmonLog [-1 ].TimeCreated$eventsPerSecond = 1000 / $timeSpan .TotalSecondsWrite-Host "Sysmon events per second: $ ([math]::Round($eventsPerSecond , 2))" Get-Item "C:\Windows\System32\winevt\Logs\Microsoft-Windows-Sysmon%4Operational.evtx" | Select-Object Name, @ {N='SizeMB' ;E={[math ]::Round($_ .Length/1 MB,2 )}} Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -FilterXPath "*[System[EventID=4]]" -MaxEvents 10
8.3 日志大小配置 1 2 3 4 5 6 7 8 wevtutil sl "Microsoft-Windows-Sysmon/Operational" /ms:536870912
九、Sysmon 规避与对策 9.1 攻击者如何规避 Sysmon 卸载 Sysmon: 需要管理员权限,但获得权限后可以 Sysmon64.exe -u
停止 Sysmon 服务: sc stop Sysmon64 / net stop Sysmon64
清空 Sysmon 日志: wevtutil cl Microsoft-Windows-Sysmon/Operational
卸载 Sysmon 驱动: fltmc unload SysmonDrv
修改 Sysmon 配置: 替换为空配置,不记录任何事件
内核级绕过: Patch Sysmon 驱动的回调函数
9.2 检测 Sysmon 被篡改 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 $lastState = (Get-Service Sysmon64).Statuswhile ($true ) { Start-Sleep -Seconds 30 $currentState = (Get-Service Sysmon64).Status if ($currentState -ne $lastState ) { Write-Warning "Sysmon service state changed: $lastState -> $currentState " $lastState = $currentState } }
9.3 加固 Sysmon 使用 -d 参数自定义驱动名称(避免被简单搜索发现)
1 2 Sysmon64.exe -i sysmonconfig.xml -d MyCustomDriver
使用 ACL 保护 Sysmon 配置文件和服务
将 Sysmon 日志实时转发到 SIEM,即使本地被清除也有副本
参考链接 Sysmon 官方文档
SwiftOnSecurity/sysmon-config
olafhartong/sysmon-modular
TrustedSec Sysmon Community Guide
Sysmon - DFIR (SANS)
关联页面:03-事件日志分析 | 21-WMI事件订阅后门 | 33-事件日志分析工具