开源IDS网络流量分析与监控系统Zeek对接GrayLog
一、 开源IDS网络流量分析与监控系统Zeek简单介绍
The Zeek Network Security Monitor:A powerful framework for network traffic analysis and security monitoring.
Zeek网络安全监控:是一款强大的网络流量分析和安全监控的框架 。

- 1、深入分析:Zeek附带了许多协议的分析器,可实现在网络应用层的高级语义分析。
- 2、适应性强且灵活:Zeek的域特定脚本语言可实现特定于站点的监视策略,也意味着不限于任何特定检测方法。
- 3、高效性:Zeek以高性能网络为目标,并在很多各种大型站点上应用和运行。
- 4、高级状态性:Zeek保留有关其监控的网络应用层可扩展状态,并提供网络活动的高级存档功能。
官方文档
https://github.com/zeek/zeek
https://docs.zeek.org/
参考链接
https://blog.ossq.cn/2303.html
http://www.senlt.cn/article/171944181.html
https://blog.ossq.cn/2287.html
在阅读过《将 Zeek 与 ELK 栈集成》的这篇文章后 https://linux.cn/article-14770-1.html

决定尝试是否可以将zeek的网络流量监控日志吐到GrayLog,并在GrayLog上进行呈现
具体实现思路,以及要解决的问题汇总
- 1、zeek的部署(能否rpm包的方式部署,编译部署太耗费时间)
- 2、流量镜像问题:zeek服务器的网卡如何配置混杂模式,交换机流量镜像如何配置
- 3、zeek的流量分析日志读取问题:zeek的日志转成json格式日志,使用graylog-sidecar+filebeat方式读取,并json提取器获取字段信息
- 4、GrayLog上查询,Dashboard配置
具体实践过程如下
二、下载zeek的CentOS7的rpm包并部署zeek
https://zeek.org/get-zeek/
由于网速问题,我这边手动提前下载好zeek相关的rpm依赖包




1、安装zeek
yum localinstall *.rpm
2、将/opt/zeek/bin目录加到PATH环境变量中
echo "PATH=$PATH:/opt/zeek/bin" >> /etc/profile
source /etc/profile
echo $PATH
3、将网卡设置成混杂模式
ifconfig ens33 promisc
交换机配置镜像流量的操作这里就不做演示,请参考这个链接中的文章自行探索,根据自身实际网络环境自行解决
https://blog.ossq.cn/2287.html



4、vim node.cfg
cd /opt/zeek/etc
vim node.cfg
修改interface为当前实际网卡

5、vim local.zeek
cd /opt/zeek/share/zeek/site/
vim local.zeek
如下位置添加以下行:
@load policy/tuning/json-logs.zeek

6、启动zeek
zeekctl
[ZeekControl] > deploy

7、查看zeek的流量分析日志
cd /opt/zeek/logs/
cd current/
ll
目前均为json格式日志

三、部署graylog-sidecar+filebeat方式读取zeek的日志
1、下载并安装graylog-sidecar和filebeat的rpm包
https://github.com/Graylog2/collector-sidecar/releases
https://mirrors.cloud.tencent.com/elasticstack/7.x/yum/7.10.2/filebeat-7.10.2-x86_64.rpm
rpm -ivh filebeat-7.10.2-x86_64.rpm
rpm -ivh graylog-sidecar-1.3.0-1.x86_64.rpm


2、创建sidecar的token,及sidecar端的配置修改
vim /etc/graylog/sidecar/sidecar.yml
并修改如下5处的配置
server_url: "http://192.168.31.170:9000/api/"
server_api_token: "hkoa0tv9gl9u09drhtckjbdv90v98v5mor5jropo0p0741oib3g"
node_name: "zeek"
update_interval: 10
send_status: true


3、graylog-sidecar启动,并下发配置
graylog-sidecar -service install
graylog-sidecar -service start



4、Graylog上面配置Beat类型的Input

防火墙开放5044端口
firewall-cmd --permanent --zone=public --add-port=5044/tcp
firewall-cmd --reload
5、确认是否收到日志

四、Graylog上配置json格式字段提取并配置大屏






五、总结
1、本文中所用到的rpm安装包已全部打包,下载链接如下
链接:https://caiyun.139.com/m/i?165CkbChzt8CJ
提取码:yrBK
2、扩展
zeek流量日志如果可以的话,可以与微步API接口进行关联查询,这样可以实现异常DNS等其他流量检测与告警
参考之前的文章
GrayLog使用HTTP JSONPath方式调用微步在线云API识别威胁IP
