Thanks for stopping by IRC today. I followed this up, and the main problem is that rdr rules apply to inbound traffic. This means that they will NOT redirect traffic coming from the window itself. If you think about it, it is inevitable: we cannot distinguish an outgoing connection from a non-mitmproxy application and an outgoing connection from mitmproxy itself. We can use route-to to send traffic to lo0 and then redirect it, but this causes an endless loop in which mitmproxy's own outgoing connections are also redirected back to mitmproxy.
Since I am a little versed in your use case, I would suggest exploring ways to do this with VirtualBox. The attack plan would be to install the VirtualBox network in bridge mode, and then use the pf rule with a match on the source address to redirect traffic to mitmproxy. This should do what you want, and not cause a singularity in time and space due to infinite redirection.
Please re-launch the IRC channel if you need further hand.
cortesi
source share