Mitmproxy Transparent mode not working


#1

Hi guys,

I’m trying to set up a mitmproxy in transparent mode following the instructions from the official-doc howto-transparent but is not working.

I want to set mitmproxy in transparent mode to avoid any client configuration and forward all HTTP traffic to my proxy server.

My interfaces:

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::6774:861b:f4e:c9e3  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:fa:5c:69  txqueuelen 1000  (Ethernet)
        RX packets 12666  bytes 10589141 (10.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5967  bytes 404489 (404.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 153  bytes 13996 (13.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0

After setting the rules:

sudo iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 443 -j REDIRECT --to-port 8080

My nat table from iptables:

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80 redir ports 8080
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443 redir ports 8080

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination

Problem: When I run mitmproxy --mode transparent --showhost and execute a curl or load a page in the browser, the HTTP traffic is not captured by mitmproxy.

Any help?