我有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 ------------------------------------------------------------ # 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