Injecting TCP and WebSocket messages in mitmproxy
Sometimes when intercepting a connection using mitmproxy, you need to send data back to the server. https://github.com/mitmproxy/mitmproxy/discussions/6855 As i
Sometimes when intercepting a connection using mitmproxy, you need to send data back to the server.
https://github.com/mitmproxy/mitmproxy/discussions/6855
As in the issue above,
ctx.master.commands.call("inject.tcp", flow, True, b"I was injected")
you need to use this method.
For TCP, use inject.tcp
For WebSocket, use inject.websocket
You can send it using these.
If you need to send it over WebSocket (client -> server), use it as shown in the code below.
ctx.master.commands.call("inject.websocket", flow, False, {"type": "register"})
The third argument indicates whether Server -> Client.