I have snort listening to the SPAN port of a cisco switch. I'd like to be able to add an iptables DROP rule on my webserver for specific snort alerts but having a hard time finding out exactly how to do that. I'd like the blocking to happen in real-time rather than launching a script through cron to periodically trawl the snort logs.
I found an example on Seclists which uses syslog-ng to run a shell script but it must be for an older version of syslog-ng as I get an error about the syntax being deprecated when I restart syslog-ng.
I don't know a lot about syslog-ng filters, so going to do more research on that as it looks promising but thought I would pose the question here in case there is a better way of doing it. What's a good way to run a shell script when a snort alert comes over the SPAN port of my snort box?
I've pieced together enough documentation to get something working. The solution involves telling snort to log to syslog, and then setting up syslog-ng to trigger on the snort syslog traffic to run the given shellscript. Having snort spooling to disk, or running scripts, isn't ideal for high traffic loads so be advised. If you configure snort to only alert on certain traffic to keep the load down, you should be fine. Setting up and debugging syslog-ng can be a pita so I've included the neccesary bits to get that working. Just add them to the bottom of syslog-ng.conf. Hope it helps someone else. As a note, syslog is logging 3 copies of each message for some reason. No idea why.
I used some of the info here: http://www.mad-hacking.net/documentation/linux/reliability/logging/email-notification.xml