linux – 如何在snort警报上运行shell脚本?

linux – 如何在snort警报上运行shell脚本?,第1张

概述我有snort听cisco交换机的SPAN端口.我希望能够在我的网络服务器上添加iptables DROP规则以获取特定的snort警报,但很难找到确切的方法.我希望阻止实时发生,而不是通过cron启动脚本来定期搜索snort日志. 我在Seclists上找到了一个example,它使用syslog-ng来运行shell脚本,但它必须是旧版本的syslog-ng,因为我在重新启动syslog-ng 我有snort听cisco交换机的SPAN端口.我希望能够在我的网络服务器上添加iptables DROP规则以获取特定的snort警报,但很难找到确切的方法.我希望阻止实时发生,而不是通过cron启动脚本来定期搜索snort日志.

我在SecLists上找到了一个example,它使用syslog-ng来运行shell脚本,但它必须是旧版本的syslog-ng,因为我在重新启动syslog-ng时遇到了关于语句被弃用的错误.

我对syslog-ng过滤器了解不多,所以要对它进行更多的研究,因为它看起来很有希望,但我想在这里提出一个问题,以防有更好的方法.当snort警报通过我的snort盒的SPAN端口时,运行shell脚本的好方法是什么?

解决方法 我已经拼凑了足够的文档来获得一些有用的东西.该解决方案涉及告诉snort登录syslog,然后设置syslog-ng以触发snort syslog流量以运行给定的shellcript.将snort假脱机到磁盘或运行脚本不适合高流量负载,因此请注意.如果您将snort配置为仅警告某些流量以降低负载,那么您应该没问题.设置和调试syslog-ng可能是一个皮塔饼,所以我已经包含了必要的位来实现这一点.只需将它们添加到syslog-ng.conf的底部即可.希望它可以帮助别人.作为注释,syslog由于某种原因记录了每个消息的3个副本.不知道为什么.

我在这里使用了一些信息:http://www.mad-hacking.net/documentation/linux/reliability/logging/email-notification.xml

/etc/snort/snort.conf - configure snort to log to syslog------------------------------------------------------------# syslogoutput alert_syslog: LOG_LOCAL6 LOG_ALERT/etc/syslog/syslog-ng.conf  - setup filters/destinations for alerts------------------------------------------------------------# snort filter - this only pays attention to syslog messages sent by the 'snort' programfilter f_snort{  facility(local6) and match("snort" value ("PROGRAM"));                                                };# optionally,this would send the snort message to a remote host running a syslog Listener.# I was running tcpdump to deBUG the whole setup so I use UDP protocol here so the# message is just blasted out over the ether without needing to actually have a syslog# Listener setup anywheredestination d_net{  udp("10.10.10.1" port(514) log_fifo_size(1000) template(t_snort));   };# this one sends the syslog message consisting of priority,time_in_seconds,host and syslog meesage.# destination d_prog{  program("/root/bin/snort_script" template("<$PRI>$UNIXTIME $HOST $MSGONLY\n") );};# ..or use a pipe if you don't want syslog running scriptsdestination d_prog_pipe{  pipe("/root/bin/syslog-pipe" template("<$PRI>$DATE $HOST $MSGONLY\n") );};# finally,log the message out the snort parsing mechanismlog{   source(s_src);   filter(f_snort);   destination(d_prog);   #destination(d_net); };/root/bin/snort_script------------------------------------------------------------#!/bin/bashwhile read line; do   echo "$line" >> /tmp/snort.logdone
总结

以上是内存溢出为你收集整理的linux – 如何在snort警报上运行shell脚本?全部内容,希望文章能够帮你解决linux – 如何在snort警报上运行shell脚本?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1034039.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存