vastlimits/uberAgent-ESA-Sysmon-Converter
GitHub: vastlimits/uberAgent-ESA-Sysmon-Converter
一款基于 .NET 8 的跨平台命令行工具,用于将 Sysmon 配置规则自动转换为 uberAgent ESA 威胁检测规则,帮助企业平滑迁移端点监控方案。
Stars: 4 | Forks: 1
# uberAgent-ESA-Sysmon-Converter
## 目录
- [平台](#platforms)
- [入门指南](#getting-started)
- [语法](#syntax)
- [示例](#example)
- [限制](#limitations)
- [许可证](#license)
## 平台
uberAgent-ESA-Sysmon-Converter 使用 .NET 8 开发,因此是跨平台的。
## 入门指南
### 下载
1. 最新的二进制压缩包可以在[这里](https://github.com/vastlimits/uberAgent-ESA-Sysmon-Converter/releases/tag/v1.2.1)找到。
2. 解压后,可以通过命令行控制该转换器。
### 转换
更多信息请参见[语法](#syntax)。
### 转换完成后
转换器成功运行后,将在输出目录中创建以下文件。
1. `uberAgent-ESA-am-converted.conf`
所有支持的规则都被序列化到 `uberAgent-ESA-am-converted.conf` 中。
有关 uberAgent 设置的更多信息,请参阅关于[威胁检测引擎](https://uberagent.com/docs/uberagent/latest/esa-features-configuration/threat-detection-engine/)的文档。
## 语法
要转换一个或多个文件中的所有规则,请使用以下命令:
```
vl.Sysmon.Converter --input filePath1 filePath2 --output outputFolder
```
要转换一个或多个特定的 Sysmon 规则:
```
vl.Sysmon.Converter --input filePath1 filePath2 --output outputFolder --rule 1 2 12
```
生成的 uberAgent 规则的默认风险分数为 50。可以在命令行中覆盖它:
```
vl.Sysmon.Converter --input filePath1 filePath2 --output outputFolder --rule 1 2 12 --score 75
```
### 目标 uberAgent 版本
如果未指定 uberAgent 版本,则假定为最新支持的 uberAgent 版本。要转换为较旧的 uberAgent 版本,请在命令行中指定它:
```
vl.Sysmon.Converter --input filePath1 filePath2 --output outputFolder --rule 1 2 12 --score 75 --version 6.1
```
上述命令的简写形式:
```
vl.Sysmon.Converter -i filePath1 -o outputFolder -r 1 2 12 -s 75 -v 6.1
```
#### 支持的 uberAgent 版本
- 6.0
- 6.1
- 6.2
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 7.5
- 8.0
未知的版本值将被记录为警告,并回退到最新支持的版本。
### 验证
该解决方案包含一个 xUnit 测试项目,涵盖了最容易发生回归的转换器语义:
- Sysmon 包含/排除优先级。
- 默认的 Sysmon 字段语义(重复字段为 `or`,不同字段之间为 `and`)。
- 嵌套的 `` / `` 括号。
- 一个 `` 内的重复事件元素以及 sysmon-modular 事件包装文件。
- `OriginalFileName` 第一阶段映射。
- 当前 uberAgent 版本的版本解析。
使用以下命令运行验证套件:
```
dotnet test vl.Sysmon.Converter.sln
```
## 示例
以下是来自 [SwiftOnSecurity 的 Sysmon 配置](https://github.com/SwiftOnSecurity/sysmon-config) 中一个 **ProcessCreate** 的片段:
```
C:\Windows\System32\RuntimeBroker.exe -Embedding
C:\Program Files (x86)\Common Files\microsoft shared\ink\TabTip32.exe
AppContainer
%%SystemRoot%%\system32\csrss.exe ObjectDirectory=\Windows
C:\windows\system32\wermgr.exe -queuereporting
C:\Windows\system32\SearchIndexer.exe
C:\Windows\system32\svchost.exe -k appmodel -s StateRepository
C:\Windows\system32\svchost.exe -k wsappx
C:\Windows\system32\svchost.exe -k netsvcs
C:\Windows\system32\svchost.exe -k localSystemNetworkRestricted
C:\Windows\system32\deviceenroller.exe /c /AutoEnrollMDM
"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe" --type=
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\Ngen.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorsvw.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorsvw.exe
C:\Windows\Microsoft.Net\Framework64\v3.0\WPF\PresentationFontCache.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorsvw.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorsvw.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngentask.exe
C:\Program Files\Microsoft Office\Office16\MSOSYNC.EXE
C:\Program Files (x86)\Microsoft Office\Office16\MSOSYNC.EXE
C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeC2RClient.exe
C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe
C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeC2RClient.exe
C:\Program Files\Windows Media Player\wmpnscfg.exe
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --type=
"C:\Program Files\Google\Chrome\Application\chrome.exe" --type=
```
在执行命令 `vl.Sysmon.Converter -i C:\tmp\example.xml -o C:\tmp\exampleOutput\` 之后
你应该会看到 **uberAgent-ESA-am-converted.conf** 包含一个 `[ActivityMonitoringRule]` 小节。该转换器保留了 Sysmon 的包含/排除和组关系语义,并输出转义后的 uAQL 字符串字面量。
```
[ActivityMonitoringRule]
RuleName = ProcessStart converted rule
EventType = Process.Start
Tag = processstart-1-converted-rule
RiskScore = 50
Query = not (Process.CommandLine == "C:\\Windows\\System32\\RuntimeBroker.exe -Embedding" or ...)
```
## 限制
### Sysmon 事件 ID
以下 Sysmon 事件 ID 尚未被 uberAgent 支持,在转换过程中会被忽略:
- 10: ProcessAccess
- 19: WMI filter
- 20: WMI consumer
- 21: WMI consumer filter
- 23: FileDelete
- 未完全支持,被视为 `ID: 26 - File Delete Logged`。
- 24: ClipboardChange
- 27: File Block Executable
- 28: File Block Shredding
- 29: File Executable Detected
### Sysmon 字段
以下 Sysmon 字段尚未被 uberAgent 支持,在转换过程中会被忽略:
- Archived
- Contents
- CurrentDirectory
- Description
- Device
- Guid
- Initiated
- IntegrityLevel
- LogonGuid
- LogonId
- Product
- SourceProcessGuid
- TargetProcessGuid
- SourceImage
- UtcTime
- QueryStatus
`OriginalFileName` 作为第一阶段映射受到支持。在 uberAgent 提供专用的 `OriginalFileName` 属性之前,转换器会将其映射到相应的进程或映像名称字段。
### 规则名称
Sysmon 规则组名称会被转换为 uberAgent 规则名称。属于规则组的那部分 Sysmon 规则的名称不会被转换。
#### 示例
Sysmon 规则片段:
```
```
转换后的 uberAgent 规则小节:
```
[ActivityMonitoringRule]
RuleName = ExampleRule
EventType = Process.Start
Tag = examplerule
RiskScore = 100
Query = true
```
## 许可证
Apache License 2.0。
### 第三方代码
本项目使用了以下第三方库:
- [CommandLineParser](https://github.com/commandlineparser/commandline)
- [Serilog](https://serilog.net/)
- 用于测试的 [xUnit](https://xunit.net/)
标签:.NET 8, PB级数据处理, Sysmon, uberAgent, 安全运维, 端点检测与响应, 脱壳工具, 规则转换