目录

编译安装

运行

调试


编译安装

apt -y install autoconf automake build-essential cargo \
     libjansson-dev libpcap-dev libpcre2-dev libtool \
    libyaml-dev make pkg-config rustc zlib1g-dev
    
apt-get install libpcre3-dev

wget https://www.openinfosecfoundation.org/download/suricata-7.0.0.tar.gz
tar xzvf suricata-7.0.0.tar.gz
cd suricata-7.0.0/

./configure --enable-nfqueue --prefix=/usr --sysconfdir=/etc --localstatedir=/var

make
make install-full

suricata编译安装和运行_服务器

运行

1、编辑/etc/suricata/suricata.yaml

修改如下:

第一个箭头处为抓包网卡名称

第二箭头处添加一行

suricata编译安装和运行_服务器_02

2、

cd /var/lib/suricata/rules

新增自定义规则,创建test.rules,内容为

alert tcp any any -> any any (msg: "Http rule test!";  flow:to_server,established; http.uri; content:"suricata"; sid:3030303; rev:1;)

http报文中uri包含suricata字段,就会匹配中该规则
编辑/etc/suricata/suricata.yaml新增一行

suricata编译安装和运行_运维_03

3、

运行suricata,使用af-packet抓包

/usr/bin/suricata -c /etc/suricata/suricata.yaml --af-packet

回放http pcap文件uri中包含suricata字段即可

tcpreplay -i ens160 -M 50  test.pcap

tail -f fast.log,查看日志如下

08/19/2024-05:50:30.126731  [**] [1:3030303:1] Http rule test! [**] [Classification: (null)] [Priority: 3] {TCP} 192.168.1.4:62622 -> 192.168.1.5:8080

3030303就是自定义的规则id

调试

1、开启debug模式

执行configure时需要加上--enable-debug

 ./configure --enable-debug  --enable-nfqueue --prefix=/usr --sysconfdir=/etc --localstatedir=/var

编辑/etc/suricata/suricata.yaml,default-log-level改成debug

suricata编译安装和运行_字段_04

执行: /usr/bin/suricata -c /etc/suricata/suricata.yaml --af-packet,会输出很多debug日志

suricata编译安装和运行_字段_05