推荐一个入侵测系统+主动防火墙-->Snort+Guardian
推荐大家使用一个入侵测系统+主动防火墙-->;Snort+Guardian
--------------------------------------------------------------------------------
Snort 是一个开源的轻量级入侵监测系统,可以监测网络上的异常情况,给出报告;
Guardian是基于Snort+IPTables的一个主动防火墙,它分析Snort的日志文件,根据一定的判据自动将某些恶意的IP自动加入IPTables的输入链,将其数据报丢弃。
我自使用Snort+Guardian以来,每天可以看到很多的恶意行为被终止,心里很是高兴!
推荐大家使用!
安装步骤:
1)安装Snort:
*现在Snort & Guardian,目前下载地址为:
http://www.snort.org/dl/snort-2.3.0RC2.tar.gz
http://www.snort.org/dl/contrib/ ... guardian-1.6.tar.gz
*将上述文件拷贝至/tmp
*tar zxvf *.tgz
*cd snort-2.3.0RC2
*./configure
*make
*make install
*mkdir /etc/snort
*cd /etc/snort
*wget http://www.snort.org/dl/rules/snortrules-snapshot-CURRENT.tar.gz
* tar zxvf snortrules-snapshot-CURRENT.tar.gz
*mkdir /var/log/snort
*cd /etc
*vi snort.conf
修改后一些关键设置如下:
var HOME_NET yournetwork
var RULE_PATH /etc/snort/rules
preprocessor http_inspect: global \
iis_unicode_map /etc/snort/rules/unicode.map 1252
include /etc/snort/rules/reference.config
include /etc/snort/rules/classification.config
如:yournetwork 220.8.0.0/16
同时,可以选择将类似
include $RULE_PATH/local.rules
等,前面的#号去掉,设置自己的规则集
* /usr/local/bin/snort -D -l /var/log/snort -c /etc/snort.conf
* 将上一条命令写入/etc/rc.d/rc.local
2)安装guardian---需要perl支持
* cd /tmp
* tar zxvf guardian-1.6.tar.gz
* cd guardian-1.6
* echo >; /etc/guardian.ignore
* cp guardian.pl /usr/local/bin/.
* cp scripts/iptables_block.sh /usr/local/bin/guardian_block.sh
* cp scripts/iptables_unblock.sh /usr/local/bin/guardian_unblock.sh
* cp guardian.conf /etc/.
* vi /etc/guardian.conf
如下:
HostGatewayByte 1
# guardian的日志文件
LogFile /var/log/guardian.log
#guardian从何处读取snort的日志
AlertFile /var/log/snort/alert
#将你需要忽略的IP放在此文件中
IgnoreFile /etc/guardian.ignore
# 封锁IP的最长时间,99999999为没有时限
TimeLimit 86400
* /usr/bin/perl /usr/local/bin/guardian.pl -c /etc/guardian.conf
* 将上一条命令加入 /etc/rc.d/rc.local
至此,完成设置
注意:
1)snort的规则文件经常更新,可以使用如下脚本自动更新:
#!/bin/sh
cd /etc/snort
wget http://www.snort.org/dl/rules/snortrules-snapshot-CURRENT.tar.gz
tar zxvf snortrules-snapshot-CURRENT.tar.gz
exit 0
*将上述脚本存为snortupdate,并放置到/etc/cron.daily/下,可以每天更新一次;
2)guardian有时会自动退出,可以使用如下脚本解决:
#!/usr/bin/perl
use Proc::ProcessTable;
$found=0;
$t = new Proc::ProcessTable;
$g = "guardian.pl";
foreach $p ( @{$t->;table} ){
$f=($p->;cmndline =~ m/guardian/);
if($f==1)
{$found=1;
last;
}
}
if($found == 1)
{
print "guardian is alive!\n";
}
else
{
print "guardian is dead!\n";
print "restart guardian now ... \n";
system "/usr/local/bin/guardian.pl -c /etc/guardian.conf";
}
将上述脚本存为testguardian,放置到/etc/cron.hourly下,意思为:每1小时检测guardian是否存活,如果已经死亡就重新启动guardian
chmod +x /etc/cron.hourly/testguardian
同时,编辑/etc/crontab
在path一行加入/usr/local/bin
脚本:killguardian
#!/usr/bin/perl
#杀死当前guardian.pl进程,需要安装perl module Proc::ProcessTable
#访问http://www.cpan.org可以获得上述module
use Proc::ProcessTable;
$t = new Proc::ProcessTable;
foreach $p (@{$t->;table})
{
kill 9, $p->;pid if $p->;cmndline =~ 'guardian.pl';
}
--------------------------------------------------------------------------------
Snort 是一个开源的轻量级入侵监测系统,可以监测网络上的异常情况,给出报告;
Guardian是基于Snort+IPTables的一个主动防火墙,它分析Snort的日志文件,根据一定的判据自动将某些恶意的IP自动加入IPTables的输入链,将其数据报丢弃。
我自使用Snort+Guardian以来,每天可以看到很多的恶意行为被终止,心里很是高兴!
推荐大家使用!
安装步骤:
1)安装Snort:
*现在Snort & Guardian,目前下载地址为:
http://www.snort.org/dl/snort-2.3.0RC2.tar.gz
http://www.snort.org/dl/contrib/ ... guardian-1.6.tar.gz
*将上述文件拷贝至/tmp
*tar zxvf *.tgz
*cd snort-2.3.0RC2
*./configure
*make
*make install
*mkdir /etc/snort
*cd /etc/snort
*wget http://www.snort.org/dl/rules/snortrules-snapshot-CURRENT.tar.gz
* tar zxvf snortrules-snapshot-CURRENT.tar.gz
*mkdir /var/log/snort
*cd /etc
*vi snort.conf
修改后一些关键设置如下:
var HOME_NET yournetwork
var RULE_PATH /etc/snort/rules
preprocessor http_inspect: global \
iis_unicode_map /etc/snort/rules/unicode.map 1252
include /etc/snort/rules/reference.config
include /etc/snort/rules/classification.config
如:yournetwork 220.8.0.0/16
同时,可以选择将类似
include $RULE_PATH/local.rules
等,前面的#号去掉,设置自己的规则集
* /usr/local/bin/snort -D -l /var/log/snort -c /etc/snort.conf
* 将上一条命令写入/etc/rc.d/rc.local
2)安装guardian---需要perl支持
* cd /tmp
* tar zxvf guardian-1.6.tar.gz
* cd guardian-1.6
* echo >; /etc/guardian.ignore
* cp guardian.pl /usr/local/bin/.
* cp scripts/iptables_block.sh /usr/local/bin/guardian_block.sh
* cp scripts/iptables_unblock.sh /usr/local/bin/guardian_unblock.sh
* cp guardian.conf /etc/.
* vi /etc/guardian.conf
如下:
HostGatewayByte 1
# guardian的日志文件
LogFile /var/log/guardian.log
#guardian从何处读取snort的日志
AlertFile /var/log/snort/alert
#将你需要忽略的IP放在此文件中
IgnoreFile /etc/guardian.ignore
# 封锁IP的最长时间,99999999为没有时限
TimeLimit 86400
* /usr/bin/perl /usr/local/bin/guardian.pl -c /etc/guardian.conf
* 将上一条命令加入 /etc/rc.d/rc.local
至此,完成设置
注意:
1)snort的规则文件经常更新,可以使用如下脚本自动更新:
#!/bin/sh
cd /etc/snort
wget http://www.snort.org/dl/rules/snortrules-snapshot-CURRENT.tar.gz
tar zxvf snortrules-snapshot-CURRENT.tar.gz
exit 0
*将上述脚本存为snortupdate,并放置到/etc/cron.daily/下,可以每天更新一次;
2)guardian有时会自动退出,可以使用如下脚本解决:
#!/usr/bin/perl
use Proc::ProcessTable;
$found=0;
$t = new Proc::ProcessTable;
$g = "guardian.pl";
foreach $p ( @{$t->;table} ){
$f=($p->;cmndline =~ m/guardian/);
if($f==1)
{$found=1;
last;
}
}
if($found == 1)
{
print "guardian is alive!\n";
}
else
{
print "guardian is dead!\n";
print "restart guardian now ... \n";
system "/usr/local/bin/guardian.pl -c /etc/guardian.conf";
}
将上述脚本存为testguardian,放置到/etc/cron.hourly下,意思为:每1小时检测guardian是否存活,如果已经死亡就重新启动guardian
chmod +x /etc/cron.hourly/testguardian
同时,编辑/etc/crontab
在path一行加入/usr/local/bin
脚本:killguardian
#!/usr/bin/perl
#杀死当前guardian.pl进程,需要安装perl module Proc::ProcessTable
#访问http://www.cpan.org可以获得上述module
use Proc::ProcessTable;
$t = new Proc::ProcessTable;
foreach $p (@{$t->;table})
{
kill 9, $p->;pid if $p->;cmndline =~ 'guardian.pl';
}
顶(0)
踩(0)
上一篇:检测隐藏进程
下一篇:简述网管员在日志分析中的五个误区
- 最新评论