给力! 10万用户级别账户数据追踪 99%准确率助力- Windows 日志收集转发介绍

it2023-09-22  69

运维世界常常需要从海量数据中删选出所需的信息轨迹并进行技术分析. 在企业环境, 特别是用户行为相关数据追述, 技术上尤其难. 要做到99%以上的准确性以及平台化建设, 更是难上加难.  设想一下, 10万级别用户, 每天的账户锁定需要在1分钟内自动通知以及给出用户准确的锁定来源提示, 这个方案你会怎么做 ?

商业和开源方案有一些但都不完整, 需要管理者做自定义开发扩展. 在试用了Kafka + Logstash + ElasticSearch + Kibana的方案一段时间之后, 我们发现开源平台数据丢失问题比较明显.  在用户级别细颗粒度的数据分析中,准确率打到97%左右很难再提升.  为提升准确率到99%以上以确保可用性和用户体验, 我们对于方案做了进一步的完善.  WEC – Windows Eventlog Collector (Windows 日志收集) 就是其中一部分, 用来补全用户认证/登录等特殊信息的删选和收集; 今天主要介绍WEC和其配置, 以飨读者;

目标 – 收集所有域控的用户验证/登录日志信息, 汇总到数据库;  用这些信息作为校验信息来复核账户锁定信息. 收集的手段即WEC.

原因 – 基于Windows Active Directory 的用户验证/登录可以通过高级审核策略留下详细信息 <账户登录, 登录/注销>. 这些信息可以帮助分析账户活动以及锁定;

成果 – 通过WEC 日志校验, 成功将信息准确率从97% 提升至 99%以上.

配置步骤 –

注 : 我们略过配置域策略开启高级审核<账户登录, 登录/注销>. 配置完成后刷新域控策略信息 gpresult.exe /H report.html 查看确认策略已经生效;

简介:WEC 或者 WEF <Windows Eventlog Forwarding> 是Windows 2012 R2及更高版本自带的服务<再老的版本我们不做涉及>, 允许event从多个Windows 服务器汇聚到收集服务器 <collector>. 该服务包含两个角色: Collector, 用于收集日志; Forwarder, 用于转发日志;  将两者连起来的是日志订阅.  Collector 可通过订阅来定义收集哪些服务器上的哪些日志.

配置步骤:

1.      首先定位一台服务器为Collector角色, 该服务器用来接收所有其他服务器的日志信息; 在Collector上开启WinRM 以及 Windows Event Collector 服务:

Winrm qc

点击订阅确认即可开启Windows Event Collector 服务, 也可在Services.msc 管理界面启动Windows Event Collector 服务

 

2.      为Forwarders 创建 GPO, 让他们知道向谁转发日志信息. 假如我们只需要域控上的安全日志信息, 我们可以为域控建立一个新的GPO, 然后定义事件转发配置:

Computer Configuration\Policies\Administrative Templates\Windows Components\Event Forwarding\Configure target subscription manager

格式例如 : Server=http://<FQDN of the collector>:5985/wsman/SubscriptionManager/WEC,Refresh=60

 

3.      为Forwarder Network Service赋予安全日志读取权限<默认只有Administrators 有安全日志权限>: 配置同一个GPO的以下两个设置:

Computer Configuration\Policies\Administrative Templates\Windows Components\Event Log Service\Security\Configure Log Access

Computer Configuration\Policies\Administrative Templates\Windows Components\Event Log Service\Security\Configure Log Access(legacy)

将其配置为  O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x5;;;BA)(A;;0x1;;;S-1-5-32-573)(A;;0x1;;;NS)

((A;;0x1;;;NS)即意为允许Network Service Read Access, (A;;0x1;;;S-1-5-32-573)在这儿是Event Log Reader组Read Access)

编码含义可参考:

O:BA Object owner is Built-in Admin (BA).

G:SY Primary group is System (SY).

D: This is a DACL, rather than an audit entry or SACL.

(D;;0xf0007;;;AN) Deny Anonymous (AN) all access.

(D;;0xf0007;;;BG) Deny Built-in Guests (BG) all access.

(A;;0xf0005;;;SY) Allow System Read and Clear, including DELETE, READ_CONTROL,WRITE_DAC, and WRITE_OWNER (indicated by the 0xf0000).

(A;;0x7;;;BA) Allow Built-in Admin READ, WRITE and CLEAR.

(A;;0x7;;;SO) Allow Server Operators READ, WRITE and CLEAR.

(A;;0x3;;;IU) Allow Interactive Users READ and WRITE.

(A;;0x3;;;SU) Allow Service accounts READ and WRITE.

(A;;0x3;;;S-1-5-3) Allow Batch accounts (S-1-5-3) READ and WRITE.

The specific event log access mask bits are:

0x0001 ELF_LOGFILE_READ Permission to read log files.

0x0002 ELF_LOGFILE_WRITE Permission to write log files.

 

4.      在Collector上配置订阅. 当前理论上Forwarders已经知道向谁转发, 我们需要通过订阅来定义哪些服务器转发哪些日志:

创建订阅:

订阅名称 – 用于区分不同订阅

目标日志 – 将转发的日志存到collector的哪个日志里

订阅类型和源计算机 – 这里我们选择 “源计算机已启动” , 我们配置了Domain Controllers 计算机组, 来动态实现所有域控自动转发;

要收集的事件 – 定义你所需要的事件, 有细颗粒度的设置, 比如事件日志类型, 日志ID 比如 4625, 4740, 事件关键字等;

高级设置 – 配置事件传递优化和协议端口, 默认采用HTTP 5985;

 

 

5.      确保Collector 服务器 URLACL 正确: 如果WinRM服务没有侦听5985/5986, 事件转发将会失败. 典型的症状是 日志105 会在Forwarder 生成 :

Event ID 105 with error 2150859027 with full message "The forwarder is having a problem communicating with subscription manager at address http://COLLECTOR:5985/wsman/SubscriptionManager/WEC. Error code is 2150859027 and Error Message is xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859027" Machine="FORWARDER"> The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is usually returned by a HTTP server that does not support the WS-Management protocol.

在Collector 上运行以下命令:

netsh http show urlacl

netsh http delete urlacl url=http://+:5985/wsman/

netsh http add urlacl url=http://+:5985/wsman/ sddl=D:(A;;GX;;;S-1-5-80-569256582-2953403351-2909559716-1301513147-412116970)(A;;GX;;;S-1-5-80-4059739203-877974739-1245631912-527174227-2996563517)

6.      复核日志转发正常发生

a.      在Forwarders上面, 查看EventLog\应用程序和服务日志\Microsoft\Windows\Eventlog-ForwardingPlugin, 上面有100日志表明与Collector 连接同步成功;

b.     在Collector上面, 查看目标日志, 确认日志已经转发过来; 到此配置成功;

 

到这为止, 你的Collector上面将会有所有需要的日志, 接下来你要做的就是如何消费这些日志并在业务逻辑中去使用.  比如4625 / 4771 等事件用来校验用户登录验证的信息;

有用的链接:  以下文章在我配置排查WEC/WEF 的时候提供了很好的帮助, 一并分享给大家:

 

Eventlog-ForwardingPlugin Event ID 102 Error 5004 - subscription can not be created

https://support.logbinder.com/SuperchargerKB/50225/EventlogForwardingPlugin-Event-ID-102-Error-5004-subscription-can-not-be-created

Events are not forwarded if the collector is running Windows Server

https://docs.microsoft.com/en-us/troubleshoot/windows-server/admin-development/events-not-forwarded-by-windows-server-collector

3. Troubleshooting a Problem Forwarder

https://support.logbinder.com/SuperchargerKB/50119/3-Troubleshooting-a-Problem-Forwarder

4. Granting Permissions for Security Log Forwarding

https://support.logbinder.com/SuperchargerKB/50120/4-Granting-Permissions-for-Security-Log-Forwarding

All subscriptions have 0 active forwarders; System Event IDs 10128, 10129

https://support.logbinder.com/SuperchargerKB/50145/All-subscriptions-have-0-active-forwarders-System-Event-IDs-10128-10129

WEC won't forward events to self if WinRM GPO doesn't include IPv6 filter

https://github.com/palantir/windows-event-forwarding/issues/37

有问题欢迎随时交流

 

最新回复(0)