这是ELK入门到实践系列的第三篇文章,分享如何使用ELK分析Windows事件日志。

Windows系统日志是记录系统中硬件、软件和系统问题的信息,同时还可以监视系统中发生的事件。用户可以通过它来检查错误发生的原因,或者寻找受到攻击时攻击者留下的痕迹。

在本文,通过ELK 安全分析的视角,我们将能够检测异常的登录行为和不常见的可疑进程。


Winlogbeat

使用Winlogbeat将Windows事件日志流传输到Elasticsearch。Winlogbeat 通过标准的 windows API 获取 windows 系统日志,常见的有 Application,Security 、System三个核心日志文件。winlogbeat 配置如下:

步骤一:安装Winlogbeat

1、下载并解压缩Winlogbeat

下载地址:https://artifacts.elastic.co/downloads/beats/winlogbeat/winlogbeat-7.4.2-windows-x86_64.zip
下载地址:https://artifacts.elastic.co/downloads/beats/winlogbeat/winlogbeat-7.4.2-windows-x86_64.zip

使用ELK分析Windows事件日志_Windows

2、安装Winlogbeat服务

以管理员身份打开PowerShell,在PowerShell提示符下,运行以下命令以安装服务。

cd "C:\Program Files(x86)\Winlogbeat".\install-service-winlogbeat.ps1
cd "C:\Program Files(x86)\Winlogbeat"
.\install-service-winlogbeat.ps1

如果在系统上禁用了脚本执行,则需要为当前会话设置执行策略以允许脚本运行。例如:

PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-winlogbeat.ps1。
PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-winlogbeat.ps1。

使用ELK分析Windows事件日志_Windows_02

步骤二:配置Winlogbeat

修改 C:\Program Files\Winlogbeat\winlogbeat.yml 以设置连接信息:

#-------------------------- Elasticsearch output ------------------------------output.elasticsearch:  # Array of hosts to connect to.  hosts: ["localhost:9200"]
  # Optional protocol and basic auth credentials.  #protocol: "https"  #username: "elastic"  #password: "changeme"
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["localhost:9200"]


  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"

填写要输出到es的地址,保存配置文件后,使用以下命令检查配置文件的正确性:

winlogbeat.exe test config -winlogbeat.yml -e
winlogbeat.exe test config -winlogbeat.yml -e

步骤三:启动 Winlogbeat

使用以下命令启动Winlogbeat服务

Start-Service winlogbeat
Start-Service winlogbeat

使用以下命令停止Winlogbeat服务:

Stop-Service winlogbeat
Stop-Service winlogbeat

安装部署ES

1、安装

yum -y install elasticsearch
yum -y install elasticsearch

2、配置

cd /etc/elasticsearch/vi  elasticsearch.yml      network.host: 0.0.0.0    http.port: 9200
cd /etc/elasticsearch/
vi  elasticsearch.yml    
  network.host: 0.0.0.0
    http.port: 9200

3、启动ES

/bin/systemctl daemon-reloadsystemctl start elasticsearch
/bin/systemctl daemon-reloadsystemctl start elasticsearch

基于ELK的SIEM

Kibana中的SIEM应用程序为安全分析提供了一个交互式工作区,可以分析主机相关和网络相关的安全事件。

创建索引,在SIEM界面,可以查到通过Winlogbeat从Windows事件日志提取主机事件。

使用ELK分析Windows事件日志_Elastic_03

点击查看主机,在主机界面,可以查看安全分析得到的结果,共包含五部分信息。

第一部分,接入日志的主机数量,用户身份验证情况,用户访问IP等汇总信息。

使用ELK分析Windows事件日志_elasticsearch_04

第二部分,接入日志的所有主机,包含主机名、最后看到事件、OS类型及版本。

使用ELK分析Windows事件日志_elasticsearch_05

第三部分,显示登录成功和失败的用户名、次数、登录时间等信息。

使用ELK分析Windows事件日志_Windows_06

第四部分,显示不常见的进行,包含进程名,主机数目,命令及用户等信息。

使用ELK分析Windows事件日志_Elastic_07

第五部分,显示所有的安全事件,包含时间戳、主机名、日志类型、用户、源、消息等信息。

使用ELK分析Windows事件日志_elasticsearch_08

结语

在本文,基于Elastic Stack的SIEM,展现了强大的安全事件分析的能力,通过Winlogbeat收集Windows事件日志,以Elasticsearch的速度进行安全分析,使用Kibana中的SIEM应用程序浏览安全数据,以快速检测和响应安全事件。

当然,不只是Windows事件日志,借助Beats可以从任何你想要的地方提取数据,如审核事件、认证日志、DNS流量、网络流等。这只是初步的探索,如何更好的使用Elastic SIEM去发现并解决安全问题,才是我们接下来要深究的方向。在学习,也一直在路上,加油!