suricata http.request_body 和 http_client_body 的区别?

2023-01-03 16:39:29 +08:00
 hack2xia

我现在的工作是写入侵检测规则,suricata 关于 http 协议关键字部分也好好看了,但依然有问题不太懂。 官方手册 v6.0.9 中章节 6.12.20 中指出: http.request_body replaces the previous keyword name: http_client_body. You may continue +to use the previous name, but it’s recommended that rules be converted to use +the new name. 实际上,我测试了一下,似乎不能直接替代:

# 没问题
alert http any any -> any any (msg:"Victure WR1200 系统命令执行漏洞 (CVE-2021-43283)"; flow:to_server,established; content:"password="; http_client_body; nocase; sid:650013; rev:1; gid:879013; priority:4;)

# 单纯只是把上面的 http_client_body 替换成了 http.request_body 报 error:nocase needs preceding content option
# 翻译过来是:nocase 需要前面的内容选项
alert http any any -> any any (msg:"Victure WR1200 系统命令执行漏洞 (CVE-2021-43283)"; flow:to_server,established; content:"password="; http.request_body; nocase; sid:650014; rev:1; gid:879014; priority:4;)

# 如果把 nocase 放到 content 的后面。报 error:rule 650015 setup buffer http_client_body but didn't add matches to it
# 翻译过来是:规则 650015 设置缓冲区 http_client_body 但没有添加匹配项
alert http any any -> any any (msg:"Victure WR1200 系统命令执行漏洞 (CVE-2021-43283)"; flow:to_server,established; content:"password="; nocase; http.request_body; sid:650015; rev:1; gid:879015; priority:4;)

# 如果把 http.request_body 放到 content 的前面,无报错
alert http any any -> any any (msg:"Victure WR1200 系统命令执行漏洞 (CVE-2021-43283)"; flow:to_server,established; http.request_body; content:"password="; nocase; sid:650016; rev:1; gid:879016; priority:4;)

所以,我感觉 http_client_body 是 content modifier ,而 http.request_body 是 sticky buffer 。 不知道我的理解对不对?

880 次点击
所在节点    信息安全
5 条回复
lambdaq
2023-01-03 17:01:13 +08:00
盲猜一个解码了一个没解码
daxin945
2023-01-03 17:11:45 +08:00
抛转引玉了
我个人理解 是不同的 suricata 版本支持的 Snort 规则版本不同 本质上都是指的请求体 但是具体的细节没太抠过
在实际写 Snort 的时候 我习惯于用 http_client_body suricata 版本 6.0.4
hack2xia
2023-01-03 17:21:13 +08:00
我也主要用的 http_client_body 。
但有时候可能会有点问题,比如:
content:"balabala";http_client_body;pcre:/<regex>/iPR;
由于 R 的存在,它类似于 distance:0 ,pcre 这里要和前面在同一个 sticky buffer 。上面的规则会报错。
http.request_body;content:"balabala";pcre:/<regex>/iPR;
则不会报错。
当然,不写 R 应该是没问题的。
hack2xia
2023-01-03 17:27:04 +08:00
hack2xia
2023-01-03 17:31:04 +08:00
上面链接的问题,看到有人回答:
Removed 'http_client_body' because we have 'http.request_body' in Suricata 5.0. Also, if you did want to use 'http_client_body', it would come after the content in which you're hoping to match. 'http.request_body' is a sticky buffer so all content following it are considered to be part of that buffer
从他的意思来看,我的理解应该没问题

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/906295

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX