Snort的规则和配置
从源码安装的snort还需要设置规则和配置,因此我们需要复制规则和配置到/etc/snort下面。我们已经创建了单独的bash脚本来用于设置规则和配置。它会设置下面这些snort设置。
-
在linux中创建用于snort IDS服务的snort用户。
-
在/etc下面创建snort的配置文件和文件夹。
-
权限设置并从源代码的etc目录中复制数据。
-
从snort文件中移除规则中的#(注释符号)。
-
#!/bin/bash#
-
# snort源代码的路径
-
snort_src="/home/test/Downloads/snort-2.9.7.3"
-
echo "adding group and user for snort..."
-
groupadd snort &> /dev/null
-
useradd snort -r -s /sbin/nologin -d /var/log/snort -c snort_idps -g snort &> /dev/null#snort configuration
-
echo "Configuring snort..."mkdir -p /etc/snort
-
mkdir -p /etc/snort/rules
-
touch /etc/snort/rules/black_list.rules
-
touch /etc/snort/rules/white_list.rules
-
touch /etc/snort/rules/local.rules
-
mkdir /etc/snort/preproc_rules
-
mkdir /var/log/snort
-
mkdir -p /usr/local/lib/snort_dynamicrules
-
chmod -R 775 /etc/snort
-
chmod -R 775 /var/log/snort
-
chmod -R 775 /usr/local/lib/snort_dynamicrules
-
chown -R snort:snort /etc/snort
-
chown -R snort:snort /var/log/snort
-
chown -R snort:snort /usr/local/lib/snort_dynamicrules
-
###copy configuration and rules from etc directory under source code of snort
-
echo "copying from snort source to /etc/snort ....."
-
echo $snort_src
-
echo "-------------"
-
cp $snort_src/etc/*.conf* /etc/snort
-
cp $snort_src/etc/*.map /etc/snort##enable rules
-
sed -i 's/include \$RULE\_PATH/#include \$RULE\_PATH/' /etc/snort/snort.conf
-
echo "---DONE---"
改变脚本中的snort源目录路径并运行。下面是成功的输出。
running script
上面的脚本从snort源中复制下面的文件和文件夹到/etc/snort配置文件中
files copied
snort的配置非常复杂,要让IDS能正常工作需要进行下面必要的修改。
-
ipvar HOME_NET 192.168.1.0/24 # LAN side
-
ipvar EXTERNAL_NET !$HOME_NET # WAN side
veriable set
-
var RULE_PATH /etc/snort/rules # snort signature path
-
var SO_RULE_PATH /etc/snort/so_rules #rules in shared libraries
-
var PREPROC_RULE_PATH /etc/snort/preproc_rules # Preproces path
-
var WHITE_LIST_PATH /etc/snort/rules # dont scan
-
var BLACK_LIST_PATH /etc/snort/rules # Must scan
main path
-
include $RULE_PATH/local.rules # file for custom rules
移除ftp.rules、exploit.rules前面的注释符号(#)。
path rules
现在下载社区规则并解压到/etc/snort/rules。启用snort.conf中的社区及紧急威胁规则。
wget_rules
community rules
进行了上面的更改后,运行下面的命令来检验配置文件。
-
# snort -T -c /etc/snort/snort.conf
snort running
总结
本篇中,我们关注了开源IDPS系统snort在Ubuntu上的安装和配置。通常它用于监控事件,然而它可以被配置成用于网络保护的在线模式。snort规则可以在离线模式中可以使用pcap捕获文件进行测试和分析
(责任编辑:IT) |