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

我有snort监听思科交换机的SPAN端口。 我希望能够在我的networking服务器上添加一个iptables DROP规则来针对特定的snort警报,但是很难find如何做到这一点。 我希望阻止实时发生,而不是通过cron启动脚本来周期性地拖动snort日志。

我在Seclists上find了一个例子 ,它使用syslog-ng来运行一个shell脚本,但是它必须是一个早期版本的syslog-ng,因为当我重新启动syslog-ng时,我得到了一个关于不赞成使用的语法的错误。

我对syslog-ngfilter知之甚less,所以我们会对此做更多的研究,因为它看起来很有希望,但是我认为如果有更好的方法,我会提出这个问题。 当Snort警报通过我的snort盒子的SPAN端口时,运行shell脚本的好方法是什么?

我已经拼凑出足够的文档来完成某些工作。 解决scheme包括告诉snortloginsyslog,然后设置syslog-ng来触发snort syslogstream量来运行给定的shell脚本。 有snort后台打印到磁盘,或运行脚本,是不理想的高stream量负载,所以build议。 如果您将snortconfiguration为仅在某些stream量上发出警报以减less负载,则应该没问题。 设置和debuggingsyslog-ng可以是一个皮塔,所以我已经包含了一些必要的工作。 只需将它们添加到syslog-ng.conf的底部。 希望它可以帮助别人。 注意,系统日志由于某种原因正在logging每个消息的3个副本。 不知道为什么。

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

/etc/snort/snort.conf - configure snort to log to syslog ------------------------------------------------------------ # syslog output 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' program filter 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 anywhere destination 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 scripts destination d_prog_pipe { pipe("/root/bin/syslog-pipe" template("<$PRI>$DATE $HOST $MSGONLY\n") ); }; # finally, log the message out the snort parsing mechanism log { source(s_src); filter(f_snort); destination(d_prog); #destination(d_net); }; /root/bin/snort_script ------------------------------------------------------------ #!/bin/bash while read line; do echo "$line" >> /tmp/snort.log done