Snort规则中的逻辑关系

0x01

看一条规则
alert tcp any any -> any any (content:"union";http_uri;nocase;content:"select":nocase;http_uri;)
下面这两条会触发哪一条?
http://foo.com?id=union select
http://foo.com?id=select union
实验结果是都会触发。
这个实验说明content如果不加distance之类的修饰符的话,多个content匹配是没有顺序的。

0x02

再看一条规则
alert tcp any any -> any any (content:"union";http_uri;nocase;content:"select":nocase;http_uri; pcre:"/union\s+(all\s+)?select\s+/Ui";)
还是这两条规则:
http://foo.com?id=union select
http://foo.com?id=select union
实验结果是只会触发第一条。
这说明,不同关键词之间(比如content和pcre)是“逻辑与”的关系。

0x03

最后一条规则
alert tcp any any -> any any (content:"union";http_uri;nocase;content:"s3l3ct":nocase;http_uri; pcre:"/union\s+(all\s+)?select\s+/Ui";)
发现上面两条都匹配不到了,说明所有关键词之间都是“逻辑与”的关系。



文/小天是我见过最单纯善良的人(简书作者)
原文链接:http://www.jianshu.com/p/9d11a3e039e9
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
posted @ 2016-09-26 16:53  godjob  Views(2215)  Comments(0Edit  收藏  举报