Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了linux – 如何在snort警报上运行shell脚本?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

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

大佬总结

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

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。