在base64decode之后使用requestBodyProcessor

发布于 2025-01-31 04:04:34 字数 329 浏览 5 评论 0原文

ModSecurity允​​许我们使用不同的请求车身处理器(例如XML或JSON)。我的问题是,是否有可能首先解码一个容纳base64编码的字符串

eyjuyw1lijoism9obiisicjhz2uioji1fq ==

转化为

> {“ name”:“ name”:“ john”,“ age”:25} <“:25} < ”: /code>

之后使用requestbodyProcessor = JSON

我尝试了不同的转换规则,依此类推,但无法正常工作。

ModSecurity allows us to use different request body processors (e.g. for XML or JSON). My question is, is it possible to first decode a body that holds a base64 encoded string

eyJuYW1lIjoiSm9obiIsICJhZ2UiOjI1fQ==

which translates to

{"name":"John", "age":25}

and after that use requestBodyProcessor=JSON?

I tried different rules with transformations and so on, but couldn't get it to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜妞爱困 2025-02-07 04:04:34

不幸的是,这是不可能的,因为:

  • 需要在第1阶段中激活车身处理器,
  • 在第2阶段开始时填充了任何以后的phoes request_body变量,因此在第1阶段无法访问它

。为了实现所需的目标,但使用解析的JSON数据与现有规则兼容,这是有点复杂的,而不是向后兼容。您可以执行此操作:

  • 禁用JSON Body处理器
  • 创建新规则,该规则在第2阶段开始时运行(在所有其他规则之前),并且运行LUA脚本
  • 创建一个LUA脚本,该脚本首先从Request_body解码base64数据,然后在上运行JSON PARSER它并最终通过TX Collection中的某些变量暴露了分析的数据

Unfortunately, this isn't possible, because:

  • body processor needs to be activated in phase 1, this cannot by done in any later phase
  • REQUEST_BODY variable is populated at the start of phase 2 so it's not accessible in phase 1

There IS a way how to achieve what you need but it's a little complex and not backward compatible with existing rules using parsed JSON data. You can do this:

  • disable JSON body processor
  • create new rule which runs at the beginning of phase 2 (before all other rules) and which runs a Lua script
  • create a Lua script which first decodes base64 data from REQUEST_BODY, then runs a JSON parser on it and finally expose parsed data via some variable in TX collection
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文