|
| 1 | +## mitmproxy-tools |
| 2 | + |
| 3 | +List of generic mitmproxy scripts I use while working on various researches, pentests and bug bounties. |
| 4 | + |
| 5 | +Previously |
| 6 | + |
| 7 | +* I wrote a blog post about my [mitmproxy + openvpn](https://blog.flatt.tech/entry/mitmproxy) setup at my former workpace. |
| 8 | +* then I wrote another [mitmproxy + openvpn](https://gist.github.com/stypr/abe9ef83556759847c063ae9389fa0ae) setup to show the current setup |
| 9 | + |
| 10 | +What has been changed this time |
| 11 | + |
| 12 | +* Directory structures have been changed for convenient addons |
| 13 | + - `views/*` can be used to auto decrypt some of request/response data for better visuals |
| 14 | + - `addons/*` can be used to work like plugins to do actions upon send/receive. |
| 15 | + |
| 16 | +* Replacing openvpn setups to wireguard setups |
| 17 | + - When upstream SOCK5 proxy only supports TCP, UDP packets have to be passed through somehow. |
| 18 | + 1. Unfortunately, transparent proxy will not pass UDP packets, while the wireguard mode does support DNS and UDP packet mitm. |
| 19 | + - Setups are much simpler than typical openvpn setup. |
| 20 | + - Reference: https://mitmproxy.org/posts/wireguard-mode/ |
| 21 | + - There are still some limitations like lack of handling for HTTP2 and HTTP3, but we can still use the old HTTPS. |
| 22 | + |
| 23 | +Feel free to contribute if you have any interesting addons/views to share. |
| 24 | + |
| 25 | +### Installations |
| 26 | + |
| 27 | +#### Summary |
| 28 | + |
| 29 | +Most of them are same as [the gist version](https://gist.github.com/stypr/abe9ef83556759847c063ae9389fa0ae), except that you don't have to install OpenVPN anymore. |
| 30 | + |
| 31 | +1. Install `wireguard` on your system (`apt install -y wireguard`) |
| 32 | + |
| 33 | +2. `bind9` is not needed anymore. Also, [mitmproxy now has its own way to handle DNS manipulations now](https://github.com/Kriechi/mitmproxy/blob/dns-addon/docs/src/content/overview-features.md#dns-manipulation). |
| 34 | + |
| 35 | +2. Install [Caddy](https://caddyserver.com/docs/install) |
| 36 | + |
| 37 | +3. Add passwords on [caddy/Caddyfile](caddy/Caddyfile) using `caddy hash-password`, move files to `/etc/caddy` |
| 38 | + |
| 39 | +4. Install mitmproxy to latest |
| 40 | +```sh |
| 41 | +apt install -y python3-pyasn1 python3-flask python3-dev python3-urwid python3-pip libxml2-dev libxslt-dev libffi-dev |
| 42 | +pip3 install -U mitmproxy --break-system-packages |
| 43 | +mitmproxy --version |
| 44 | +``` |
| 45 | + |
| 46 | +5. The script proxies through upstream [WARP](https://one.one.one.one/) by default. |
| 47 | + You might want to install or make appropriate changes to the script. |
| 48 | + |
| 49 | +6. Once everything is done, `screen ./run.sh` |
| 50 | + |
| 51 | +#### Installing WARP on Linux |
| 52 | + |
| 53 | +1. Install WARP CLI. |
| 54 | + |
| 55 | +```sh |
| 56 | +curl https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg |
| 57 | +echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ bookworm main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list |
| 58 | +sudo apt update && sudo apt install -y cloudflare-warp |
| 59 | +``` |
| 60 | + |
| 61 | +2. Register WARP, set proxy with appropriate ports, start proxy. |
| 62 | + |
| 63 | +```sh |
| 64 | +warp-cli register |
| 65 | +warp-cli proxy port 40000 |
| 66 | +warp-cli mode proxy |
| 67 | +warp-cli connect |
| 68 | +``` |
0 commit comments