Winlogbeat 是 Windows 事件日志的轻量级数据发送器。 虽然 Elastic 群集通常用于实时监视,但是可以对 Winlogbeat 进行调整,以手动将“冷日志”或旧的非活动 Windows 事件日志(EVTX)手动发送给 Elastic Stack。 该功能使分析人员可以从收集的系统图像中提取 EVTX文 件,并利用 Elastic 堆栈的功能进行调查。
我们可以在 Windows 环境下,打开 Event Viewer:

打开 Event Viewer 后,我们可以看到各种不同范围的日志:

我们甚至可以看到更多的应用程序的日志:

我们可以通过如下的命令来得到多少中日志:
Get-WinEvent -ListLog * | Measure-Object -Line
我们可以通过如下的命令来得到哪些是 Elastic 所关心的和安全相关的日志文件:
Get-WinEvent -ListLog * | ?{ $_.LogName -match "(PowerShell|WMI|Sysmon)" }

在上面,我们尝试得到 Powershell,WMI 及 Sysmon 的日志名字。这个在我们下面的配置中使用。
这为使用 Elastic Stack 作为 DFIR 分析人员的事后调查工具打开了大门,而不仅仅是实时分析。 该帖子介绍了参与此过程的可能方法。
你需要准备的
- 运行正常的 Elastic 堆栈(不需要 Logstash)
- 单节点或多节点均可接受。对于还没有安装 Elasticsearch 及 Kibana 的开发者来说,请参阅文章 “Elastic:菜鸟上手指南”。
- Ubuntu, MacOS 或 CentOS 作为你的 Elastic Stack Node OS
- Windows 主机从以下位置发送 EVTX 日志文件
- Winlogbeat 数据发送器
它是如何工作的
Winlogbeat 是由 Elastic 创建的数据传送器,用于在发生时将“热”或实时 EVTX 文件发送到Elastic堆栈。 这样就可以基于记录的实时事件实时监视系统。 对于数字取证调查员来说,这些数据通常从不热,而从冷的角度出发-是从在特定时间点锁定的系统的图像中收集的。
对于所有设置和配置,Winlogbeat 均使用默认配置文件 “winlogbeat.yml” 运行。 该程序通常还作为服务在主机上运行,在创建时抓取 EVTX 数据时在后台运行。
下载 Winlogbeat
我们在我们的 Windows 机器里下载 Winlogbeat。下载地址为:
Download Link: Download Winlogbeat | Ship Windows Event Logs | Elastic | Elastic
我们可以根据自己的版本(和 Elasticsearch 一样的版本)来进行下载。下载后,解压缩内容并将生成的 Winlogbeat 文件夹放置在系统上你认为合适的任何位置。比如针对我的设置,我解压到如下的目录:

我们可以从上面看出来有一个叫作 winlogbeat.yaml 的配置文件。在下面的章节里我们将用到。
配置 Winlogbeat
在做这一步之前,我们首先把我们的 Elasticsearch 及 Kibana 安装好,并运行起来
配置 Winlogbeat 也是非常简单的。在解压缩的 Winlogbeat 文件夹中,你应该看到一个标有 “winlogbeat.yml” 的文件-这是该服务的默认配置。 如果以前没有在 Elastic 群集中使用Winlogbeat,请继续执行以下步骤。 如果你已在 Elastic 群集中使用 Winlogbeat,请随时保留 “winlogbeat.yml” 并跳过这些步骤。
在你喜欢的文本编辑器中打开 “winlogbeat.yml”。 向下滚动到 “output” 部分,然后修改 “hosts” 选项以类似于你的 Elasticsearch 实例的 IP。 对于单节点集群,Elasticsearch 与其余 Elastic 进程位于同一节点上。
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["192.168.0.100:9200"]
上面是我的配置,这是因为我把我的 Elasticsearch 置于和 Windows 同样的机器中。在实际的使用中,你需要使用自己的IP地址来代替上面的 192.168.0.100。同时为了能够在 Kibana 中使用默认的 Dashboard,我们也同时必须配置 Kibana 的地址:
setup.kibana:
# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
host: "192.168.0.100:5601"
同样地,我把我的 Kibana 置于和 Windows 在一起的机器中。在实际的使用中,这个地址需要根据自己的设置来调整。
在上面,我们看到关于 Pwershell,WMI 及 Sysmon 的日志文件,我们可以通过如下的方式来进行配置。打开 winlogbeat.yml 文件,并寻找如下的配置:
winlogbeat.event_logs:
- name: Application
- name: Microsoft-Windows-PowerShell/Operational
- name: Windows PowerShell
- name: Microsoft-Windows-WMI-Activity/Operational
- name: Microsoft-Windows-PowerShell-DesiredStateConfiguration-FileDownloadManager/Operational
- name: Microsoft-Windows-PowerShell/Admin
ignore_older: 72h
- name: System
- name: Security
processors:
- script:
lang: javascript
id: security
file: ${path.home}/module/security/config/winlogbeat-security.js
- name: Microsoft-Windows-Sysmon/Operational
processors:
- script:
lang: javascript
id: sysmon
file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js
完成后,保存文件,然后在主机上以管理员身份打开 PowerShell 窗口。 我们想要将必要的 Winlogbeat 模板上载到 Elastic 栈中,以进行正确的解析。 在此窗口中,导航到Winlogbeat 文件夹并运行以下命令:
.\winlogbeat.exe setup -e

上面显示:Kibana 已经成功地装载了相应的 template。
运行 Winlogbeat
接下来的一步就非常简单了。我们可以在PowerShell中打入如下的命令:
.\winlogbeat.exe -e -c winlogbeat.yml

我们可以看到一件有许多的事件被成功发布到 Elasticsearch 中了。
在 Kibana 中查看数据
这个时候,我们可以打开 Kibana。点击 Discover,这时我们可以看到:

我们可以看到一个以 Winlogbeat 我开头的索引。这个索引实际上就是我们刚才在 Windows 下运行 winlogbeat.exe 所生成的索引。
在之前我们已经对 Kibana 的 dashboard 进行了配置,那么我们现在直接点击 Dashboard,并选择 Winlogbeat Dashboard ECS:

我们可以看到如下的界面:

如果你没有看到数据,请选择右上角的时间范围。在上面显示有3个事件。如果我们接着向下翻动,我们可以看到:

显示有3个警告。
如果我们把时间弄的更长一些,会有更多的数据:

参考:
【1】Manually upload EVTX log files to ELK with Winlogbeat and PowerShell – Burnham Forensics

本文介绍如何使用Winlogbeat手动上传EVTX日志文件至ElasticStack,实现冷日志的分析,包括配置、运行Winlogbeat及在Kibana中查看数据。
1935





