V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hack2xia
V2EX  ›  信息安全

suricata http.request_body 和 http_client_body 的区别?

  •  
  •   hack2xia · 2023-01-03 16:39:29 +08:00 · 864 次点击
    这是一个创建于 480 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我现在的工作是写入侵检测规则,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 。 不知道我的理解对不对?

    5 条回复    2023-01-03 17:31:04 +08:00
    lambdaq
        1
    lambdaq  
       2023-01-03 17:01:13 +08:00
    盲猜一个解码了一个没解码
    daxin945
        2
    daxin945  
       2023-01-03 17:11:45 +08:00
    抛转引玉了
    我个人理解 是不同的 suricata 版本支持的 Snort 规则版本不同 本质上都是指的请求体 但是具体的细节没太抠过
    在实际写 Snort 的时候 我习惯于用 http_client_body suricata 版本 6.0.4
    hack2xia
        3
    hack2xia  
    OP
       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
        5
    hack2xia  
    OP
       2023-01-03 17:31:04 +08:00   ❤️ 1
    上面链接的问题,看到有人回答:
    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
    从他的意思来看,我的理解应该没问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   900 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:02 · PVG 06:02 · LAX 15:02 · JFK 18:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.