天天看点

IDS入侵检测系统下的snort安装

snort在windows下的安装

snort 是一个强大的轻量级的网络入侵检测系统。它具有实时数据流量分析和日志IP 网络数

据包的能力,能够进行协议分析,对内容进行搜索/匹配。它能够检测各种不同的攻击方式,

对攻击进行实时报警。Snort 可以运行在*nix/Win32 平台上.

本文将主要介绍Win2003 Server 下Snort 的安装与配置,关于Snort 的体系结构和规则,可

以参考其他相关资料.

安装与配置

acid-0.9.6b23.tar.gz               基于php 的入侵检测数据库分析控制台           http://www.cert.org/kb/acid

adodb465.zip                        ADOdb库for PHP                          http://prdownloads.sourceforge.net/adodb/

apache_2.2.2-win32-x86-no_ssl.msi  Windows 版本的Apache Web 服务器    http://mirror.vmmatrix.net/apache

jpgraph-1.20.4a.tar.gz                面向对象的图形库for PHP                             http://www.aditus.nu/jpgraph

mysql-5.0.22-win32.zip            Windows 版本的Mysql 数据库服务器           http://dev.mysql.com/

php-5.1.6-Win32.zip                 Windows 版本的php 脚本                              http://www.php.net/

snort_2_6_0_Installer.exe          Windows 版本的Snort 安装包                        http://www.snort.org/

WinPcap_3_1.exe                        网络数据包截取驱动程序                              http://www.winpcap.org/

(网址是仅供参考,但版本一定要匹配)

首先安装Apache

安装的时候注意,如果你已经安装了IIS 并且启动了Web Ser ver ,因为IIS 的WebServer 默

认在TCP 80 端口监听,所以会和Apache WebServer 冲突,我们可以修改Apache WebServer

为其他端口。选择定制安装,安装路径修改为c:\apache 安装程序会自动建立c:\apache2 目录,

继续以完成安装。

安装完成后首先修改c:\apache2\conf\httpd.conf

定制安装完成后,apache web server 默认在8080 端口监听,我们修改为其他不常用的高端

端口:

修改Listen 8080 为Listen 50080

安装apache 为服务方式运行

c:\apache2\bin\apache –k install

添加Apache 对PHP 的支持:

解压缩php-5.1.6-Win32.zip  至c:\php

拷贝php5ts.dll 至%systemroot%\system32

拷贝php.ini-dist 至%systemroot%\php.ini

修改php.ini

extension=php_gd2.dll

同时拷贝c:\php\extension\php_gd2.dll 至%systemroot%\

以上添加gd 图形库支持

在httpd.conf 中添加

LoadModule php4_module "c:/php/sapi/php4apache2.dll"

AddType application/x-httpd-php .php

启动Apache 服务

net start apache2

在c:\apache2\htdocs 目录下新建test.php ,

test.php 文件内容:

<?phpinfo();?>

使?*** ttp://192.168.0.15:50080/test.php

测试php 是否安装成功

安装Snort_2_0_0

使用默认安装路径c:\snort

安装Mysql

默认安装Mysql 至c:\mysql ,

安装mysql 为服务方式运行

c:\mysql\bin\mysqld-nt –install

启动mysql 服务

net start mysql

ps:Win2003 Server 下如果出现不能启动mysql ,新建my.ini

内容为:

[mysqld]

basedir=C:\MySQL

bind-address=127.0.0.1

datadir=C:\MySQL\data

注意其中的basedir 和datadir 目录是否指向了正确的目录.

把my.ini 拷贝至%systemroot%目录下就可以了

配置mysql

为默认root 帐号添加口令:

c:\>cd mysql\bin

c:\>mysql mysql

mysql>set password for "root"@"localhost" = password('erFl87tr32Gk');

删除默认的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';

删除默认的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";

安装adodb:

解压缩adodb465.zip  至c:\php\adodb 目录下

安装acid

解压缩acid-0.9.6b23.tar.gz  至c:\apache2\htdocs\acid 目录下

修改acid_conf.php 文件

$DBlib_path = "c:\php\adodb";

$alert_dbname = "snort";

$alert_host = "localhost";

$alert_port = "";

$alert_user = "acid";

$alert_password = "log_snort";

/* Archive DB connection parameters */

$archive_dbname = "snort_archive";

$archive_host = "localhost";

$archive_port = "";

$archive_user = "acid";

$archive_password = "archive_snort";

$ChartLib_path = "c:\php\jpgraph\src";

建立acid 运行必须的数据库:

http://192.168.0.15:50080/acid/acid_db_setup.php

按照系统提示建立

安装jpgrapg 库

解压缩jpgraph-1.12.2.tar.gz 至c:\php\ jpgraph

修改jpgraph.php

DEFINE("CACHE_DIR","/tmp/jpgraph_cache/");

安装winpcap

配置Snort

编辑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 的配置文件的路径

                                                                                                                             (如有不正确请大家指出)

继续阅读