点击这里给我发消息 点击这里给我发消息
首页 > 行业资讯 > Mysql>详细内容

构建小型的 FreeBSD 入侵检测系统

添加时间:2010-1-4
    相关阅读: 软件 数据库 网络 SQL PHP Mysql 系统

1.Snort简介 Snort 是一个强大的轻量级的网络入侵检测系统。它具有实时数据流量分析和日志IP 网络数据包的能力,能够进行协议分析,对内容进行搜索/匹配。它能够检测各种不同的攻击方式,对攻击进行实时报警。更重要的它是免费的,在中小企业中很好的适应网络环境,不需要太多的资源和资金就能建立起一个优秀的IDS系统。 2.系统平台
安装平台选择FreeBSD 4.9 ,本身足够安全,坚固;特性喜欢PORTS安装起来少了不少麻烦。
Hawk# uname -a
FreeBSD hawk.the9 4.9-RELEASE FreeBSD 4.9-RELEASE

3.需要软件
Mysql-server-3.23.58 http://mysql.secsup.org
Snort2.0.6 http://www.snort.org
Apache-2.0.47 http://www.apache.org
mod_php4-4.3.3,1 http://www.php.net
adodb-3.60_1 http://phplens.com
acid-0.9.6b23 http://acidlab.sourceforge.net
Jpgraph-1.12.2 http://jpgraph.techuk.com

4.安装SNORT
1)安装mysql
hawk# cd /usr/ports/databases/mysql323-server
hawk# make install
2)安装apache
hawk# cd /usr/ports/www/apache2/
hawk# make install
3)安装PHP
hawk # cd /usr/ports/www/mod_php4
hawk # make install
4)配置APACHE
编辑httpd.conf (/usr/local/etc/apache2)
DocumentRoot "/usr/local/www/snort"
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
5)安装SNORT
hawk# mkdir /etc/snort
hawk# mkdir /var/log/snort
hawk# tar -zxvf snort-2.0.6.tar.gz
hawk# mv snort-2.0.6 /etc/snort
hawk# ./configure --with-mysql

hawk# make
hawk# make install
hawk# cd /etc/snort/etc
hawk# cp snort.conf /etc/snort/
hawk# cp *.config /etc/snort

6) 安装SNORT的规则库
可以在SNORT站点上下载标准规则库,基本够用了。2.0.0.x的SNORT使用STABLE rules,而2.0.1.x的SNORT使用CURRENT rules。
hawk# mkdir /etc/snort/etc
hawk# wget http://www.snort.org/dl/rules/snortrules-stable.tar.gz
hawk# tar xvfz snortrules-stable.tar.gz

7)配置SNORT
修改snort.conf (/etc/snort/snort.conf)
var HOME_NET 172.18.0.0/22 (修改为你的内部网网络地址)
var EXTERNAL_NET any #外网,关键字any这里表示HOME_NET之外的所有地址
var DNS_SERVERS 202.197.32.12 #DNS 服务器
var RULE_PATH ../rules 修改为 var RULE_PATH /etc/snort/etc/rules
改变记录日志数据库:
output database: log, mysql, user=root password=your_password dbname=snort host=localhost

8) 设置snort启动
hawk# vi /usr/local/etc/rc.d/snort.sh
#!/bin/sh
case "{GetProperty(Content)}" in
start)
/usr/local/bin/snort -Dqc /etc/snort/snort.conf > /dev/null && echo -n " snort"
;;
stop)
kill `cat /var/run/snort_*.pid`
;;
restart)
killall -1 `cat /var/run/snort_*.pid`
;;
*)
echo "Usage: snort.sh [start|stop|restart]"
;;
esac

不过建议是手动启动,我在使用中发现自动启动有一点问题,等系统完全启动完了再启动SNORT就一切正常。

9)在mysql中建立数据库
先建立SNORT使用的数据库
mysql>create database snort;
mysql>grant INSERT,SELECT on root.* to snort@localhost;
mysql>quit;
进入snort安装目录:
mysql -p <./contrib/create_mysql snort
>Enter password:
安装DB表:(在contrib目录)
zcat snortdb-extra.gz | mysql -p snort
>Enter password:

安装完成检查一下表的显示
mysql>show databases;
+------------+
| Database
+------------+
| mysql
| snort
| test
+------------+
3 rows in set (0.00 sec)
mysql>use snort;
mysql>show tables; 将会有这些:
+------------------+
| Tables_in_snort |
+------------------+
| data
| detail
| encoding
| event
| flags
| icmphdr
| iphdr
| opt
| protocols
| reference
| reference_system
| schema
| sensor
| services
| sig_class
| sig_reference
| signature
| tcphdr
| udphdr
+------------------+
19 rows in set (0.00 sec)
mysql>exit

5.安装配置Web接口
1)先安装GD库
hawk# cd /usr/ports/graphics/gd
hawk# make install
2) 安装 jpgraph-1.12.2
hawk# cd /usr/ports/graphics/jpgraph
hawk# make install
3)安装adodb-3.60_1
hawk# cd /usr/ports/databases/adodb
hawk# make install
4 )安装acid-0.9.6b23
hawk# cd /usr/ports/security/acid
hawk# make install
5)配置 acid
hawk# mv /usr/local/www/data.default/php/adodb /usr/local/www/snort/
hawk# mv /usr/local/www/data.default/php/acid /usr/local/www/snort/
编辑acid_conf.php,修改相关配置如下:
$DBlib_path = "/usr/local/www/snort/adodb";
/* The type of underlying alert database
*
* MySQL : "mysql"
* PostgresSQL : "postgres"
* MS SQL Server : "mssql"
*/
$DBtype = "mysql";
/* Alert DB connection parameters
* - $alert_dbname : MySQL database name of Snort alert DB
* - $alert_host : host on which the DB is stored
* - $alert_port : port on which to access the DB
* - $alert_user : login to the database with this user
* - $alert_password : password o

本文作者:
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册