snort+vmware+centos搭建网络入侵检测系统(rkk新)

snort+vmware+centos搭建网络入侵检测系统(rkk新)

2023年7月23日发(作者:)

入侵检测系统试验环境搭建

---Linux 环境---

整理测试者:安徽商贸职业技术学院电信系芮坤坤

一、搭建环境简介:实现网络入侵检测平台搭建

1、所需软件及主要插件:

软件名称及版本 实现功能

1

2

3

4

5

Linux CentOS 6.5 操作系

统(内核版本2.6.32 )

Apache 2.2.3

PHP 5.2.10

Mysql 5.0.22

发布网页

发布网页

存储入侵日志的数据库

开源入侵检测系统软件

入侵检测系统平台

6

7

8

Snortrules-snapshot-2.

入侵检测规则集

图形化界面

数据库

连接插件

9 2 图表绘制插件

2、步骤:

(1)安装编译环境 Gcc 和 GCC-C++;

(2)安装及配置 Apache;

(3)安装及配置Mysql 数据库服务;

(4)安装及配置 Php 及相应支持插件;

(5)安装编译配置 Snort 系统和数据库等相应的文件;

(6)安装配置 ACID、ADODB、JPGRAPH 图形界面工具与数据库的连接;

(7)测试系统。

在安装配置前查看是否具有 Gcc 编译器,查看的方法:

rpm -qa |grep gcc

如果没有安装 Gcc 则进行 Gcc 的安装,执行下列命令进行安装(需要以下插件):

Yum –y install gcc*

二、安装 Apache

1.1、编译安装 Apache 的步骤

tar -zxvf apache-(版本号) #解压 apache

cd apache解压目录

./configure --prefix=/usr/local/apache --enable-so --enable-rewrite (配置)

make (编译)

make install (安装)

/usr/local/apache/bin/apachectl start #启动 Apache

cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache2

下次启动Apache时,只需输入/etc/init.d/apache2 start 即可

在浏览器中输入 127.0.0.1 测试 Apache,出现如下界面。

三、安装 Mysql

Groupadd mysql

useradd -g mysql mysql

3.1 编译安装 mysql:

tar -zxvf mysql-(版本号) #解压 mysql

进入 mysql 解压目录

cd mysql解压目录

./configure --prefix=/usr/local/mysql --with-charsets=gb2312 (配置)

make (编译)

make install (安装)

如在编译过程中出现错误,请安装如下软件包

yum -y install ncurses-devel*

进入 support-files 目录(在mysql解压目录中)

cd support-files

cp /etc/

/usr/local/mysql/bin/mysql_install_db --user=mysql

chown -R root /usr/local/mysql

chown -R mysql /usr/local/mysql/var

chgrp -R mysql /usr/local/mysql

/usr/local/mysql/share/mysql/ start #启动 MYSQL

cp /usr/local/mysql/share/mysql/ /etc/init.d/mysql2

下次启动mysql服务,只需输入/etc/init.d/mysql2 start即可

/usr/local/mysql/bin/mysqladmin -u root password 123456 #修改mysql登录密码

登录数据库进行测试:

/usr/local/mysql/bin/mysql -u root -p

password: 123456(root 根口令)

mysql>

四、Php 安装配置

4.1、编译安装

tar -jxvf php-(版本号)

cd php解压目录

./configure --prefix=/usr/local/php

--with-apxs2=/usr/local/apache/bin/apxs

--with-mysql=/usr/local/mysql

--with-config_file_path=/usr/local/php

make

make install

如在编译过程中出现问题,请安装如下软件包

yum install libxml2-devel*

vi /usr/local/apache/conf/

DirectoryIndex 后加

AddType application/X-httpd-php .php

vi /usr/local/apache/htdocs/ 建立一个测试用网页

phpinfo();

?>

重新启动 Apache

/etc/init.d/apache2 restart

在浏览器中输入:IP地址/ 可以看到 Php 中出现对 Mysql 的支持。

五、安装 Snort

下载编译 snort2.8.3.1,

#tar -zxvf

# cd snort-2.8.3.1

# ./configure --with-mysql

# make

# make install

# mkdir /etc/snort

# mkdir /var/log/snort

# cd /usr/local/src

#tar -zxvf

# cd rules

# cp * /etc/snort

# cd /usr/local/src/snort2.8.3.1/etc

# cp /etc/snort

# cp *.config /etc/snort

# vi /etc/snort/

[修改部分]

5.1、移动到第 39 行

把“# var HOME_NET 10.1.1.0/24”改成“var HOME_NET 192.168.1.7/24”

你自己网卡 IP 地址,把前面的#号去掉

5.2、移动到 110 行把“var RULE_PATH ../rules”改成“

“var RULE_PATH /etc/snort/” 更改规则路径

5.3、移动到 805 行把“# output database: log, mysql, user=root password=test

dbname=db host=localhost”改成“output database: log, mysql, user=root

password=123456 bname=snort host=localhost”

密码改成你自己的,把前面的#号去掉。

5.4、移动到 966 行,将

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

# include $RULE_PATH/

前面的#号删除,修改完毕后,:wq 保存退出

*************************************************************************************************

[错误 1]:

如果直接编译可能会出现以下错误:

ERROR!Libpcap library/headers(libpcap.a(or .so)/pcap.h) not found,go get it from

or use the –with-libpcap-* options,if you have it installed in an

unusual check if your libpcap depends on another shared library that may be

installed in an unusual place.

[解决方案]:

yum –y install libpcap libpcap-devel

*************************************************************************************************

[错误 2]:

继续编译如果出现以下错误:

ERROR!Libpcre header not found .

Get it from

[解决方案]:

yum –y install pcre pcre-devel

*************************************************************************************************

[错误 3]:

接着编译可能会出现以下错误:

ERROR!unable to find mysql headers(mysql.h)

Check in the following places

/usr

/usr/include

/usr/mysql

/usr/mysql/include

/usr/local

/usr/local/include

/usr/local/include/mysql

/usr/local/mysql

/usr/local/mysql/include

[解决方案]:

yum –y install mysql-devel

*************************************************************************************************

安装 mysql-devel 所需要的支持的插件列表

测试 snort 的安装:snort –vi eth0(使用嗅探模式查看本地网卡捕获的数据包),使

用 ctrl+c 停止捕获数据

测试数据截图:

六、建 立 Snort 数据库

# mysql –u root -p123456

# create database snort;

# grant INSERT,SELECT on root.* to snort@localhost;

# exit

# cd /usr/local/src/snort-2.8.3.1/schemas

# mysql -u root -p123456 < create_mysql snort

进入 snort2.8.3.1 的 schemas

测试:

snort -dev -l /var/log/snort -h 192.168.1.0/24 用于将捕获的记录存入日志文件

查看日志文件

snort -r /var/log/snort/.1209854033

*************************************************************************************************

[错误]

ERROR 1064(42000)at line 23:you have an error in your SQL syntax;check the manual that

corresponds to your MySQL server version for the right syntax to use near „schema(vseq

INT UNSIGNED NOT NULL,

Ctime „at line 1 )

[解决方案]

根据网上提供方案是 snort 版本和 mysql 版本不兼容,所以选择 snort 2.8.3.1 下载,

地址为:/?id=27125&ResourceID=26

*************************************************************************************************

# 进入 mysql 数据库,查看 snort 数据库中的表:

# mysql –u root -p123456

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

| icmphdr

| iphdr

| opt

| reference

| reference_system

| schema

| sensor

| sig_class

| sig_reference

| signature

| tcphdr

| udphdr

+------------------+

16 rows in set (0.00 sec)

mysql>exit

*************************************************************************************************

[错误 2]

运行 snort –c /etc/snort/

出现

Not Using PCAP_FRAMES

[解决方案]

停止 snort

Ctrl+c;

Set PCAP_FRAMES=MAX ,snort -W

*************************************************************************************************

七、安装配置 Acid

# 把 、、2放到网页根目录。

# cp a*.* /usr/local/apache/htdocs/

# cp 2 /usr/local/apache/htdocs/

#cd /usr/local/apache/htdocs

# tar -zxvf

# tar -jxvf 2

# mv jpgraph-3.0.7 jpgraph

# tar -zxvf

# cd acid

# vi acid_

移动到 12 行,

把#$DBlib_path = ";

改成$DBlib_path = " /usr/local/apache/htdocs/adodb”

移动到 32 行,把

#$alert_dbname = "snort_log"; //改成 snort

$alert_host = "localhost";

$alert_port = "";

$alert_user = "root";

$alert_password = "123456"; //改成数据库登录密码

/* Archive DB connection parameters */

$archive_dbname = "snort_archive"; //改成 snort

$archive_host = "localhost";

$archive_port = "";

$archive_user = "root";

$archive_password = "123456;” //改成数据库登录密码

移动到 69 行把

# $ChartLib_path =; 改成$ChartLib_path= /usr/local/apache/htdocs//jpgraph/src";

# 修改完毕后,保存退出。

八、 写一个 snort 规则

# cd /usr/local/

# vi

#!/bin/sh

snort -d -h 192.168.1.0/24 -l /var/log/snort -c /etc/snort/ -i eth0

-A full

# 保存退出。

# chmod 755

九、启动服务

# /etc/init.d/apache2 restart

# /etc/init.d/mysql2 restart

# /usr/local/

十、进入 Web 界面:

启动 snort:

snort -c /etc/snort/ -i eth0 -D

# 127.0.0.1/acid/acid_,

点"Setup Page"链接 Create Acid AG

# 访问 127.0.0.1/acid 将会看 到 ACID 界面。

*************************************************************************************************

[错误 1] :

Error(p)connecting to DB :snort@localhost

Check the DB connection variables in acid_

=$alert_dbname :MySQL database name where the alerts are stored

=$alert_host

=$alert_port

=$alert_user

=$alert_password

:host where the database is stored

:port where the database is stored

:username into the database

:password for the username

server through socket Database ERROR:Can‟t connect to local MySQL

„/var/lib/mysql/(111)

[解决方案]

1、数据库连接问题,使用了外部编译的 mysql 数据库,而 acid 连接的是系统自带的数据库;

*************************************************************************************************

Ln –s /tmp/ /var/lib/mysql/

[错误 2]:

点击

setup page 后出现界面,但是点击 create ACID AG 时没有反应,点击 search 链接出现 Database

ERROR:DatabaseERROR:Table „_ag‟doesn‟t exist

[解决方案]:

将 acid 中创建 mysql 表的文件输出到 mysql 数据库:

mysql –u root –p123456 < /var/www/html/create_acid_tbls_ snort

*************************************************************************************************

查看数据表已经多了 4 个数据表。

十一、测试 IDS

利用 NMAP,或者 X-scan 对系统进行扫描,产生告警纪录。同时启动 snort 后可以等待

几分钟,发现数据库中已经产生了报警信息。

发布者:admin,转转请注明出处:http://www.yc00.com/news/1690105949a306274.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信