WhiteMooncy/Wazuh-Rules-Teams

GitHub: WhiteMooncy/Wazuh-Rules-Teams

为 Wazuh SIEM 提供 67 条精调的 Windows 安全事件检测规则,并通过 Power Automate 实现与 Microsoft Teams 的智能告警聚合与即时推送,显著降低告警噪音。

Stars: 0 | Forks: 0

# Wazuh 自定义规则与 Teams 集成 **Wazuh SIEM 完整的自定义规则集以及与 Microsoft Teams 的集成方案** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Wazuh Version](https://img.shields.io/badge/Wazuh-4.x-blue)](https://wazuh.com/) [![Platform](https://img.shields.io/badge/Platform-Linux-lightgrey)](https://www.linux.org/) ## 📋 描述 本项目提供了一套完整的实施方案: - **67 条自定义规则**,用于 Windows 安全事件 (Kerberos、进程执行、账户管理、LSASS 等) - 使用 Power Automate 实现与 **Microsoft Teams 的智能集成** - **累积摘要系统**(每 3 条告警或 24 小时发送一次) - **即时关键告警**(等级 ≥15) - **减少 80% 的噪音**(从每天约 40 条告警减少到约 5-8 条) ## 🎯 主要特性 ### ✅ 自定义规则(共 67 条) - **Kerberos 身份验证**(6 条规则):检测 TGT、服务票据、Kerberoasting 攻击 - **服务安装**(2 条规则):检测可疑服务与持久化 - **进程执行**(5 条规则):CMD、PowerShell、WScript、RegEdit、Net.exe - **凭证访问**(2 条规则):LSASS 访问、Mimikatz - **账户管理**(15 条规则):创建、修改、特权组 - **密码操作**(4 条规则):密码更改、重置 - **防御规避**(1 条规则):日志清除(关键) - **Linux PAM**(1 条规则):Root 身份验证 ### ✅ Teams 集成 - **智能摘要**:带有统计信息的告警累积 - **关键告警**:等级 ≥15 时立即发送 - **Adaptive Cards**:包含 MITRE ATT&CK、Agent、等级的丰富格式 - **Dashboard 链接**:直达 Wazuh Dashboard 的按钮 - **无表情符号**:完全兼容企业 Webhook ## 📊 效果 | 指标 | 之前 | 之后 | 改善 | |---------|-------|---------|--------| | 告警/天 | ~40 | ~5-8 | **减少 80%** | | 最低等级 | 9 | 11 | 噪音更少 | | 格式 | 单条 | 摘要 | 干扰更少 | | 关键告警 | 混合 | 即时 | 响应更好 | ## 🚀 快速安装 ### 前置条件 - 已安装 Wazuh Manager 4.x - 服务器的 Root 权限 - Microsoft Teams 账户 - Power Automate(包含在 Microsoft 365 中) ### 第 1 步:复制规则 ``` # 连接到 Wazuh 服务器 ssh root@ # 复制 custom 规则 cd /var/ossec/etc/rules/ wget https://raw.githubusercontent.com//wazuh-custom-rules-teams/main/rules/custom_windows_security_rules.xml wget https://raw.githubusercontent.com//wazuh-custom-rules-teams/main/rules/local_rules_override.xml # 验证语法 /var/ossec/bin/wazuh-logtest -t ``` ### 第 2 步:安装集成脚本 ``` # 复制 scripts cd /var/ossec/integrations/ wget https://raw.githubusercontent.com//wazuh-custom-rules-teams/main/integrations/custom-teams-summary.py wget https://raw.githubusercontent.com//wazuh-custom-rules-teams/main/integrations/custom-teams-summary # 授予权限 chmod +x custom-teams-summary.py custom-teams-summary chown root:wazuh custom-teams-summary.py custom-teams-summary ``` ### 第 3 步:配置 Power Automate 1. 前往 [Power Automate](https://make.powerautomate.com) 2. **创建流** → **自动化云流** 3. 触发器:**“当收到 HTTP 请求时”** 4. 操作:**“在聊天或频道中发布消息”** (Teams) 5. 复制 **HTTP POST URL** ### 第 4 步:配置 Wazuh ``` # 编辑 ossec.conf nano /var/ossec/etc/ossec.conf # 添加到末尾(在 之前): ``` ``` custom-teams-summary TU-WEBHOOK-URL-AQUI 11 json ``` ``` # 重启 Wazuh systemctl restart wazuh-manager # 检查状态 systemctl status wazuh-manager ``` ### 第 5 步:测试 ``` # 下载测试 script cd /tmp wget https://raw.githubusercontent.com//wazuh-custom-rules-teams/main/scripts/test_alerts.sh chmod +x test_alerts.sh # 执行(将生成 17 条测试 alerts) ./test_alerts.sh ``` ## 📁 项目结构 ``` wazuh-custom-rules-teams/ ├── README.md # Este archivo ├── LICENSE # Licencia MIT ├── .gitignore # Archivos excluidos │ ├── rules/ # Reglas de detección │ ├── custom_windows_security_rules.xml # 62 reglas custom │ ├── local_rules_override.xml # 5 reglas override │ └── README.md # Documentación de reglas │ ├── integrations/ # Scripts de integración │ ├── custom-teams-summary.py # Script principal Python │ ├── custom-teams-summary # Wrapper bash │ ├── custom-teams.py # Script alternativo │ └── README.md # Documentación integración │ ├── scripts/ # Utilidades y testing │ ├── test_alerts.sh # Prueba 17 alertas │ ├── test_all_rules.sh # Prueba 35+ alertas │ ├── migration.sh # Script de migración │ └── README.md # Guía de scripts │ ├── docs/ # Documentación completa │ ├── INSTALLATION.md # Guía de instalación detallada │ ├── MIGRATION.md # Migración entre servidores │ ├── RULES_REFERENCE.md # Referencia completa de reglas │ ├── TEAMS_SETUP.md # Configuración de Teams │ ├── TROUBLESHOOTING.md # Solución de problemas │ ├── CONTEXTO_WAZUH.md # Contexto completo Wazuh │ └── MANUAL_CONFIGURACION.md # Manual técnico completo │ └── examples/ # Ejemplos de configuración ├── ossec.conf.example # Configuración ossec.conf ├── power_automate_flow.json # Flujo de Power Automate └── adaptive_card_template.json # Template de Adaptive Card ``` ## 📖 文档 - **[完整安装指南](docs/INSTALLATION.md)**:从零开始的分步指南 - **[迁移指南](docs/MIGRATION.md)**:在服务器之间迁移配置 - **[规则参考](docs/RULES_REFERENCE.md)**:67 条规则详解 - **[Teams 配置](docs/TEAMS_SETUP.md)**:Power Automate 完整设置 - **[故障排除](docs/TROUBLESHOOTING.md)**:常见问题与解决方案 ## 🔍 重点规则 ### 🔴 关键等级 (15) ``` 60000 lsass.exe mimikatz|procdump Mimikatz detectado | Mimikatz credential dumping detected T1003.001 T1003 18101 ^1102$ Log de eventos de seguridad limpiado | Windows Security log cleared T1070.001 ``` ### 🟠 极高等级 (12-13) ``` 60103 ^4720$ Cuenta de usuario creada | User account created T1136.001 60100 Domain Admins Usuario añadido a Domain Admins | User added to Domain Admins group T1098 ``` ## 🎨 Teams 告警示例 ### 累积摘要(每 3 条告警或 24 小时) ``` [MUY ALTO] Resumen de Alertas Wazuh - 24h Total de Alertas: 5 Periodo: 24h Nivel Máximo: 13 Agentes Afectados: 2 Distribución por Nivel: Nivel 13: 2 alertas Nivel 12: 1 alertas Nivel 9: 1 alertas Top 5 Reglas Activadas: 1. Rule 100006 (1×): Kerberos autenticación fallida - cuenta expirada 2. Rule 100008 (1×): Servicio sospechoso instalado 3. Rule 100035 (1×): Acceso a proceso LSASS 4. Rule 100007 (1×): Servicio nuevo instalado 5. Rule 5502 (1×): PAM: Login session closed Top MITRE ATT&CK: • T1558 (Steal or Forge Kerberos Tickets) • T1543.003 (Create or Modify System Process) • T1003.001 (LSASS Memory) [Ver Dashboard] [Descartar] ``` ### 即时关键告警(等级 ≥15) ``` [CRITICO] ALERTA CRÍTICA WAZUH ID de Regla: 100101 Nivel: 15 Descripción: Log de seguridad limpiado | Security log cleared Agente: DC01 Timestamp: 2026-03-11 14:30:45 Técnicas MITRE ATT&CK: • T1070.001: Clear Windows Event Logs Usuario: administrator IP de Origen: 192.168.1.100 Log: EventChannel [Ver en Dashboard] [Investigar] ``` ## 🔧 高级配置 ### 调整摘要阈值 编辑 `/var/ossec/integrations/custom-teams-summary.py`: ``` # 第 ~15 行 MAX_ALERTS_BEFORE_SUMMARY = 3 # Cambiar a 5, 10, etc. SUMMARY_INTERVAL_HOURS = 24 # Cambiar a 12, 48, etc. CRITICAL_LEVEL = 15 # Nivel para envío inmediato ``` ### 更改最低等级 编辑 `/var/ossec/etc/ossec.conf`: ``` 11 ``` ### 按特定规则过滤 ``` custom-teams-summary ... 11 100001,100036,100101 ``` ## 🐛 故障排除 ### 问题:Webhook 返回 404 **原因**:URL 过期或 Power Automate 中的流被禁用 **解决方案**: 1. 验证 Power Automate 中的流是否已**启用** 2. 如有必要,重新生成 Webhook 3. 在 `/var/ossec/etc/ossec.conf` 中更新配置 4. 重启:`systemctl restart wazuh-manager` ### 问题:Teams 未收到告警 **诊断**: ``` # 查看 integration logs tail -50 /var/ossec/logs/integrations.log # 查看生成的 alerts tail -50 /var/ossec/logs/alerts/alerts.json | jq 'select(.rule.level >= 11)' # 手动测试 tail -1 /var/ossec/logs/alerts/alerts.json | \ /var/ossec/integrations/custom-teams-summary "TU-WEBHOOK-URL" ``` ### 问题:累积了大量告警 **临时解决方案**: ``` # 清除 cache rm /var/ossec/logs/teams_alerts_cache.pkl # 或强制发送 python3 << 'EOF' import pickle cache = {'alerts': [], 'last_summary_time': None, 'summary_count': 0} pickle.dump(cache, open('/var/ossec/logs/teams_alerts_cache.pkl', 'wb')) EOF ``` 查看 [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) 了解更多常见问题。 ## 📝 更新日志 ### v1.0.0 (2026-03-11) - ✅ 67 条自定义规则的初始实施 - ✅ 与 Microsoft Teams 集成 - ✅ 累积摘要系统 - ✅ 即时关键告警 - ✅ 完整文档 - ✅ 测试与迁移脚本 ## 📄 许可证 本项目基于 MIT 许可证 - 详见 [LICENSE](LICENSE)。 ## 👤 作者 **Mateo Villablanca** - GitHub: [@mvillablanca](https://github.com/WhiteMooncy) ## 🙏 致谢 - [Wazuh](https://wazuh.com/) - 开源 SIEM 平台 - [Microsoft Teams](https://www.microsoft.com/microsoft-teams/) - 通信平台 - [MITRE ATT&CK](https://attack.mitre.org/) - 攻击者技术框架 **⭐ 如果这个项目对你有帮助,请考虑在 GitHub 上给它一个 Star**
标签:AMSI绕过, Cloudflare, Conpot, Homebrew安装, HTTP/HTTPS抓包, Kerberos安全, LSASS保护, Microsoft Teams, Mimikatz检测, MITRE ATT&CK, OpenCanary, Power Automate, Wazuh, Windows安全, 告警降噪, 威胁检测, 安全告警, 安全集成, 应用安全, 微软Teams, 态势感知, 权限管理, 模型越狱, 模拟器, 私有化部署, 逆向工具, 防御规避