Chinaunix
标题:
EasyIDS snort with 2 sensors
[打印本页]
作者:
ac57
时间:
2008-11-28 16:20
标题:
EasyIDS snort with 2 sensors
在网上找到一个开源的IDS集成——easyids,它把 CentOS(4.6),snort,base,ntop,web界面管理等都自动集和在一起,如果只有单独一个网络要监听,从它网站下载ISO,自动装上,配下管理用的网卡就能使了,还可以通过 Web 编辑 rules 很方便。 它的网站是
http://www.skynet-solutions.net/easyids/
大家感兴趣的可以先看看。
我的试验情况就不同了,我监听了两个网段,需要两个sensor,所以我在它的基础上做了些修改,需要监听多网段的朋友也可以交流下。
网卡的配置就不说了。
首先关闭 snort 和 barnyard服务,休改init.d下的 snort 服务脚本,
它源文件是
#!/bin/sh
#
# chkconfig: 2345 99 82
# description: Starts and stops the snort intrusion detection system
#
# config: /etc/snort/snort.conf
# processname: snort
# Source function library
. /etc/rc.d/init.d/functions
BASE=snort
DAEMON="-D"
INTERFACE="-i eth1"
CONF="/etc/snort/snort.conf"
USER="-u snort -g snort"
# Check that $BASE exists.
[ -f /usr/local/bin/$BASE ] || exit 0
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
RETVAL=0
# See how we were called.
case "$1" in
start)
if [ -n "`/sbin/pidof $BASE`" ]; then
echo -n $"$BASE: already running"
echo ""
exit $RETVAL
fi
echo -n "Starting snort service: "
/usr/local/bin/$BASE $INTERFACE $USER -c $CONF $DAEMON
sleep 1
action "" /sbin/pidof $BASE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/snort
;;
stop)
echo -n "Shutting down snort service: "
killproc $BASE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snort
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
status)
status $BASE
RETVAL=$?
;;
*)
echo "Usage: snort {start|stop|restart|reload|status}"
exit 1
esac
exit $RETVAL
我的修改
#!/bin/sh
。。。。。。
INTERFACE1="-i eth1"
INTERFACE2="-i eth2"
。。。。。。
start)
。。。。。
/usr/local/bin/$BASE $INTERFACE1 $USER -c $CONF -l /var/log/snort/eth1/ $DAEMON
/usr/local/bin/$BASE $INTERFACE2 $USER -c $CONF -l /var/log/snort/eth2/ $DAEMON
。。。。。
当然要在 /var/log/snort/下建 eth1、eth2目录,所有者改为 snort ,这样 分别把snort监听两个网卡输出的log分离便于barnyard处理,还可以修改CONF为两个不同路径的snort.conf,这样修改相应的snort.conf,两个网段可以采不同的rules
其次是barnyard
源文件是
#!/bin/sh
#
# chkconfig: 2345 99 82
# description: Starts and stops the barnyard fast output system
#
# config: /etc/snort/barnyard.conf
# processname: barnyard
# Source function library
. /etc/rc.d/init.d/functions
BASE=barnyard
DAEMON="-D"
GENMAP="/etc/snort/gen-msg.map"
SIDMAP="/etc/snort/sid-msg.map"
WALDO="/etc/snort/bylog.waldo"
CONF="/etc/snort/barnyard.conf"
LOGDIR="/var/log/snort"
LOGFILE="snort.log"
# Check that $BASE exists.
[ -f /usr/local/bin/$BASE ] || exit 0
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
RETVAL=0
# See how we were called.
case "$1" in
start)
if [ -n "`/sbin/pidof $BASE`" ]; then
echo -n $"$BASE: already running"
echo ""
exit $RETVAL
fi
echo -n "Starting barnyard service: "
/usr/local/bin/$BASE -c $CONF -g $GENMAP -s $SIDMAP -d $LOGDIR -f $LOGFILE -w $WALDO $DAEMON
sleep 1
action "" /sbin/pidof $BASE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/barnyard
;;
stop)
echo -n "Shutting down barnyard service: "
killproc $BASE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/barnyard
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
status)
status $BASE
RETVAL=$?
;;
*)
echo "Usage: barnyard {start|stop|restart|reload|status}"
exit 1
esac
exit $RETVAL
我的修改
#!/bin/sh
。。。。。。
WALDO1="/etc/snort/eth1/bylog.waldo"
WALDO2="/etc/snort/eth2/bylog.waldo"
CONF1="/etc/snort/eth1/barnyard.conf"
CONF2="/etc/snort/eth2/barnyard.conf"
LOGDIR1="/var/log/snort/eth1"
LOGDIR2="/var/log/snort/eth2"
。。。。。。
start)
。。。。。
/usr/local/bin/$BASE -X /var/run/by_eth1.pid -c $CONF1 -g $GENMAP -s $SIDMAP -d $LOGDIR1 -f $LOGFILE -w $WALDO1 $DAEMON
/usr/local/bin/$BASE -X /var/run/by_eth2.pid -c $CONF2 -g $GENMAP -s $SIDMAP -d $LOGDIR2 -f $LOGFILE -w $WALDO2 $DAEMON
。。。。。
因为barnyard.conf 中只能设唯一的Interface作为 Sensor, 我在/etc/snort/ 下建 eth1、eth2,copy barnyard.conf和bylog.waldo到里面,修改eth1的barnyard.conf, config interface: eth1和output alert_acid_db: mysql, sensor_id 1,修改eth2中的barnyard.conf,config interface: eth2和output alert_acid_db: mysql, sensor_id 2,还要修改两个bylog.walo,我们先执行 snort -i eth1 -u snort -g snort -c /var/snort/snort.conf -l /var/log/snort/eth1/ -v ,ctrl + C 结束,在执行 snort -i eth2 -u snort -g snort -c /var/snort/snort.conf -l /var/log/snort/eth2/ -v ,ctrl + C 结束。
会在 /var/log/snort/eth1 和 /var/log/snort/eth2 下生成 如 snort.log.1227597433的文件,那eth1的bylog.walo为
/var/log/snort/eth1
snort.log
1227597433
0
eth2的bylog.walo修改类似。
重新启动 snort 和 barnyard 服务,这样snort 就可以监听两个sensor, 更多sensor 修改类似,多加几个 interface 而已,不过好像最多能监控4个 sensor,如果超过四个,我建议把几个监听网卡做 bonding 。
作者:
hojo2000
时间:
2010-05-28 17:08
多谢兄弟指点,刚刚玩玩这个
作者:
洋服一次
时间:
2010-05-28 20:43
提示:
作者被禁止或删除 内容自动屏蔽
作者:
qingchn
时间:
2010-06-03 17:10
最近在研究snort 顺便看下
作者:
雨桐木
时间:
2010-06-03 18:28
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2