【发布时间】:2018-08-14 13:31:40
【问题描述】:
我正在尝试实现一个 mitmproxy 插件脚本,以篡改特定的 https 数据包数据 - 这是通过 mitmproxy 的证书注入动态解密的方式。
我正在关注这个Stack Overflow answer 到一个相当相似的问题,以及来自 mitmproxy 文档的this tutorial,但到目前为止没有任何成功。
我要定位的数据包来自https://api.example.com/api/v1/user/info。
现在这是我编写的用于篡改此数据包数据的整个 python 脚本,基于上述来源:
from mitmproxy import ctx
class RespModif:
def _init_(self):
self.num = 0
def response(self, flow):
ctx.log.info("RespModif triggered")
if flow.request.url == "https://api.example.com/api/v1/user/info":
ctx.log.info("RespModif triggered -- In the if statement")
self.num = self.num + 1
ctx.log.info("RespModif -- Proceeded to %d response modifications "
"of the targetted URLs" % self.num)
addons = [
RespModif()
]
检查事件日志,我可以看到第一个日志信息(“RespModif 触发”)正在报告到日志中,但另外两个日志信息(从内部完成) if 语句)从未被报告,这意味着我认为if 语句永远不会成功。
我的代码有问题吗?
如何让if 语句成功?
PS:目标 URL 绝对正确,而且我正在使用它与来自客户端应用程序的注册帐户一起使用,该应用程序正在被 mitmproxy 嗅探。
【问题讨论】:
标签: python linux packet-capture mitmproxy tampering