Created
November 26, 2025 17:49
-
-
Save rsp9u/afe5531a595074ba205e18c5f38bf458 to your computer and use it in GitHub Desktop.
mitmproxy works for local process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo su - | |
| # mitmproxyのCA証明書が生成されるディレクトリに移動 | |
| cd /home/mitm/.mitmproxy | |
| # Debian系ではPEM形式からDER形式に変換する必要がある | |
| openssl x509 -in mitmproxy-ca-cert.pem -inform PEM -out mitmproxy-ca-cert.crt | |
| # ディストリのCA証明書ディレクトリに移動させ、証明書をインストール | |
| mv mitmproxy-ca-cert.crt /usr/local/share/ca-certificates/ | |
| update-ca-certificates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # NATテーブルのルールをクリア(Dockerなどが入っていない場合。入っている場合はクリアしない) | |
| sudo iptables -F -t nat | |
| # mitmユーザーのプロセスから出力されるパケットはそのままOUTPUT | |
| sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -m owner --uid-owner $(id -u mitm) -j ACCEPT | |
| # 上記以外のプロセスから出力されるパケットはmitmproxyに流す | |
| sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j REDIRECT --to-ports 8443 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # mitmproxyをインストール | |
| sudo apt-get update | |
| sudo apt-get install mitmproxy | |
| # iptablesでUIDフィルタをするため、専用ユーザーを作って切り替え | |
| sudo useradd -m -s /bin/bash mitm | |
| sudo su - mitm | |
| # mitmproxyを起動 | |
| mitmproxy --mode transparent -p 8443 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wget https://www.google.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment