mrklv01/graylog-windows-security-detections

GitHub: mrklv01/graylog-windows-security-detections

一套基于 Graylog + Winlogbeat 的 Windows Security 事件检测规则集,针对账户锁定与密码过期场景实现实时 Telegram 告警。

Stars: 0 | Forks: 0

# Windows 安全事件检测 (Graylog + Winlogbeat) ![Graylog](https://img.shields.io/badge/Graylog-Event%20Definitions-orange) ![Winlogbeat](https://img.shields.io/badge/Winlogbeat-Windows%20Security-blue) 基于通过 Winlogbeat -> Graylog 传输的 Windows Security 日志的检测目录, 并通过 Custom HTTP Notification 向 Telegram 发送警报。此为脱敏的 作品集版本:真实的 Token/chat_id —— 作为 Graylog 中特定 Notification 的 机密信息,不在此处存储。 技术栈:**Winlogbeat -> Graylog (Streams, Event Definitions: Filter & Aggregation + Event Fields + Notifications) -> Custom HTTP Notification -> Telegram**。 ``` flowchart LR A[Windows Security Log] --> B[Winlogbeat] B --> C[Graylog Stream: DC's] C --> D{Event Definition} D -->|4740: lockout| E[account_block] D -->|4625 + SubStatus 0xc0000071:\npassword expired| F[password expired to channel] E --> G[Telegram] F --> G ``` ## 检测 1: 账户锁定 (Event ID 4740) 在 Active Directory 中发生账户锁定时触发。 - **Search Query:** winlogbeat_winlog_event_id:4740 AND NOT winlogbeat_winlog_event_data_TargetUserName:(admin OR test OR service_accounts) - **Stream(s):** DC's, Default Stream - **Search within / Execute every:** 5 分钟 / 1 分钟 - **Grace period:** 1 分钟(防止针对同一事件重复触发) - **Notification:** Custom HTTP -> Telegram (`account_block`) - **Grace period / Message backlog:** 1 分钟 / 1 条消息 —— grace period 较短, 因为账户锁定需要一线做出快速反应 - **Event Fields**(用于在通知中提供上下文的事件模板化字段): - `caller_computer` — `${source.caller_computer}` - `EventTime` — `${source.timestamp}` - `Initiator` — `${source.winlogbeat_winlog_event_data_SubjectUserName}` - `locked_username` — `${source.locked_username}` - `Reason` — `${source.message}` - `Server` — `${source.winlogbeat_winlog_computer_name}` - `targetDomain` — `${source.winlogbeat_winlog_event_data_TargetDomainName}` - `TargetUsername` — `${source.winlogbeat_winlog_event_data_TargetUserName}` - **原因:** 服务/测试账户通常会产生干扰噪音(例如, 使用错误凭证的定期脚本)—— 已将其从告警中排除, 以免冲淡真实的员工锁定信号。字段集合 直接在通知中提供:谁被锁定、在哪台机器上、谁/什么 触发了锁定 —— 无需登录 Graylog 查看详情。 ## 检测 2: 密码过期 (Event ID 4625 + SubStatus 0xC0000071) 当由于密码过期导致登录失败时触发 —— 即 在用户自己注意到被锁定之前。 - **Search Query:** winlogbeat_winlog_event_id:4625 AND winlogbeat_winlog_event_data_SubStatus:0xc0000071 - **Stream(s):** DC's - **Search / execute within:** 5 分钟 - **Notification:** Custom HTTP -> Telegram (`password expired to channel`) - **Grace period / Message backlog:** 5 分钟 / 无 backlog —— 该事件不如 锁定紧急,因此 grace period 更宽 - **Event Fields:** - `Server` — `${source.winlogbeat_winlog_computer_name}` - `TargetUsername` — `${source.winlogbeat_winlog_event_data_TargetUserName}` - `WorkstationName` — `${source.winlogbeat_winlog_event_data_WorkstationName}` - **原因:** 在用户提交“无法登录”的 工单之前,主动通知支持团队。 ## 辅助通知 - `send unlock to channel` —— 账户解锁/重置时的通知。 - `Telegram Daily Report` —— 每日所有事件的汇总报告 (而不是为每个事件单独发送通知)。 - `test notification` —— 用于在更改通知配置时 测试发送是否正常的测试频道。 ## 未来规划 (roadmap) - 检测短时间内来自同一 `caller_computer` 的连续多个 4625 事件 —— 密码暴力破解 (brute-force) 的标志。 - 关联 4740 (lockout) + 此前的一系列 4625 事件 —— 以便区分 “用户忘记密码”与潜在攻击。 - 将排除列表(`service_accounts` 等)移至 Graylog Lookup Table 中,而不是使用内联查询 —— 随着列表的增长,更易于维护。 ## 安全说明 - Bot 的 Token 和 chat_id 仅保留在 Graylog 的 Notification 设置中, 绝不发布在代码库中。 - 公司真实的服务/测试登录列表已使用 占位符 `service_accounts` 进行泛化处理。
标签:Graylog, Terraform 安全, 告警通知, 系统运维