Created
March 2, 2026 21:18
-
-
Save dstd/b6f09ce8a4215eeefdaa3e1775ae90ea to your computer and use it in GitHub Desktop.
[mitmproxy][dirtyhack] Fixed version of flow.kill that really terminates the connections, rather just marking flows as killed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Managed to workaround my problem via a dirty hack. | |
| # Not quite good, but it works and solves my daily tasks. | |
| class FlowKillFix: | |
| def kill_flow(self, flow): | |
| server = ctx.master.addons.get("proxyserver") | |
| conn = flow.client_conn | |
| handler = server.connections.get(conn.id) | |
| dropped = [] | |
| if handler is not None: | |
| handler.close_connection(conn, False) | |
| dropped.append("client") | |
| conn = flow.server_conn | |
| handler = server.connections.get(conn.id) | |
| if handler is not None: | |
| handler.close_connection(conn, False) | |
| dropped.append("server") | |
| if len(dropped) > 0: | |
| ctx.log.alert(f"dropped {"-".join(dropped)} for {flow.request.url}") | |
| else: | |
| ctx.log.error(f"dropped nothing for {flow.request.url}") | |
| @command.command("flow.drop") | |
| def flow_drop(self, flows: Sequence[flow.Flow]) -> None: | |
| for f in flows: | |
| if isinstance(f, http.HTTPFlow): | |
| self.kill_flow(f) | |
| else: | |
| ctx.log.error(f"skipped non-http {f}") | |
| addons = [FlowKillFix()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Kill focused flow by Ctrl+K with confirmation of operation by Enter | |
| - | |
| ctx: ["flowlist","flowview"] | |
| key: ctrl k | |
| cmd: console.command flow.drop @focus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment