snort 是一个强大的轻量级的网络入侵检测系统。它具有实时数据流量分析和日志IP 网络数据包的能力,能够进行协议分析,对内容进行搜索/匹配。它能够检测各种不同的攻击方式,对攻击进行实时报警。Snort 可以运行在*nix/Win32 平台上。
本文将主要介绍Win xp/2003 Server 下Snort 的安装与配置,关于Snort 的体系结构和规则,可以参考其他相关资。
一、需要的组件以及它们的作用,功能(各个安装文件去相关软件的主页下载):
(1)WinPcap:windwos下的捕获网络数据包的驱动程序库,http://winpcap.polito.it/
(2)snort:将其捕获的数据发送至数据库,http://www.snort.org/
(3)apache:为系统提供了web服务支持,http://www.apache.org/。
(4)php:为系统提供了php支持,使apache能够运行php程序,http://www.php.net/。
(5)MySQL:存储网络数据包的数据库,http://www.mysql.com/。
(6)acid:是基于php的入侵检测数据库分析控制台(刚才安装apache和php就是为了能运行它)http://www.cert.org/kb/acid/
(7)adodb:是php数据库的连接组件,http://adodb.sourceforge.net/。
(8)Jpgraph:Object-Oriented图形链接库For PHP,http://www.aditus.nu/jpgraph/。
acid:通过adodb从mssql.snort数据库中读取数据,将分析结果显示在网页上,并使用jpgraph组件对其进行图形化分析。
二、安装
1、WinPcap,一路next,就ok了.
2、安装Apache,PHP,MySQL,请参考以前我写的一篇文章http://guitarbug.blogchina.com/658709.html,注意选择MySQL4.0版本,4.1版本对客户端采用了新的验证方式,登录会有点问题.
3、安装adodb
http://keihanna.dl.sourceforge.net/sourceforge/adodb/adodb471-1.tgz
http://ftp7.enet.com.cn:88/pub/linux/development/libraries/adodb.tgz
解压缩adodb471.zip 至c:\php\adodb 目录下
4、安装Snort和配置Snort
使用默认安装路径c:\snort,选择数据库为 MySQL,并按照以下修改C:\Snort\etc\snort.conf文件:
需要修改的地方:
include classification.config
include reference.config
改为绝对路径
include c:\snort\etc\classification.config
include c:\snort\etc\reference.config
设置snort 输出alert 到mysql server
output database: alert, mysql, host=localhost user=snort password=snort dbname=snort
encoding=hex detail=full
测试snort 是否正常工作:
c:\snort\bin>snort -c "c:\snort\etc\snort.conf" -l "c:\snort\logs" -d -e -X
-X 参数用于在数据链接层记录raw packet 数据
-d 参数记录应用层的数据
-e 参数显示/记录第二层报文头数据
-c 参数用以指定snort 的配置文件的路径
5、安装snort rule
在snort网站下载rule规则
将其rule 、doc目录覆盖到c:\snort\rule\、c:\snort\doc
6、配置与snort相关的数据库和用户权限
配置mysql
为默认root 帐号添加口令:
c:\>cd mysql\bin
c:\>mysql mysql
mysql>set password for "root"@"localhost" = password('erFl87tr32Gk');
删除默认的mailto:any@帐号
mysql>delete from user where user='' and host = '%';
mysql>delete from db where user='' and host = '%';
mysql>delete from tables_priv where user='' and host = '%';
mysql>delete from columns_priv where user='' and host = '%';
删除默认的any@localhost 帐号
mysql>delete from user where user ='' and host = 'localhost';
mysql>delete from db where user = '' and host = 'localhost';
mysql>delete from tables_priv where user='' and host = 'localhost';
mysql>delete from columns_priv where user='' and host= 'localhost';
删除默认的mailto:root@帐号
mysql>delete from user where user = 'root' and host = '%';
mysql>delete from db where user = 'root' and `host` = '%';
mysql>delete from tables_priv where user= 'root' and host = '%';
mysql>delete from columns_priv where user = 'root' and host = '%';
这样只允许root 从localhost 连接
建立snort 运行必须的snort 库和snort_archive 库
mysql>create database snort;
mysql>create database snort_archive;
使用c:\snort\contrib 目录下的create_mysql 脚本建立Snort 运行必须的数据表
c:\mysql\bin\mysql -D snort -u root -p < c:\snort\contrib\create_mysql
c:\mysql\bin\mysql -D snort_archive -u root -p < c:\snort\contrib\create_mysql
建立acid 和snort 用户
mysql> grant usage on *.* to "acid"@"localhost" identified by "acidtest";
mysql> grant usage on *.* to "snort"@localhost" identified by "snorttest";
为acid 用户和snort 用户分配相关权限
mysql> grant select,insert,update,delete,create,alter on snort .* to "acid"@"localhost";
mysql> grant select,insert on snort .* to "snort"@"localhost";
mysql> grant select,insert,update,delete,create,alter on snort_archive .* to "acid"@"localhost";
7、安装acid
(1)解压缩acid压缩包至apache2\htdocs\acid目录下
(2)修改acid_conf.php文件,找到相应的行,并把它们改成:
$DBtype = "mysql";
$DBlib_path = "c:\php\adodb";
$alert_dbname = "snort";
$alert_host = "localhost";
$alert_port = "";
$alert_user = "snort";
$alert_password = "yourpassword";
/* Archive DB connection parameters */
$archive_dbname = "snort_archive";
$archive_host = "localhost";
$archive_port = "";
$archive_user = "snort";
$archive_password = "yourpassword";
$ChartLib_path = "c:\php\jpgraph\src";
(3)打开http://localhost/acid/acid_db_setup.php,测试基本功能是否安装成功。如果有错误,则根据错误情况重新检查。在正常情况下,到此处应该能够正常连接数据库。
8、安装jpgrapg 库
(1)解压缩jpgraph压缩包至c:\php\ jpgraph
(2)修改jpgraph.php
DEFINE("CACHE_DIR","/tmp/jpgraph_cache/");
三、运行snort,打开ACID
(1),进入cmd命令窗口,切换到snort安装目录,例如c:\snort\bin运行snort -c "c:\snort\etc\snort.conf" -l "c:\snort\logs" -d,运行后不要关闭窗口.
(2),输入http://localhost/acid/,应该可以看到当前的网络情况分析。
OVER!