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