linux下snort的架设
(2011-08-31 19:17:32)
标签:
it |
分类: linux知识 |
这篇文章假设LAMP已经架设完成,只介绍Snort与LAMP相结合的部分。
编译安装Snort(这里以2.8.5.1版本为例)之前,必须先编译安装libpcap,这里把libpcap安装在/home/Program/libpcap。 安装之后,开始编译snort: # ./configure --prefix=/home/Program/snort --with-libpcap-includes=/home/Program/libpcap/include --with-libpcap-libraries=/home/Program/libpcap/lib --with-mysql=/mysql --with-mysql-includes=/mysql/include --with-mysql-libraries=/mysql/lib --enable-dynamicplugin 如果需要添加Pgsql支持,就把下面这句加上: --with-postgresql=/pgsql --with-pgsql-includes=/pgsql/include # make # make install # mkdir -v /var/log/snort ********************************************************************************************* 注意:如果要增加pgsql支持,要修改configure文件: 在 if test -z "$POSTGRESQL_LIB_DIR"; then 语句之前加上 POSTGRESQL_LIB_DIR="/pgsql/lib" 这句,/pgsql为pgsql的安装目录。 然后,保存退出。 ********************************************************************************************* # mkdir -v /home/Program/snort/etc # cd path/snort-2.8.5.1/etc 把用已注册的用户名从官方网站下载来的规则文件snortrules-snapshot-2.8.tar.gz解压后, 把其中的rules目录手动复制到/home/Program/snort目录下。 安装使用共享对象规则(so rules): # tar zxf snortrules-snapshot-2.8.tar.gz # cd so_rules # cat *.rules >> so-rules.rules # vi /home/Program/snort/etc/snort.conf 注释掉下面一行: # include $RULE_PATH/so-rules.rules 然后,保存退出。 # cd so_rules/src # vi Makefile 修改为 BASEDIR=/home/net/snort-2.8.5.1 修改为 SNORT_VERSION=2.8.5.1 把libs :=后面的web-activex、sql、multimedia注释掉。 然后,保存退出。 # make # cp -v *.so /home/Program/snort/lib/snort_dynamicrules # vi /home/Program/snort/etc/snort.conf 把其中的 dynamicpreprocessor directory /usr/local/lib/snort_dynamicpreprocessor/ 修改为 dynamicpreprocessor directory /home/Program/snort/lib/snort_dynamicpreprocessor/ 把其中的 dynamicengine /usr/local/lib/snort_dynamicengine/libsf_engine.so 修改为 dynamicengine /home/Program/snort/lib/snort_dynamicengine/libsf_engine.so 然后保存退出。 # groupadd snort # useradd -g snort snort -s /sbin/nologin # mysql -p mysql> create database snort; mysql> grant create,insert,select,delete,update on snort.* to snort@localhost identified by 'passwd'; # mysql -p < path/snort-2.8.5.1/schemas/create_mysql snort 如果是pgsql,要创建snort数据库用户及snort数据库,然后使用以下命令即可(不必单独执行授权命令): # psql -U snort < path/snort-2.8.5.1/schemas/create_postgresql snort # vi /home/Program/snort/etc/snort.conf 把其中的 # output database: log, mysql, user=root password=test dbname=db host=localhost 修改为 output database: log, mysql, user=snort password=passwd dbname=snort host=localhost ====================================================== 如果是pgsql,就改为 output database: alert, postgresql, user=snort password=passwd dbname=snort host=localhost ====================================================== 然后保存退出。 ********************************************************************************************* output database:后面是log时,会记录太多信息,而改为alert则仅记录警告信息。 ********************************************************************************************* 下载并安装BASE与ADODB: 去地址:http://sourceforge.net/projects/secureideas/files/ 去地址:http://sourceforge.net/projects/adodb/files/ 解压后, # mv base-x.x.x /apache2/html/base # mv adodb /apache2/ # cd /apache2/html/base # cp -v base_conf.php.dist base_conf.php # vi base_conf.php 把下面的选项 $BASE_urlpath = ''; $DBlib_path = ''; $DBtype = 'mysql'; $alert_dbname = 'snort_log'; $alert_host = 'localhost'; $alert_port = ''; $alert_user = 'snort'; $alert_password = 'mypassword'; $archive_exists = 0; $archive_dbname = 'snort_archive'; $archive_host = 'localhost'; $archive_port = ''; $archive_user = 'snort'; $archive_password = 'mypassword'; 分别修改为 $BASE_urlpath = '/base'; $DBlib_path = '/apache2/adodb/'; $DBtype = 'mysql'; $alert_dbname = 'snort'; $alert_host = 'localhost'; $alert_port = ''; $alert_user = 'snort'; $alert_password = 'snortpass'; $archive_exists = 0; $archive_dbname = 'snort'; $archive_host = 'localhost'; $archive_port = ''; $archive_user = 'snort'; $archive_password = 'snortpass'; 然后保存退出。 # mkdir -v /apache2/password # /apache2/bin/htpasswd -c /apache2/password/passwords base New password: <yourpasswordadminbase> Re-type new password: <yourpasswordadminbase> Adding password for user base # vi /apache2/conf/base.conf 添加以下内容: <Directory "/apache2/html/base"> AuthType Basic AuthName "SnortIDS" AuthUserFile /apache2/password/passwords Require user base </Directory> 然后保存退出。 # vi /apache2/conf/httpd.conf 添加以下内容: Include conf/base.conf 然后保存退出。 重启LAMP服务器,并运行Snort。 在浏览器的地址栏中,输入:http://lqy0909.vicp.net/base 来访问BASE,这是会提示输入用户名密码,用户名是base,密码就是刚刚用htpasswd命令设置的密码。 如果使用过程中,出现类似以下错误提示: Warning: include_once(Mail.php) [function.include-once]: failed to open stream: No such file or directory in /apache2/html/base/includes/base_action.inc.php on line 29 Warning: include_once() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.:') in /apache2/html/base/includes/base_action.inc.php on line 29 Warning: include_once(Mail/mime.php) [function.include-once]: failed to open stream: No such file or directory in /apache2/html/base/includes/base_action.inc.php on line 30 Warning: include_once() [function.include]: Failed opening 'Mail/mime.php' for inclusion (include_path='.:') in /apache2/html/base/includes/base_action.inc.php on line 30 Warning: Cannot modify header information - headers already sent by (output started at /apache2/html/base/includes/base_action.inc.php:29) in /apache2/html/base/base_common.php on line 1077 可以用以下办法解决: # pear install pear/Mail # pear install pear/Mail_Mime 下面的包也要安装,否则会出现找不到Perl::Image_Graph的错误提示: # pear install channel://pear.php.net/Image_Canvas-0.3.2 # pear install channel://pear.php.net/Image_Graph-0.7.2 可选: # pear install pear/Numbers_Roman # pear install channel://pear.php.net/Numbers_Words-0.16.1 |
前一篇:linux下snort问题
后一篇:Nginx介绍