服务器 频道

安装Win2003 Server下的Snort

  【IT168 服务器学院】snort 是一个强大的轻量级的网络入侵检测系统。它具有实时数据流量分析和日志IP 网络数据包的能力,能够进行协议分析,对内容进行搜索/匹配。它能够检测各种不同的攻击方式,对攻击进行实时报警。Snort 可以运行在*nix/Win32 平台上。

  本文将主要介绍Win2003 Server 下Snort 的安装与配置,关于Snort 的体系结构和规则,可以参考其他相关资。

  安装与配置

  首先下载以下软件包:
  acid-0.9.6b23.tar.gz
  http://www.cert.org/kb/acid
  基于php 的入侵检测数据库分析控制台
  adodb360.zip
  http://php.weblogs.com/adodb
  ADOdb(Active Data Objects Data Base)库for PHP
  apache_2.0.46-win32-x86-no_src.msi
  http://www.apache.org
  Windows 版本的Apache Web 服务器
  jpgraph-1.12.2.tar.gz
  http://www.aditus.nu/jpgraph
  OO 图形库for PHP
  mysql-4.0.13-win.zip
  http://www.mysql.com
  Windows 版本的Mysql 数据库服务器
  php-4.3.2-Win32.zip
  http://www.php.net
  Windows 版本的php 脚本环境支持
  snort-2_0_0.exe
  http://www.snort.org
  Windows 版本的Snort 安装包
  WinPcap_3_0.exe
  http://winpcap.polito.it/
  网络数据包截取驱动程序
  phpmyadmin-2.5.1-php.zip
  http://www.phpmyadmin.net
  基于php 的Mysql 数据库管理程序
  (需要国外代理访问)

  首先安装Apache_2.0.46 For Windows

  安装的时候注意,如果你已经安装了IIS 并且启动了Web Server,因为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-4.3.2-Win32.zip 至c:\php
  拷贝php4ts.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();?>
  使用http://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:
  解压缩adodb360.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 的配置文件的路径

   

0
相关文章