quick transparent mitmproxy on docker

Getting Started

#!/bin/sh

set -x

iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8080

docker run --rm -it --network host -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy mitmproxy/mitmproxy mitmweb --web-host 0.0.0.0 --mode transparent --showhost

iptables -t nat -D PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -D PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8080

Additional Steps

  • Change default gateway to the box running the mitmproxy or run mitmproxy on the gateway itself.
  • Go to mitm.it, install the certificate.

Enjoy mitmproxy running on the box:8081.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.