I inspect a HTTPS WebSocket traffic with Mitmproxy. Currently I can read/edit WS messages with:
class Intercept:
def websocket_message(self, flow):
print(flow.messages[-1])
def start():
return Intercept()
.. as attached script to Mitmproxy.
How do I push/inject my own message to the client? Not edit existing one, but add a new message.
You can do this with 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()
There are more examples in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With