How to use Mitmproxy on proxychains - kdaisho/Blog GitHub Wiki
1. Configure Proxychains
Open the configuration file:
sudo nano /etc/proxychains4.conf
Make sure you enable dynamic chain (so it tries multiple proxies if one fails):
dynamic_chain
Disable strict chain (to avoid connection failures when one proxy is down):
# strict_chain
Uncomment DNS leak protection (useful for anonymity):
proxy_dns
Set the proxy at the bottom (e.g., Tor's SOCKS5):
socks5 127.0.0.1 9050
2. Start Tor (If using it)
If you're routing through Tor, make sure it's running:
sudo systemctl start tor
(Optional: Enable Tor on boot)
sudo systemctl enable tor
3. Run Mitmproxy with Proxychains
Now, start Mitmproxy, Mitmweb, or Mitmdump with Proxychains:
Mitmproxy (interactive CLI mode)
proxychains mitmproxy
Mitmweb (GUI mode)
proxychains mitmweb
Mitmdump (headless mode)
proxychains mitmdump
4. Verify traffic is routed through proxy
To confirm Mitmproxy is routing traffic through Proxychains:
- Check Proxychains output – it will show connection attempts.
- Verify your IP using Mitmproxy:
proxychains curl https://check.torproject.org/
If you're using Tor, it should say "Congratulations, your IP is from the Tor network."
5. Capture and Forward Traffic with Mitmproxy
If you need to intercept and analyze traffic, configure your browser or tools to use Mitmproxy as a proxy:
- Set HTTP/HTTPS Proxy to 127.0.0.1:8080
- Install Mitmproxy CA Certificate:
mitmproxy --install
Then, follow the on-screen instructions.
Troubleshooting
If Proxychains fails, try running:
proxychains4 -f /etc/proxychains4.conf mitmproxy
If traffic isn't intercepted, make sure clients are configured to use Mitmproxy (127.0.0.1:8080).
If using Tor, confirm it's running:
systemctl status tor
Now, your Mitmproxy setup should be routing traffic through Proxychains successfully.
Note
I have socks4 127.0.0.1 9050 in the last line of proxychains4.conf. Do I need to change that line? I have no issues running tor with socks4 at all. Do I really need to change to use Tor with MitmProxy?
No, you don’t need to change from SOCKS4 to SOCKS5 if everything is working fine.
Mitmproxy itself doesn’t directly care whether you use SOCKS4 or SOCKS5—it just receives traffic from Proxychains, which handles the proxying. If Proxychains is successfully routing traffic through Tor with SOCKS4, then Mitmproxy will work as expected. When Would You Need to Change?
You might want to switch to SOCKS5 only if:
- Some applications require SOCKS5 (like SSH tunneling).
- You need DNS resolution through Tor (SOCKS4 doesn’t support remote DNS, while SOCKS5 does).
- You experience connection issues with Mitmproxy (unlikely if Proxychains is working fine).
Final Verdict
If you can capture and analyze traffic through Mitmproxy while routing it through Tor without issues, then stick with SOCKS4—no need to change! 🚀