suricata 7.0.5
suricata rule由三部分组成, action, header, options
action,决定当前规则匹配上后需要执行的动作header,定义当前规则的协议,IP地址,端口,方向options,定义了具体的规则
一、 action
合法的action值有:
alert, 产生告警drop, 丢弃包并且产生告警reject,发送rst或icmp 不可达消息给当前匹配上包的源rejectsrc, 和reject一样rejectdst, 发送rst或icmp不可达消息给当前匹配上包的目的rejectboth,给两端同时发送rst或icmp不可达消息
二、 header
protocol + source ip + source port + direction + destination ip + destination port
2.1 Protocol
指定当前规则处理的什么协议。
基础协议:
- tcp
- udp
- icmp
- ip
已经支持的应用层协议: - http1
- http2
- ftp
- tls
- dns
- dcerpc
- dhcp
- ssh
- smtp
- imap
…
2.2 Source, Destination
../..,定义网段[...,...,...],定义多个IP!可以对上面的进行取反,即排除$VAR, 可以通过提前定义变量,然后使用变量表示地址any, 表示所有地址
| 例子 | 说明 |
|---|---|
| !1.1.1.1 | 排除1.1.1.1后剩余的所有地址 |
| ![1.1.1.1, 1.1.1.2] | 排除1.1.1.1和1.1.1.2后剩余的所有地址 |
| $HOME_NET | 提取HOME_NET的值 |
| [10.0.0.0/24, !10.0.0.5] | 排除10.0.0.5后的10.0.0.0/24网段 |
2.3 Port
:, 表示范围[...,...],多个端口!排除端口$VAR从变量中获取端口
| 例子 | 说明 |
|---|---|
| [80, 81, 82] | 端口80,81,82 |
| [80:82] | 80到82直接的端口 |
| [1024:] | 1024到最大端口 |
| [80:100,!99] | 80到100,排除99 |
| [1:80,![2,4]] | 1到80,排除2,4 |
2.3 Direction
source -> destination 单向匹配
source <> destiantion 双向匹配
三、 options
( keyword:settings;keyword; )
alert http any any -> $HOME_NET any (msg:“noalert example: set state”; flow:established,to_server; xbits:set,SC.EXAMPLE,track ip_dst, expire 10; noalert; http.method; content:“GET”; sid:1; )
参考: https://docs.suricata.io/en/latest/rules/intro.html