The quiter you become,the more you are able to hear!

suricata 规则之 IP Keywords

Author: geneblue

Blog: https://geneblue.github.io/

指定为 ip 协议时的一些规则项字段

IP Keywords

ttl

ttl 用于指定 ip 包的最大存活时间,可以指定想匹配的 ttl 时间,比如:

1
ttl:10;

ipopts

对 ip 协议比较熟悉的话,会知道 ip 包中会有一些 options 项,可以设定指定项来匹配指定的 ip 包:

IP Option Description
rr Record Route
eol End of List
nop no Op
ts time stamp
sec ip Security
esec IP Extended Security
lsrr Loose Source Routing
ssrr Strict Source Routing
satid Stream Identifier
any any Ip options are set

例如:

1
ipopts: lsrr;

sameip

sameip 关键字用于匹配源 IP 和目的 IP 相同的包:

1
sameip;

ip_proto

ip_proto 关键字可用于匹配包头中的 ip 协议,检测基于 ip 协议的其他协议,比如 TCP 协议在 IP header 中的协议号是 6。完整的协议号列表可以参见 https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers. 可以指定协议号,也可以指定协议名缩写,比如:

1
2
ip_proto:6;
ip_proto:TCP;

id

id 指定匹配 IP 协议中 Identification 项的数值,比如:

1
id:1;

geoip

geoip 关键字用于匹配源ip,目的 ip,或者两者的 ip 归属地,suricata 使用 MaxMind 的 GeoIP2 api:

1
2
3
4
5
geoip: src,RU;
geoip: both,CN,RU;
geoip: dst,CN,RU,IR;
geoip: both,US,CA,UK;
geoip: any,CN,IR;

使用 api 需要编译 libmaxminddb,详情见文档。

fragbits

fragbits 关键字匹配 ip header 中的flags,搭配 fragoffset 关键字使用,这个使用频率应该比较低,详情见文档

tos

匹配 ip header 中的 tos 字段

参考