olafhartong/sysmon-modular

GitHub: olafhartong/sysmon-modular

一个模块化的 Sysmon 配置规则仓库,提供基于 PowerShell 和 Python 的配置生成工具,帮助用户高效定制和管理 Windows 端点监控策略。

Stars: 3063 | Forks: 645

# sysmon-modular | 供所有人自定义的 Sysmon 配置仓库 [![license](https://img.shields.io/github/license/olafhartong/sysmon-modular.svg?style=flat-square)](https://github.com/olafhartong/sysmon-modular/blob/master/license.md) ![Maintenance](https://img.shields.io/maintenance/yes/2026.svg?style=flat-square) [![GitHub last commit](https://img.shields.io/github/last-commit/olafhartong/sysmon-modular.svg?style=flat-square)](https://github.com/olafhartong/sysmon-modular/commit/master) ![Build Sysmon config with all modules](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/b835264bc1000201.svg) [![Twitter](https://img.shields.io/twitter/follow/olafhartong.svg?style=social&label=Follow)](https://twitter.com/olafhartong) [![Discord Shield](https://discordapp.com/api/guilds/715302469751668787/widget.png?style=shield)](https://discord.gg/B5n6skNTwy) 这是一个 Microsoft Sysinternals Sysmon 的[在此下载](https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon)配置仓库,采用模块化设置,以便于更轻松地维护和生成特定配置。 请记住,任何这些配置都应被视为一个起点,**强烈**建议针对特定环境进行调整。 **注意:** 为了从 FileExecutable 事件中获取更多价值,建议将最新版本的 LOLdrivers 配置合并到该配置中。你可以通过获取该文件并将其添加到 `29_file_execute_detected` 文件夹中,然后生成新配置来轻松实现这一点。 仓库中的 sysmonconfig.xml 是在 PowerShell 脚本成功合并且 Sysmon 在 Azure Pipeline 运行中成功加载后自动生成的。有关如何生成包含自定义模块的自定义配置的更多信息,请参见[此处](https://github.com/olafhartong/sysmon-modular/wiki/Configuration-options#generating-custom-configs) ## 预生成配置 | 类型 | 配置 | 描述| | --- | --- | --- | | default | [sysmonconfig.xml](https://raw.githubusercontent.com/olafhartong/sysmon-modular/master/sysmonconfig.xml) | 这是最常用的均衡配置,更多信息请见[此处](https://github.com/olafhartong/sysmon-modular/wiki/Configuration-options#generating-the-default-configuration) | | default+ | [sysmonconfig-with-filedelete.xml](https://raw.githubusercontent.com/olafhartong/sysmon-modular/master/sysmonconfig-with-filedelete.xml) | 这是最常用的均衡配置,包含 FileDelete 文件保存功能的更多信息 | | verbose | [sysmonconfig-excludes-only.xml](https://raw.githubusercontent.com/olafhartong/sysmon-modular/master/sysmonconfig-excludes-only.xml) | 这是一个非常详尽的配置,包含所有事件,仅应用了排除模块。未经验证不应在生产环境中使用,这将产生大量数据并可能影响性能。更多信息请见[此处](https://github.com/olafhartong/sysmon-modular/wiki/Configuration-options#generating-custom-configs)| | super verbose | [sysmonconfig-research.xml](https://raw.githubusercontent.com/olafhartong/sysmon-modular/master/sysmonconfig-research.xml) | 具有极高详细程度的配置。此文件预期的日志量非常大,**绝对不要在生产环境中使用!** 此配置仅用于研究,它会消耗更多的 CPU/内存。仅在准备调查特定技术之前启用,完成后请加载较轻量级的配置。 | | MDE augment | [sysmonconfig-mde-augmentation.xml](https://raw.githubusercontent.com/olafhartong/sysmon-modular/master/sysmonconfig-mde-augment.xml) | 用于增强 Defender for Endpoint 的配置,旨在补充信息并尽可能减少重叠。它基于 default/balanced 配置,并且*不会为 Sysmon 生成所有事件*,配置中有相关注释。为了 IR 的利益,考虑使用仅排除配置并仅摄取丰富事件。(包含更多原理的博客即将发布)| ### 目录 * [必要操作](#required-actions) + [自定义](#customization) + [生成配置](#generating-a-config) - [PowerShell](#powershell) + [生成自定义配置](#generating-custom-configs) * [使用](#use) + [安装](#install) + [更新现有配置](#update-existing-configuration) * [Python 生成器工具](#python-generator-tool) * [Sysmon 社区](#sysmon-community) * [贡献](#contributing) * [更多信息](#more-information) 除了下方的文档外,还有一个关于如何使用此项目的[视频](https://youtu.be/Cx_zrM8Hu7Y)。 [![如何使用此项目](https://img.youtube.com/vi/Cx_zrM8Hu7Y/0.jpg)](https://www.youtube.com/watch?v=Cx_zrM8Hu7Y) ## 注意;低于 15 版本的 Sysmon 将无法与此配置完全兼容 旧版本仍在分支中可用,但不如当前分支完整 - V8.x >> [此处](https://github.com/olafhartong/sysmon-modular/tree/version-8) - V9.x >> [此处](https://github.com/olafhartong/sysmon-modular/tree/version-9) - V10.4 >> [此处](https://github.com/olafhartong/sysmon-modular/tree/v10.4) - V12.x >> [此处](https://github.com/olafhartong/sysmon-modular/tree/version-12) - V13.x / 14.x >> [此处](https://github.com/olafhartong/sysmon-modular/tree/version-13-14) 要了解各版本新增的功能,请查看我的[简短博客文章](https://medium.com/falconforce/sysmon-11-dns-improvements-and-filedelete-events-7a74f17ca842)及更新的文章,或观看我的 [DerbyCon 演讲](http://www.irongeek.com/i.php?page=videos/derbycon9/stable-36-endpoint-detection-super-powers-on-the-cheap-with-sysmon-olaf-hartong) **注意:** 我确实建议在你的环境中使用尽可能少的配置,原因有很多,比如:维护、输出一致性、可管理性等等。但请务必为域控制器、服务器和工作站制定专门的配置。 ## 必要操作 我强烈建议在将配置实施到生产环境之前先进行检查。这能让你获得最具可操作性的日志,并尽可能减少噪音。 ### 自定义 在广泛部署之前,你需要在自己的环境中安装并观察配置的结果。 例如,你需要排除防病毒软件的操作,否则它很可能会用无用的信息填满你的日志。 ### 生成配置 #### PowerShell ``` $> git clone https://github.com/olafhartong/sysmon-modular.git $> cd sysmon modular $> . .\Merge-SysmonXml.ps1 $> Merge-AllSysmonXml -Path ( Get-ChildItem '[0-9]*\*.xml') -AsString | Out-File sysmonconfig.xml ``` ### 生成自定义配置 以下功能特别感谢 mbmy **新功能:** `Find-RulesInBasePath` - 接受一个基础路径(例如 `C:\folder\sysmon-modular\`),并根据正则表达式模式查找所有候选的 xml 规则文件 示例: ```PS C:\Users\sysmon\sysmon-modular> Find-RulesInBasePath -BasePath C:\users\sysmon\sysmon-modular\ -OutputRules | Out-File available_rules.txt``` **Merge-AllSysmonXml 新参数:** `-BasePath` - 根据正则表达式模式从提供的路径中查找所有候选的 xml 规则文件并合并它们 示例: ```PS C:\Users\sysmon\sysmon-modular> Merge-AllSysmonXml -AsString -BasePath C:\Users\sysmon\sysmon-modular\``` `-ExcludeList` - 与 `-BasePath` 结合使用,接收一个规则列表,并在合并前将它们从找到的规则中排除 示例: ```PS C:\Users\sysmon\sysmon-modular> Merge-AllSysmonXml -AsString -BasePath C:\Users\sysmon\sysmon-modular\ -ExcludeList C:\users\sysmon\sysmon-modular\exclude_rules.txt``` `-IncludeList` - 与 `-BasePath` 结合使用,从基础路径查找所有可用规则,但仅合并列表中定义的规则 示例: ```PS C:\Users\sysmon\sysmon-modular> Merge-AllSysmonXml -AsString -BasePath C:\Users\sysmon\sysmon-modular\ -IncludeList C:\users\sysmon\sysmon-modular\include_rules.txt``` **注意** BasePath 必须是 sysmon-modular 文件的完整路径(例如 `c:\tools\sysmon-modular`),否则 PowerShell 将无法找到它们,从而导致生成默认配置。 包含/排除列表示例格式: ``` 3_network_connection_initiated\include_native_windows_tools.xml 12_13_14_registry_event\exclude_internet_explorer_settings.xml 12_13_14_registry_event\exclude_webroot.xml 17_18_pipe_event\include_winreg.xml 19_20_21_wmi_event\include_wmi_create.xml 2_file_create_time\exclude_chrome.xml 3_network_connection_initiated\include_native_windows_tools.xml 3_network_connection_initiated\include_ports_proxies.xml 8_create_remote_thread\include_general_commment.xml 8_create_remote_thread\include_psinject.xml 9_raw_access_read\include_general_commment.xml ``` **为特定事件 ID 构建包含所有 sysmon-modular 规则的配置(包含整个目录),然后禁用所有没有导入规则的事件 ID** 示例: ``` # 生成 config $sysmonconfig = Merge-AllSysmonXml -BasePath . -IncludeList $workingFolder\include.txt -VerboseLogging -PreserveComments # 关闭任何未导入 rules 的 rule groups foreach($rg in $sysmonconfig.SelectNodes("/Sysmon/EventFiltering/RuleGroup [*/@onmatch]")) { $ruleNodes = $rg.SelectNodes("./* [@onmatch]") if( $ruleNodes -eq $null ` -or $ruleNodes.ChildNodes.count -gt 0) { # no rule nodes found (unlikely) or more than one rule found continue } # RuleGroup with only one rule node $ruleNode = $ruleNodes[0] if($ruleNode.onmatch -eq "exclude" -and $ruleNode.ChildNodes.count -eq 0 ) { $message = "{0} {1} has no matching conditions. Toggled to 'include' to limit output" -f $ruleNode.Name,$rg.Name Write-Warning $message $ruleNode.onmatch = "include" $comment = $sysmonconfig.CreateComment($message) $rg.AppendChild($comment) | Out-Null } } ``` 包含/排除列表示例格式(用于整个规则/事件系列): ``` 1_process_creation 5_process_ended 11_file_create 23_file_delete 7_image_load 17_18_pipe_event ``` ## 使用 ### 安装 使用管理员权限运行 ``` sysmon.exe -accepteula -i sysmonconfig.xml ``` ### 更新现有配置 使用管理员权限运行 ``` sysmon.exe -c sysmonconfig.xml ``` ## Python 生成器工具 这是一项新功能,由 [cnnrshd](https://github.com/cnnrshd) 创建 ### 基于优先级的规则排序 1. 简单的 Python 脚本,可以基于与现有包含列表类似的格式进行合并 - 唯一的区别是它接受一个包含两列(文件路径和优先级)的 CSV 文件 2. 使用 CSV 文件格式化的配置 3. 一个简单的模板 4. Schemaversion 是动态的,基于所提供规则的最高 schema 版本。 使用此脚本生成的配置保留了注释,并强制执行了正确的 XML 缩进,提高了可读性并允许更轻松地交叉引用规则文件 示例命令 ``` python merge_sysmon_configs.py config_lists/default_list/default_list.csv -f csv -b templates/sysmon_template.xml -o test.xml ``` ** 这种生成内容的方式仍然是全新且处于实验阶段的。目前尚不支持像 MDE augment 和 exclude-only 这样的自定义版本。 ## 更多信息 我开始撰写一系列涵盖此仓库的博客文章; - [低成本的端点检测超能力 - 第 1 部分 - MITRE ATT&CK、Sysmon 与我的模块化配置](https://medium.com/@olafhartong/endpoint-detection-superpowers-on-the-cheap-part-1-e9c28201ac47) - [低成本的端点检测超能力 — 第 2 部分 — 部署与维护](https://medium.com/@olafhartong/endpoint-detection-superpowers-on-the-cheap-part-2-deploy-and-maintain-d06580329fe8) - [低成本的端点检测超能力 — 第 3 部分 — Sysmon 篡改](https://medium.com/@olafhartong/endpoint-detection-superpowers-on-the-cheap-part-3-sysmon-tampering-49c2dc9bf6d9) - [Sysmon 与 Microsoft Defender for Endpoint 的对比](https://medium.com/falconforce/sysmon-vs-microsoft-defender-for-endpoint-mde-internals-0x01-1e5663b10347) ## MITRE ATTACK 只要 Sysmon 能够检测到,我就致力于将所有配置映射到 ATT&CK 框架。 请注意,这是一个*可能的日志条目*,可能会引导实现检测,但在所有情况下,这并不是该技术的唯一遥测数据。此外,该规则可能关联到更多的技术,所映射的是我认为最可能的那一个。
标签:AI合规, Libemu, Sysmon, 安全, 终端检测与响应, 超时处理, 逆向工具