开源SOC实现(十二)-告警通知工具Praeco

admin 2024年3月19日15:47:10评论16 views字数 4312阅读14分22秒阅读模式

上一期说到在Wazuh中集成Sigma的相关规则,实现检测规则的快速导入,增强检测能力。接下来介绍告警通知工具,用于将检测到的告警快速通知到对应责任人。

Praeco介绍

开源SOC实现(十二)-告警通知工具Praeco

Praeco是一款告警通知工具,用于统计Elasticsearch或者OpenSearch中异常统计数据,并将对应的告警信息通过各种通讯方式发出,支持Slack, MS Teams, Email, Telegram, an HTTP POST/HTTP POST 2 endpoint等。

开源SOC实现(十二)-告警通知工具Praeco

Praeco工作逻辑

开源SOC实现(十二)-告警通知工具Praeco

Praeco中重要的组件:ElastAlert 2。

ElastAlert 2针对Elasticsearch或者OpenSearch(Wazuh使用OpenSearch)中异常数据(使用者配置查询语句)进行告警,如果您希望在您实时写入Elasticsearch或者OpenSearch中的数据匹配特定模式时收到告警,那么ElastAlert 2适合你。‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

大致工作逻辑如下:Praeco对Elasticsearch中数据进行查询,并返回对应结果,如果匹配到需要告警内容则进行告警。

开源SOC实现(十二)-告警通知工具Praeco

接下来安装Praeco并将其跟Wazuh进行联动对于异常统计数据进行告警。

安装Praeco

开源SOC实现(十二)-告警通知工具Praeco

开源SOC实现(十二)-告警通知工具Praeco
开源SOC实现(十二)-告警通知工具Praeco

Praeco仓库地址:https://github.com/johnsusek/praeco

由于Praeco需要容器化部署,通过docker进行搭建,所以需要在安装Praeco之前安装docker。

开源SOC实现(十二)-告警通知工具Praeco
开源SOC实现(十二)-告警通知工具Praeco

根据官方文档进行安装:https://docs.docker.com/engine/install/centos/

安装完成查看docker服务相关状态:

systemctl status docker

开源SOC实现(十二)-告警通知工具Praeco

接下来安装Praeco

git clone https://github.com/johnsusek/praeco.git

开源SOC实现(十二)-告警通知工具Praeco

cd praecomkdir -p rules rule_templateschmod -R 777 rules rule_templates

开源SOC实现(十二)-告警通知工具Praeco

接下来修改配置文件,需要注意修改下图中红色框中内容,偷懒直接使用admin账号,生产环境中需要为Praeco专门创建一个账号用于查询。

vi config/api.config.json

复制以下内容并进行修改

{  "appName": "elastalert-server",  "port": 3030,  "wsport": 3333,  "elastalertPath": "/opt/elastalert",  "verbose": false,  "es_debug": false,  "debug": false,  "rulesPath": {    "relative": true,    "path": "/rules"  },  "templatesPath": {    "relative": true,    "path": "/rule_templates"  },  "dataPath": {    "relative": true,    "path": "/server_data"  },  "es_host": "*WAZUH-INDEXER*",  "es_port": 9200,  "es_username""admin",  "es_password": "*YOUR_PASSWORD*",  "es_ssl": true,  "ea_verify_certs": false,  "opensearch_flg": true,  "writeback_index": "praeco_elastalert_status"}

开源SOC实现(十二)-告警通知工具Praeco

继续修改另一个配置文件

vi config/elastalert.yaml

复制以下内容并进行修改

# The elasticsearch hostname for metadata writeback# Note that every rule can have its own elasticsearch hostes_host: 192.168.116.201# The elasticsearch portes_port: 9200# This is the folder that contains the rule yaml files# Any .yaml file will be loaded as a rulerules_folder: rules# How often ElastAlert 2 will query elasticsearch# The unit can be anything from weeks to secondsrun_every:  seconds: 60# ElastAlert 2 will buffer results from the most recent# period of time, in case some log sources are not in real timebuffer_time:  minutes: 1# Optional URL prefix for elasticsearch#es_url_prefix: elasticsearch# Connect with TLS to elasticsearchuse_ssl: True# Verify TLS certificatesverify_certs: False# GET request with body is the default option for Elasticsearch.# If it fails for some reason, you can pass 'GET', 'POST' or 'source'.# See http://elasticsearch-py.readthedocs.io/en/master/connection.html?highlight=send_get_body_as#transport# for details#es_send_get_body_as: GET# Option basic-auth username and password for elasticsearches_username: admines_password: *YOUR_PASSWORD*# The index on es_host which is used for metadata storage# This can be a unmapped index, but it is recommended that you run# elastalert-create-index to set a mappingwriteback_index: praeco_elastalert_status# If an alert fails for some reason, ElastAlert will retry# sending the alert until this time period has elapsedalert_time_limit:  days: 2skip_invalid: True

开源SOC实现(十二)-告警通知工具Praeco

开源SOC实现(十二)-告警通知工具Praeco

最后配置环境变量

export PRAECO_ELASTICSEARCH=192.168.116.202

启动praeco

docker compose up -d

开源SOC实现(十二)-告警通知工具Praeco

开源SOC实现(十二)-告警通知工具Praeco

使用浏览器登录praeco

http://192.168.116.202:8080

开源SOC实现(十二)-告警通知工具Praeco

可以正常登录看到该页面代表部署完成。

使用以下命令查看Elasticsearch连接是否正常。

docker logs <3030端口容器对应的ID>例如:docker logs d725775a88cf

开源SOC实现(十二)-告警通知工具Praeco

配置Praeco告警规则

开源SOC实现(十二)-告警通知工具Praeco

点击Add rule创建新Rule

开源SOC实现(十二)-告警通知工具Praeco

Name为socalert,Index为被查询的Elasticsearch中索引的名称,可以通过Grafana查看如下图所示,由于索引最后的数字值会随着日志量增加而增加,所以使用通配符进行模糊匹配,时间注意选择UTC时间,我这里date_@timestamp代表UTC时间。

开源SOC实现(十二)-告警通知工具Praeco

配置完如下图所示

开源SOC实现(十二)-告警通知工具Praeco

接下来需要编辑告警条件语句

开源SOC实现(十二)-告警通知工具Praeco

既然要编辑告警语句,就要了解需要检测到什么行为或者日志后进行告警,比如以检测以下语句为例

SCHTASKS /CREATE /RU “NT AUTHORITYSYSTEM” /SC DAILY /TN “MyTasksNotepad task” /TR “C:WindowsSystem32notepad.exe” /ST 11:00

开源SOC实现(十二)-告警通知工具Praeco

通过Graylog查看生成的日志

开源SOC实现(十二)-告警通知工具Praeco

点击Praeco告警语句编辑页面的UNFILTERED

开源SOC实现(十二)-告警通知工具Praeco

Builder引导你输入告警条件,类似新手模式,Manual类似专家模式,输入以下语句

(data_win_eventdata_parentImage:(*\powershell.exe) AND data_win_eventdata_commandLine:(*SCHTASKS*/CREATE*/RU*)

开源SOC实现(十二)-告警通知工具Praeco

输入完点击Close,返回上级页面,接下来配置告警通知方式

开源SOC实现(十二)-告警通知工具Praeco

同一告警重复通知次数选择0,告警通知方式选择Telegram

开源SOC实现(十二)-告警通知工具Praeco

配置通知消息模板后,配置Telegram相关参数

开源SOC实现(十二)-告警通知工具Praeco

配置使用Telegram进行告警通知

开源SOC实现(十二)-告警通知工具Praeco
开源SOC实现(十二)-告警通知工具Praeco

根据官方文档进行配置:https://elastalert2.readthedocs.io/en/latest/ruletypes.html#telegram

开源SOC实现(十二)-告警通知工具Praeco

根据官方文档了解到需要两个参数,分别是:

telegram_bot_token: "bot_token"
telegram_room_id: "chat_id"

打开软件,找到BotFather这个账号,对话如下获取HTTP API开源SOC实现(十二)-告警通知工具Praeco

接下来寻找telegram_room_id

根据搜索引擎查找到对应方法:

https://stackoverflow.com/questions/32423837/telegram-bot-how-to-get-a-group-chat-id

开源SOC实现(十二)-告警通知工具Praeco

https://api.telegram.org/bot1234567890:xxxxxxxxxxxxxxxxxxxx/getUpdates

开源SOC实现(十二)-告警通知工具Praeco

配置完成后,点击Test测试告警发送。

开源SOC实现(十二)-告警通知工具Praeco

测试通过后点击Save即可在首页看到刚才添加的Rule

开源SOC实现(十二)-告警通知工具Praeco

对应告警推送工具Praeco写的较为简单,由于同类的工具较为丰富,就不做详细阐述,欢迎订阅收看开源SOC实现(十三)-事件响应平台IRIS

精彩预告:后面为大家准备了情报联动以及自定义编排等内容,别走开

原文始发于微信公众号(Kali渗透测试教程):开源SOC实现(十二)-告警通知工具Praeco

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年3月19日15:47:10
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   开源SOC实现(十二)-告警通知工具Praecohttp://cn-sec.com/archives/2581210.html

发表评论

匿名网友 填写信息