Man-in-the-Middle (mitm) Proxy
This thing is fantastic: Man in the Middle Proxy. It focuses a little higher in the network stack than tools like Wireshark and gives you insight about the traffic to and from your computer. It can be set up to decrypt the data so you can see exactly what is being sent and received.
You can think of it as a computer-wide version of dev-tools/network tab. I find it interesting to see what is going on, and it can be valuable debugging as well.
Install (Mac)
brew install mitmproxy
Command Line
mitmproxy --listen-host 0.0.0.0 --listen-port=8090 --set confdir=~/.mitmproxy/
UI
mitmweb --web-host 0.0.0.0 --listen-port=8090 --set web_port=8083
Note: it will start the proxy too ^^^
Certs
Go to: http://mitm.it/, Download for your platform.
Install (Mac)
sudo security add-trusted-cert -d -p ssl -p basic -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem
To Make it "Always Trust" (Mac)
- Use spotlight to search for "Keychain Access".
- In the left sidebar, pick System → Certificates.
- Find mitmproxy root cert you downloaded.
- Double-click it, then expand Trust section.
- Change “When using this certificate” to Always Trust.
- Close and confirm.
You can also watch this video about it.
Setting up the Proxy (Mac)
There are UI methods, but this is more reliable.
networksetup -listallnetworkservices
Look for your network. Mine was "Wi-Fi". Above, when starting mitmproxy, I chose to use port 8090 for mitmproxy to listen. Now, I'm routing network activity from my computer through it:
networksetup -setwebproxy "Wi-Fi" 127.0.0.1 8090
networksetup -setsecurewebproxy "Wi-Fi" 127.0.0.1 8090
I can turn on and off the proxy using these commands:
networksetup -setwebproxystate "Wi-Fi" on
networksetup -setsecurewebproxystate "Wi-Fi" on
networksetup -setwebproxystate "Wi-Fi" off
networksetup -setsecurewebproxystate "Wi-Fi" off