gpt4 book ai didi

python - Mitmproxy,推送自己的WebSocket消息

转载 作者:行者123 更新时间:2023-12-04 17:48:17 31 4
gpt4 key购买 nike

我使用 Mitmproxy 检查 HTTPS WebSocket 流量。目前我可以阅读/编辑 WS 消息:

class Intercept:
def websocket_message(self, flow):
print(flow.messages[-1])

def start():
return Intercept()

.. 作为 Mitmproxy 的附加脚本。

如何向客户端推送/注入(inject)我自己的消息?不编辑现有消息,而是添加新消息。

最佳答案

您可以使用 inject.websocket 执行此操作:

from mitmproxy import ctx

class Intercept:
def websocket_message(self, flow):
print(flow.messages[-1])
to_client = True
ctx.master.commands.call("inject.websocket", flow, to_client, b"Hello World!", True)

def start():
return Intercept()

more examples在文档中。

关于python - Mitmproxy,推送自己的WebSocket消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47205568/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com