轉貼 - 入侵檢測 防火牆應用實例
入侵檢測 防火牆應用實例
推薦大家使用一個入侵測系統+主動防火牆——Snort+Guardian 。
Snort 是一個開源的羽量級入侵監測系統,可以監測網路上的異常情況,給出報告;
Guardian是基於Snort+IPTables的一個主動_blank">防火牆,它分析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:rocessTable;
$found=0;
$t = new Proc:rocessTable;
$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:rocessTable
#訪問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 是一個開源的羽量級入侵監測系統,可以監測網路上的異常情況,給出報告;
Guardian是基於Snort+IPTables的一個主動_blank">防火牆,它分析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:rocessTable;
$found=0;
$t = new Proc:rocessTable;
$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:rocessTable
#訪問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';
}
沒有留言:
張貼留言