suricata关键字threshold

Threshold

Threshold(阈值)用来控制规则告警的频率。有三种模式(也叫阈值类型):threshold,limit,both。
阈值的配置又分为规则阈值和全局阈值,本文只讨论规则阈值。

语法:
threshold:  type <threshold|limit|both>,  track <by_src|by_dst|by_rule|by_both>,  count <N>,  seconds <T>

type:threshold
功能:在一个T(seconds)时间窗口内,当规则匹配中N(count)次,就产生一个告警。告警后内部count计数归0,当该时间窗口内再次达到N(count) 次,就会再次告警。

alert tcp !$HOME_NET any -> $HOME_NET 25 (msg:"ET POLICY Inbound Frequent Emails -␣
˓→Possible Spambot Inbound"; \
flow:established; content:"mail from|3a|"; nocase; ␣
˓→ \
threshold: type threshold, track by_src, count 10, seconds 60; ␣
˓→ \
reference:url,doc.emergingthreats.net/2002087; classtype:misc-activity; sid:2002087;␣
˓→rev:10;)

type:limit
功能:在一个T(seconds)时间窗口内,最多产生N(count)次告警。

alert http $HOME_NET any -> any $HTTP_PORTS (msg:"ET USER_AGENTS Internet Explorer 6 in␣
˓→use - Significant Security Risk"; \
flow:to_server,established; content:"|0d 0a|User-Agent|3a| Mozilla/4.0 (compatible|3b|␣
˓→MSIE 6.0|3b|"; \
threshold: type limit, track by_src, seconds 180, count 1; ␣
˓→ \
reference:url,doc.emergingthreats.net/2010706; classtype:policy-violation; sid:2010706;␣
˓→rev:7;)

type:both
功能:在一个T(seconds)时间窗口内,当规则匹配中N(count)次,就产生一个告警。并且在该时间窗口内只产生一次告警。

alert tcp $HOME_NET 5060 -> $EXTERNAL_NET any (msg:"ET VOIP Multiple Unauthorized SIP␣
˓→Responses TCP"; \
flow:established,from_server; content:"SIP/2.0 401 Unauthorized"; depth:24; ␣
˓→ \
threshold: type both, track by_src, count 5, seconds 360; ␣
˓→ \
reference:url,doc.emergingthreats.net/2003194; classtype:attempted-dos; sid:2003194;␣
˓→rev:6;)

track
by_src:追踪源IP地址
by_dst:追踪目的IP地址。
by_both:同时追踪源IP和目的IP地址。
by_rule:追踪规则。

detection_filter

语法:
detection_filter: track <by_src|by_dst|by_rule|by_both>, count <N>, seconds <T>

功能:

在一个T(seconds)时间窗口内,当规则匹配中N(count)次之后,开始产生告警。注意:N次后,每次规则匹配中都产生告警。

alert http $EXTERNAL_NET any -> $HOME_NET any \
(msg:"ET WEB_SERVER WebResource.axd access without t (time) parameter - possible␣
˓→ASP padding-oracle exploit"; \
flow:established,to_server; content:"GET"; http_method; content:"WebResource.axd";␣
˓→http_uri; nocase; \
content:!"&t="; http_uri; nocase; content:!"&amp|3b|t="; http_uri; nocase; ␣
˓→ \
detection_filter:track by_src,count 15,seconds 2; ␣
˓→ \
reference:url,netifera.com/research/; reference:url,www.microsoft.com/technet/
˓→security/advisory/2416728.mspx; \
classtype:web-application-attack; sid:2011807; rev:5;)

浅谈suricata中threshold源码实现:

数据结构:以by_src/by_dst构建了一个哈希表。以by_both构建第二个哈希表。by_rule采用数组线性表。

实现: 当第一个命中规则告警包来时,构建结点并记录此时第一个包的时间和命中的规则的seconds(时间窗口),并且结点上的count++,插入哈希表。
        后续再来此规则告警包时判断条件:  包时间 <= 第一个包时间 + seconds。如果成立说明该包在一个时间窗口内,count++。并对count进行判断决定是否告警。
        另创建一个线程,起计时器作用。该线程负责查看哈希表中的结点是否未在使用且已经超过时间窗口,超过则摘除结点。


 

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值