NexusFang-tech/evtxplorer

GitHub: NexusFang-tech/evtxplorer

基于 YAML 规则引擎的 Windows 事件日志分析工具,支持 MITRE ATT&CK 映射和阈值检测。

Stars: 0 | Forks: 0

# EVTXplorer [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/aea4f9e25e024658.svg)](https://github.com/NexusFang-Tech/evtxplorer/actions/workflows/ci.yml) [![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) EVTXplorer 解析 Windows 事件日志(`.evtx` 二进制文件或导出的 `.xml`),并根据 YAML 检测规则库评估每个事件。每条规则对应一个 MITRE ATT&CK 技术,并可选择将事件聚合为基于阈值的检测 —— 仅当在滑动时间窗口内发生 N 个匹配事件时才触发告警。 ## 功能特性 - **双格式支持** — 解析 `.evtx` 二进制日志或从事件查看器导出的 XML - **YAML 规则引擎** — 以人类可读的规则而非代码编写检测逻辑 - **阈值检测** — 通过在可配置的时间窗口内聚合事件,对暴力破解、密码喷洒和批量 AD 侦察进行告警,并支持按任意字段组合分组 - **MITRE ATT&CK 集成** — 每条规则映射到一个技术 ID;报告包括战术、技术名称和指向 ATT&CK 知识库的直接链接 - **三种输出格式** — 结构化 JSON、扁平 CSV 或自包含的 HTML 报告 - **丰富的终端输出** — 带有实时进度的颜色编码严重性表格,无需配置 - **可安装的 CLI** — `pip install -e .` 后即可在任意位置运行 `evtxplorer` - **CI 测试** — 跨 Python 3.10、3.11 和 3.12 的 GitHub Actions 流水线 ## 检测覆盖范围 | Rule ID | Name | MITRE Technique | Severity | |-----------|---------------------------------------------|--------------------------|----------| | EVT-C001 | Failed Logon Attempt | T1110.001 Brute Force | info | | EVT-C002 | Brute Force Login Attempts *(threshold)* | T1110.001 Brute Force | high | | EVT-C003 | Password Spray — Network Logon Failures | T1110.003 Password Spray | high | | EVT-C004 | LSASS Process Memory Access | T1003.001 LSASS Memory | critical | | EVT-C005 | Kerberos TGS Request — Kerberoasting | T1558.003 Kerberoasting | high | | EVT-C006 | Logon with Explicit Credentials | T1550.002 Pass-the-Hash | medium | | EVT-L001 | Remote Desktop Protocol Logon | T1021.001 RDP | medium | | EVT-L002 | Network Logon — Admin Share Access | T1021.002 SMB Shares | low | | EVT-L003 | Potential Pass-the-Hash — NTLM Logon | T1550.002 Pass-the-Hash | high | | EVT-L004 | New Service Installed Remotely | T1543.003 Windows Service| high | | EVT-L005 | Scheduled Task Created | T1053.005 Scheduled Task | medium | | EVT-P001 | New Local User Account Created | T1078 Valid Accounts | medium | | EVT-P002 | User Added to Privileged Group | T1078.002 Domain Accounts| high | | EVT-P003 | Token Privilege Adjustment — UAC Bypass | T1548.002 Bypass UAC | medium | | EVT-P004 | Special Privileges Assigned at Logon | T1134.001 Token Theft | medium | | EVT-P005 | Windows Defender Real-Time Protection Off | T1562.001 Disable Tools | high | | EVT-P006 | Security Event Log Cleared | T1070.001 Clear Logs | critical | | EVT-P007 | PowerShell Script Block Logged | T1059.001 PowerShell | medium | | EVT-D001 | Domain Admin Group Enumerated | T1069.002 Domain Groups | medium | | EVT-D002 | Bulk Security Group Enumeration *(threshold)* | T1069.002 Domain Groups | high | | EVT-D003 | User Group Membership Queried | T1087.002 Domain Account | low | ## 安装 **要求:** Python 3.10+ ``` git clone https://github.com/NexusFang-Tech/evtxplorer.git cd evtxplorer pip install -e . ``` 为了解析 `.evtx` 二进制文件,`python-evtx` 已作为依赖项包含在内。来自 Windows 事件查看器的 XML 导出无需任何额外要求即可工作。 ## 使用方法 ### 基础 — 分析日志文件,打印结果到终端 ``` evtxplorer --input security.evtx ``` ### 分析导出的 XML 日志 ``` evtxplorer --input C:\Users\analyst\Desktop\security_export.xml ``` ### 分析日志目录并生成 HTML 报告 ``` evtxplorer --input logs/ --format html --output report.html ``` ### 多输入文件并输出 JSON ``` evtxplorer --input security.evtx system.evtx --format json --output findings.json ``` ### 仅筛选高严重性和严重发现 ``` evtxplorer --input security.evtx --severity high critical ``` ### 使用自定义规则目录 ``` evtxplorer --input security.evtx --rules /path/to/my/rules/ ``` ### 完整选项 ``` usage: evtxplorer [-h] --input PATH [PATH ...] [--rules DIR] [--format {json,csv,html,none}] [--output FILE] [--severity LEVEL [LEVEL ...]] [--verbose] [--version] options: --input, -i Event log file(s) or directory (.evtx, .xml, .txt) --rules, -r Directory containing YAML rule files (default: ./rules) --format, -f Output format: json | csv | html | none (default: none) --output, -o Output file path (required for json/csv/html) --severity Filter to specific severity levels --verbose Enable debug logging --version Show version and exit ``` ## 编写检测规则 规则是 `rules/` 目录中的 YAML 文件。EVTXplorer 递归加载所有 `.yml` 和 `.yaml` 文件,因此您可以将规则组织到子目录中。 ### 最小规则 ``` id: EVT-CUSTOM-001 name: "Account Lockout" description: "A user account was locked out." severity: medium mitre: T1110.001 match: event_id: 4740 channel: Security ``` ### 带有 EventData 字段条件的规则 ``` id: EVT-CUSTOM-002 name: "Interactive Logon as SYSTEM" description: "An interactive logon (Type 2) occurred using the SYSTEM account." severity: high mitre: T1078 match: event_id: 4624 channel: Security data: LogonType: "2" TargetUserName: "SYSTEM" ``` ### 阈值规则 — 在时间窗口内发生 N 个事件后触发 ``` id: EVT-CUSTOM-003 name: "Account Lockout Storm" description: "Multiple accounts locked out in a short window — possible spray attack." severity: critical mitre: T1110.003 match: event_id: 4740 channel: Security threshold: count: 5 window_seconds: 30 group_by: [computer] ``` ### 规则字段参考 | Field | Type | Required | Description | |------------------------------|-------------------|----------|-------------| | `id` | string | ✅ | Unique rule identifier | | `name` | string | ✅ | Short descriptive name | | `description` | string | — | Analyst-facing explanation | | `severity` | string | ✅ | `critical` \| `high` \| `medium` \| `low` \| `info` | | `mitre` | string | — | ATT&CK technique ID (e.g. `T1078.002`) | | `tags` | list[string] | — | Arbitrary labels for filtering | | `references` | list[string] | — | URLs to supporting documentation | | `match.event_id` | int or list[int] | ✅ | Windows Event ID(s) to match | | `match.channel` | string | — | Substring match on log channel name | | `match.provider` | string | — | Substring match on provider name | | `match.data` | dict | — | EventData field exact-match conditions | | `threshold.count` | int | — | Number of matches required to fire | | `threshold.window_seconds` | int | — | Sliding window duration | | `threshold.group_by` | list[string] | — | Fields to group by (e.g. `computer`, `data.TargetUserName`) | ## 输出格式 ### 终端(默认) 带有严重性计数、规则名称、MITRE ID、计算机名、事件 ID 和时间戳的颜色编码发现表格。如果没有发现则退出代码为 `0`,如果有发现则为 `1` —— 适用于脚本和流水线集成。 ### JSON (`--format json`) 包含 `summary` 块(严重性计数、技术细分、战术覆盖)和 `findings` 数组的结构化输出,后者包含完整规则元数据、MITRE ATT&CK 链接、事件数据以及阈值发现的贡献事件计数。 ### CSV (`--format csv`) 扁平表格输出 —— 每个发现一行。适用于导入 Excel、Splunk 或任何 SIEM 采集流水线。 ### HTML (`--format html`) 自包含的深色主题报告,带有严重性摘要卡片、带有可展开 EventData 的可排序发现表格、MITRE 技术覆盖细分以及指向 ATT&CK 条目的直接链接。无外部依赖 —— 可作为单个文件分享。 ## 项目结构 ``` evtxplorer/ ├── evtxplorer/ │ ├── __init__.py # Version │ ├── cli.py # Argparse entry point, Rich terminal output │ ├── engine.py # Rule loader and detection engine │ ├── mitre.py # ATT&CK technique registry │ ├── parser.py # EVTX binary and XML log parsing │ └── reporter.py # JSON, CSV, and HTML output ├── rules/ │ ├── credential_access.yml │ ├── discovery.yml │ ├── lateral_movement.yml │ └── persistence_and_privilege_escalation.yml ├── tests/ │ ├── fixtures/ # Synthetic event log XML for testing │ ├── conftest.py │ ├── test_engine.py │ ├── test_parser.py │ └── test_reporter.py ├── .github/workflows/ │ └── ci.yml # Python 3.10 / 3.11 / 3.12 matrix └── pyproject.toml ``` ## 开发 ``` # 安装 dev dependencies pip install -e ".[dev]" # 运行 tests 并包含 coverage pytest # Lint ruff check evtxplorer/ # 重新生成 test fixtures python tests/fixtures/generate_fixtures.py ``` ## 路线图 - [ ] Sigma 规则兼容层 - [ ] Sysmon 事件支持(Event IDs 1, 3, 7, 10, 11) - [ ] 针对大型日志集的 JSONL 流式输出 - [ ] 基线模式 —— 抑制与已知良好配置文件匹配的检测 - [ ] 网络共享和 UNC 路径输入支持 ## 许可证 MIT — 见 [LICENSE](LICENSE)。 ## 参考 - [MITRE ATT&CK for Enterprise](https://attack.mitre.org/matrices/enterprise/) - [Ultimate Windows Security — Event ID Encyclopedia](https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/) - [Microsoft Security Auditing Documentation](https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/security-auditing-overview) - [python-evtx](https://github.com/williballenthin/python-evtx) by Willi Ballenthin
标签:AMSI绕过, Cloudflare, EDR, EVTX分析器, HTML报告生成, MITRE ATT&CK, Python安全工具, SIEM日志分析, Windows事件日志, YAML规则引擎, 免杀技术, 多模态安全, 威胁检测, 密码喷洒检测, 暴力破解检测, 红队行动, 网络安全, 聊天机器人, 脆弱性评估, 阈值告警, 隐私保护