Help with mitmproxy nft table rules listening port 8080

Hello, I been trying to set up mitmproxy to monitor qube connections. I’ve followed this guide but im stuck on the iptable part

    sudo iptables -t nat -A PR-QBS -i vif+ -p tcp --dport 80 -j REDIRECT --to-port 8080
    sudo iptables -t nat -A PR-QBS -i vif+ -p tcp --dport 443 -j REDIRECT --to-port 8080
    sudo iptables -t filter -I INPUT -i vif+ -p tcp -m tcp --dport 8080 -j ACCEPT

I have mitmproxy installed but i cant use iptables and i don’t know how to do it properly with nft rules. So how could i go about setting this up?

2 Likes

I’m very new with nftables too and maybe someone who actually understands something can help but in a meanwhile it might go something like this:

sudo nft add chain qubes nat { type nat hook prerouting priority dstnat; }
sudo nft add rule qubes custom-input tcp dport {80,443} accept
sudo nft add rule qubes nat tcp dport 8080

1 Like
#!/usr/sbin/nft -f
add table mitm
add chain mitm mitm { type nat hook prerouting priority -190  ; }
add rule mitm mitm tcp dport  { http, https } counter redirect to :8080
add rule qubes custom-input tcp dport 8080 counter accept

Save this as mitm.nft, make it executable.

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

1 Like

How would i run it in terminal? also do i add both http ports in the brackets {80,443}?
i made the file but i don’t know how to make it an executable. How would i do it in terminal?

1 Like

Alright its working now thanks. How can i make the script automatic every time i start the netvm(sys-mitm)

1 Like