6.26. Base64关键字¶
Suricata支持从缓冲区解码base64编码的数据,并在解码后的数据上进行匹配。
这是通过使用两个关键字来实现的, base64_decode
和 base64_data
. 必须同时使用这两个关键字才能生成警报。
6.26.1. base64_decode¶
base64使它可以从base64数据缓冲区解码。
语法::
base64_decode:bytes <value>, offset <value>, relative;
这个 bytes
选项指定Suricata应解码多少字节并可用于base64_数据。解码将在缓冲区结束时停止。
这个 offset
选项指定Suricata在解码之前应该跳过多少字节。如果 relative
未设置。
这个 relative
选项使解码相对于上一个内容开始匹配。默认行为是从缓冲区的开始处开始。此选项使 offset
跳过相对于上一个匹配项的字节。
注解
关于 relative
和 base64_decode
:
要解码的相关内容匹配必须是流中的第一个匹配项。
6.26.2. base64_data¶
base64_数据是 sticky buffer
.
对以前由base64u decode解码的数据启用内容匹配。
6.26.3. 例子¶
下面是一个规则匹配的例子,它匹配在HTTPURI缓冲区中的base64编码字符串“test”。
它开始相对于已知字符串“somestring”进行解码,已知偏移量为1。这必须是缓冲区中第一次出现“somestring”。
例子::
Buffer content:
http_uri = "GET /en/somestring&dGVzdAo=¬_base64"
Rule:
alert http any any -> any any (msg:"Example"; http.uri; content:"somestring"; \
base64_decode:bytes 8, offset 1, relative; \
base64_data; content:"test"; sid:10001; rev:1;)
Buffer content:
http_uri = "GET /en/somestring&dGVzdAo=¬_base64"
Rule:
alert http any any -> any any (msg:"Example"; content:"somestring"; http_uri; \
base64_decode:bytes 8, offset 1, relative; \
base64_data; content:"test"; sid:10001; rev:1;)