suricata安装配置

suricata是开源的IPS工具,其中使用了netfilter_queue库,可以借鉴

安装:(https://redmine.openinfosecfoundation.org/projects/suricata/wiki/CentOS_Installation

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
 yum -y install libpcap libpcap-devel libnet libnet-devel pcre \
pcre-devel gcc gcc-c++ automake autoconf libtool make libyaml \
libyaml-devel zlib zlib-devel file-devel
HTP安装: 
./configure --enable-nfqueue
rpm -Uvh http://rules.emergingthreatspro.com/projects/emergingrepo/x86_64/libnetfilter_queue-0.0.15-1.x86_64.rpm \
http://rules.emergingthreatspro.com/projects/emergingrepo/x86_64/libnetfilter_queue-devel-0.0.15-1.x86_64.rpm \
http://rules.emergingthreatspro.com/projects/emergingrepo/x86_64/libnfnetlink-0.0.30-1.x86_64.rpm \
http://rules.emergingthreatspro.com/projects/emergingrepo/x86_64/libnfnetlink-devel-0.0.30-1.x86_64.rpm
yum -y install python-devel
#The latest version that will compile is 0.6.6.
wget http://people.redhat.com/sgrubb/libcap-ng/libcap-ng-0.6.6.tar.gz
tar -xzvf libcap-ng-0.6.6.tar.gz
cd libcap-ng-0.6.6
./configure 
make 
make install
ln -s /usr/local/lib/libcap-ng.so.0 /usr/lib64/libcap-ng.so.0

Suricata

To download and build Suricata, enter the following:

wget http://www.openinfosecfoundation.org/download/suricata-2.0.11.tar.gz
tar -xvzf suricata-2.0.11.tar.gz
cd suricata-2.0.11

If you are building from Git sources, enter all the following commands:

bash autogen.sh

If you are not building from Git sources, enter only:

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-nfqueue
make
sudo make install
配置Suricata 
Suricata源代码随带默认的配置文件。不妨安装这些默认的配置文件,如下所示。
$ sudo make install-conf
正如你所知,要是没有IDS规则集,Suricata毫无用处。颇为方便的是,Makefile随带IDS规则安装选项。想安装IDS规则,运行下面这个命令即可。
$ sudo make install-rules
上述规则安装命令会从EmergingThreats.net(https://www.bro.org)安装可用的社区规则集的最新快照,并将它们存储在/etc/suricata/rules下。

首次配置Suricata IDS

现在就可以配置Suricata了。配置文件位于/etc/suricata/suricata.yaml。使用文本编辑工具打开文件,以便编辑。

$ sudo vi /etc/suricata/suricata.yaml

下面是一些基本的设置,供你开始入门。

“default-log-dir”关键字应该指向Suricata日志文件的位置。

default-log-dir: /var/log/suricata/

在“vars”这部分下面,你会找到Suricata使用的几个重要变量。“HOME_NET”应该指向由Suricata检查的本地网络。“!$HOME_NET”(被分配给EXTERNAL_NET)指本地网络以外的任何网络。“XXX_PORTS”表明不同服务所使用的一个或多个端口号。请注意:不管使用哪个端口, Suricata都能自动检测HTTP流量。所以,正确指定HTTP_PORTS变量并不是很重要。

vars:
HOME_NET: "[192.168.122.0/24]"
EXTERNAL_NET: "!$HOME_NET"
HTTP_PORTS: "80"
SHELLCODE_PORTS: "!80"
SSH_PORTS: 22

“host-os-policy”这部分用来防范一些利用操作系统的网络堆栈的行为(比如TCP重组)来规避检测的常见攻击。作为一项应对措施,现代IDS想出了所谓的“基于目标的”检测,检查引擎根据流量的目标操作系统,对检测算法进行微调。因而,如果你知道每个本地主机运行什么操作系统,就可以将该信息提供给Suricata,从而有望提高其检测速度。这时候用到了“host-os-policy“部分。在该例子中,默认的IDS策略是Linux;如果不知道某个IP地址的操作系统信息,Suricata就会运用基于Linux的检查策略。如果捕获到192.168.122.0/28和192.168.122.155的流量,Suricata就会运用基于Windows的检查策略。

host-os-policy:
# 这些是Windows机器。
windows: [192.168.122.0/28, 192.168.122.155]
bsd: []
bsd-right: []
old-linux: []
# 将Linux作为默认策略。
linux: [0.0.0.0/0]
old-solaris: []
solaris: ["::1"]
hpux10: []
hpux11: []
irix: []
macos: []
vista: []
windows2k3: []

在“threading”这部分下面,你可以为不同的Suricata线程指定CPU亲和性(CPU affinity)。默认情况下,CPU亲和性被禁用(“set-cpu-affinity: no”),这意味着Suricata线程将被安排在任何可用的CPU核心上。默认情况下,Suricata会为每个CPU核心创建一个“检测”线程。你可以调整这个行为,只要指定“detect-thread-ratio: N”。这会创建N x M个检测 线程,其中M是指主机上CPU核心的总数。

threading:
set-cpu-affinity: no
detect-thread-ratio: 1.5

就上述线程设置而言,Suricata会创建1.5 x M个检测线程,其中M是系统上CPU核心的总数。

想了解关于Suricata配置的更多信息,你可以阅读默认的配置文件本身,为了便于理解,加有大量注释。

以上是编译安装的整个过程,为了更好的理解suricata的功能,自己做了一个简单的测试:
1、自己编写一条规则,规则书写参考snort规则(suricata完全兼容snort规则)
   例如以百度网站为例:
   [root@host201 rules]# cat test.rules
alert http any any -> any any (msg:"hit baidu.com...";content:"baidu"; reference:url, www.baidu.com;)
   将文件命名为test.rules,存放在目录/etc/suricata/rules下(直接存放在该目录下rules里面)。
2、启动suricata 
  ./suricata  -s test.rules -i eth1

3、打开虚拟机中浏览器,访问www.baidu.com
   此时,查看log文件/var/log/suricata目录下
   fast.log显示数据包匹配的条数
   http.log   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值