jpskill.com
🛠️ 開発・MCP コミュニティ

api-mitmproxy

APIのセキュリティテストで、HTTP/HTTPS通信を傍受・改変・再現し、挙動を検証したり、モバイルアプリの通信をデバッグしたり、Pythonスクリプトで自動化したりできる、インタラクティブなHTTPSプロキシとして活用するSkill。

📜 元の英語説明(参考)

Interactive HTTPS proxy for API security testing with traffic interception, modification, and replay capabilities. Supports HTTP/1, HTTP/2, HTTP/3, WebSockets, and TLS-protected protocols. Includes Python scripting API for automation and multiple interfaces (console, web, CLI). Use when: (1) Intercepting and analyzing API traffic for security testing, (2) Modifying HTTP/HTTPS requests and responses to test API behavior, (3) Recording and replaying API traffic for testing, (4) Debugging mobile app or thick client API communications, (5) Automating API security tests with Python scripts, (6) Exporting traffic in HAR format for analysis.

🇯🇵 日本人クリエイター向け解説

一言でいうと

APIのセキュリティテストで、HTTP/HTTPS通信を傍受・改変・再現し、挙動を検証したり、モバイルアプリの通信をデバッグしたり、Pythonスクリプトで自動化したりできる、インタラクティブなHTTPSプロキシとして活用するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o api-mitmproxy.zip https://jpskill.com/download/17019.zip && unzip -o api-mitmproxy.zip && rm api-mitmproxy.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17019.zip -OutFile "$d\api-mitmproxy.zip"; Expand-Archive "$d\api-mitmproxy.zip" -DestinationPath $d -Force; ri "$d\api-mitmproxy.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して api-mitmproxy.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → api-mitmproxy フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
5

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

mitmproxy API セキュリティテスト

概要

mitmproxy は、ペネトレーションテスターや開発者向けの、インタラクティブで TLS 対応の HTTP プロキシです。API、モバイルアプリ、シッククライアントを含む HTTP/HTTPS トラフィックのリアルタイムな検査、変更、リプレイを可能にします。HTTP/1、HTTP/2、HTTP/3、および WebSockets をサポートすることで、mitmproxy は最新の API セキュリティテストのための包括的なカバレッジを提供します。

インターフェース

mitmproxy - キーボードナビゲーションを備えたインタラクティブなコンソールインターフェース mitmweb - 視覚的なトラフィック検査のための Web ベースの GUI mitmdump - 自動化されたトラフィックキャプチャとスクリプト作成のためのコマンドラインツール

クイックスタート

mitmproxy をインストールして実行します。

# pip 経由でインストール
pip install mitmproxy

# インタラクティブなコンソールプロキシを開始
mitmproxy

# Web インターフェースを開始 (デフォルト: http://127.0.0.1:8081)
mitmweb

# 出力付きのコマンドラインプロキシを開始
mitmdump -w traffic.flow

クライアントがプロキシを使用するように設定します (デフォルト: localhost:8080)

コアワークフロー

ワークフロー 1: インタラクティブな API トラフィック検査

手動の API セキュリティテストと分析の場合:

  1. mitmproxy または mitmweb を起動します。

    # コンソールインターフェース
    mitmproxy --mode regular --listen-host 0.0.0.0 --listen-port 8080
    
    # または Web インターフェース
    mitmweb --mode regular --listen-host 0.0.0.0 --listen-port 8080
  2. ターゲットアプリケーションがプロキシを使用するように設定します (HTTP: localhost:8080)

  3. クライアントデバイスに mitmproxy CA 証明書をインストールします

  4. アプリケーションから API リクエストをトリガーします

  5. mitmproxy でリクエスト/レスポンスをインターセプトして検査します

  6. リクエストを変更して以下をテストします。

    • 認証バイパスの試み
    • 認可の欠陥 (IDOR、権限昇格)
    • 入力検証 (SQLi、XSS、コマンドインジェクション)
    • ビジネスロジックの脆弱性
  7. ドキュメント化とレポート作成のためにフローを保存します

ワークフロー 2: モバイルアプリの API セキュリティテスト

進捗状況: [ ] 1. モバイルデバイスに mitmproxy CA 証明書をインストールします [ ] 2. デバイスの WiFi が mitmproxy をプロキシとして使用するように設定します [ ] 3. 視覚的なトラフィック検査のために mitmweb を起動します [ ] 4. モバイルアプリを起動し、すべての機能を実行します [ ] 5. API エンドポイント、認証メカニズム、データフローを確認します [ ] 6. 一般的な API 脆弱性 (OWASP API Top 10) をテストします [ ] 7. さらなる分析のためにトラフィックを HAR としてエクスポートします [ ] 8. リクエスト/レスポンスの例とともに調査結果を文書化します

各ステップを体系的に実行します。完了した項目をチェックします。

ワークフロー 3: 自動化された API トラフィック記録

大規模な API トラフィックのキャプチャと分析の場合:

  1. フローキャプチャで mitmdump を起動します。

    mitmdump -w api-traffic.flow --mode regular
  2. 自動テストまたは手動アプリ操作を実行します

  3. mitmdump を停止 (Ctrl+C) してフローを保存します

  4. キャプチャされたトラフィックをリプレイします。

    # サーバーにリプレイ
    mitmdump -nc -r api-traffic.flow
    
    # スクリプトによる変更を加えてリプレイ
    mitmdump -s replay-script.py -r api-traffic.flow
  5. 分析のために HAR 形式にエクスポートします。

    # Python API を使用
    python3 -c "from mitmproxy.io import FlowReader; from mitmproxy.tools.dump import DumpMaster;
    import sys; [print(flow.request.url) for flow in FlowReader(open('api-traffic.flow', 'rb')).stream()]"

ワークフロー 4: API テストのための Python スクリプト

カスタムロジックを使用した自動化されたセキュリティテストの場合:

  1. Python アドオン スクリプトを作成します (api-test.py):

    from mitmproxy import http
    
    class APISecurityTester:
        def request(self, flow: http.HTTPFlow) -> None:
            # リクエストをオンザフライで変更
            if "api.example.com" in flow.request.pretty_url:
                # 認証バイパスをテスト
                flow.request.headers["X-User-ID"] = "1"
    
        def response(self, flow: http.HTTPFlow) -> None:
            # レスポンスを分析
            if flow.response.status_code == 200:
                if "admin" in flow.response.text:
                    print(f"[!] Potential privilege escalation: {flow.request.url}")
    
    addons = [APISecurityTester()]
  2. スクリプトを使用して mitmproxy を実行します。

    mitmproxy -s api-test.py
    # または自動化の場合
    mitmdump -s api-test.py -w results.flow
  3. 自動化された調査結果とキャプチャされたトラフィックを確認します

  4. レポート作成のために結果をエクスポートします

ワークフロー 5: SSL/TLS 証明書ピンニングバイパス

証明書ピンニングを使用するモバイルアプリのテストの場合:

  1. デバイスに mitmproxy CA 証明書をインストールします
  2. 証明書のアンピンニングツールまたはフレームワークの変更を使用します。
    • Android: SSL アンピンニング用の Frida スクリプト
    • iOS: SSL Kill Switch または同様のツール
  3. mitmproxy を介してアプリのトラフィックを設定します
  4. または、リバースプロキシモードを使用します。
    mitmproxy --mode reverse:https://api.example.com --listen-host 0.0.0.0 --listen-port 443
  5. /etc/hosts を変更して、API ドメインを mitmproxy にリダイレクトします
  6. 通常どおりにトラフィックをインターセプトして分析します

動作モード

mitmproxy は複数のデプロイメントモードをサポートしています。

通常プロキシモード (デフォルト):

mitmproxy --mode regular --listen-port 8080

クライアントはプロキシ設定を明示的に構成します。

透過プロキシモード (クライアントには見えません):

mitmproxy --mode transparent --listen-port 8080

トラフィックをリダイレクトするには、iptables/pf ルールが必要です。

リバースプロキシモード (サーバーの前に配置):

mitmproxy --mode reverse:https://api.example.com --listen-port 443

mitmproxy はサーバーエンドポイントとして機能します。

アップストリームプロキシモード (プロキシをチェーン):

mitmproxy --mode upstream:http://corporate-proxy:8080

別のプロキシを介してトラフィックをルーティングします。

証明書のインストール

HTTPS インターセプトのために mitmproxy CA 証明書をインストールします。

ブラウザ/デスクトップ:

  1. mitmproxy を起動し、プロキシ設定を構成します
  2. http://mitm.it にアクセスします
  3. プラットフォーム用の証明書をダウンロードします
  4. システム/ブラウザの証明書ストアにインストールします

Android:

  1. 証明書をデバイスにプッシュします: adb push ~/.mitmproxy/mitmproxy-ca-cert.cer /sdcard/
  2. 設定 → セキュリティ → SD カードからインストール
  3. mitmproxy 証明書を選択します

iOS:

  1. 証明書をメールで送信するか、Web サーバーでホストします
  2. デバイスにプロファイルをインストールします
  3. 設定 → 一般 → 情報 → 証明書信頼
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

mitmproxy API Security Testing

Overview

mitmproxy is an interactive, TLS-capable intercepting HTTP proxy for penetration testers and developers. It enables real-time inspection, modification, and replay of HTTP/HTTPS traffic including APIs, mobile apps, and thick clients. With support for HTTP/1, HTTP/2, HTTP/3, and WebSockets, mitmproxy provides comprehensive coverage for modern API security testing.

Interfaces

mitmproxy - Interactive console interface with keyboard navigation mitmweb - Web-based GUI for visual traffic inspection mitmdump - Command-line tool for automated traffic capture and scripting

Quick Start

Install and run mitmproxy:

# Install via pip
pip install mitmproxy

# Start interactive console proxy
mitmproxy

# Start web interface (default: http://127.0.0.1:8081)
mitmweb

# Start command-line proxy with output
mitmdump -w traffic.flow

Configure client to use proxy (default: localhost:8080)

Core Workflows

Workflow 1: Interactive API Traffic Inspection

For manual API security testing and analysis:

  1. Start mitmproxy or mitmweb:

    # Console interface
    mitmproxy --mode regular --listen-host 0.0.0.0 --listen-port 8080
    
    # Or web interface
    mitmweb --mode regular --listen-host 0.0.0.0 --listen-port 8080
  2. Configure target application to use proxy (HTTP: localhost:8080)

  3. Install mitmproxy CA certificate on client device

  4. Trigger API requests from the application

  5. Intercept and inspect requests/responses in mitmproxy

  6. Modify requests to test:

    • Authentication bypass attempts
    • Authorization flaws (IDOR, privilege escalation)
    • Input validation (SQLi, XSS, command injection)
    • Business logic vulnerabilities
  7. Save flows for documentation and reporting

Workflow 2: Mobile App API Security Testing

Progress: [ ] 1. Install mitmproxy CA certificate on mobile device [ ] 2. Configure device WiFi to use mitmproxy as proxy [ ] 3. Start mitmweb for visual traffic inspection [ ] 4. Launch mobile app and exercise all features [ ] 5. Review API endpoints, authentication mechanisms, data flows [ ] 6. Test for common API vulnerabilities (OWASP API Top 10) [ ] 7. Export traffic as HAR for further analysis [ ] 8. Document findings with request/response examples

Work through each step systematically. Check off completed items.

Workflow 3: Automated API Traffic Recording

For capturing and analyzing API traffic at scale:

  1. Start mitmdump with flow capture:

    mitmdump -w api-traffic.flow --mode regular
  2. Run automated tests or manual app interaction

  3. Stop mitmdump (Ctrl+C) to save flows

  4. Replay captured traffic:

    # Replay to server
    mitmdump -nc -r api-traffic.flow
    
    # Replay with modifications via script
    mitmdump -s replay-script.py -r api-traffic.flow
  5. Export to HAR format for analysis:

    # Using Python API
    python3 -c "from mitmproxy.io import FlowReader; from mitmproxy.tools.dump import DumpMaster;
    import sys; [print(flow.request.url) for flow in FlowReader(open('api-traffic.flow', 'rb')).stream()]"

Workflow 4: Python Scripting for API Testing

For automated security testing with custom logic:

  1. Create Python addon script (api-test.py):

    from mitmproxy import http
    
    class APISecurityTester:
        def request(self, flow: http.HTTPFlow) -> None:
            # Modify requests on-the-fly
            if "api.example.com" in flow.request.pretty_url:
                # Test for authorization bypass
                flow.request.headers["X-User-ID"] = "1"
    
        def response(self, flow: http.HTTPFlow) -> None:
            # Analyze responses
            if flow.response.status_code == 200:
                if "admin" in flow.response.text:
                    print(f"[!] Potential privilege escalation: {flow.request.url}")
    
    addons = [APISecurityTester()]
  2. Run mitmproxy with script:

    mitmproxy -s api-test.py
    # Or for automation
    mitmdump -s api-test.py -w results.flow
  3. Review automated findings and captured traffic

  4. Export results for reporting

Workflow 5: SSL/TLS Certificate Pinning Bypass

For testing mobile apps with certificate pinning:

  1. Install mitmproxy CA certificate on device
  2. Use certificate unpinning tools or framework modifications:
    • Android: Frida script for SSL unpinning
    • iOS: SSL Kill Switch or similar tools
  3. Configure app traffic through mitmproxy
  4. Alternatively, use reverse proxy mode:
    mitmproxy --mode reverse:https://api.example.com --listen-host 0.0.0.0 --listen-port 443
  5. Modify /etc/hosts to redirect API domain to mitmproxy
  6. Intercept and analyze traffic normally

Operating Modes

mitmproxy supports multiple deployment modes:

Regular Proxy Mode (default):

mitmproxy --mode regular --listen-port 8080

Client configures proxy settings explicitly.

Transparent Proxy Mode (invisible to client):

mitmproxy --mode transparent --listen-port 8080

Requires iptables/pf rules to redirect traffic.

Reverse Proxy Mode (sits in front of server):

mitmproxy --mode reverse:https://api.example.com --listen-port 443

mitmproxy acts as the server endpoint.

Upstream Proxy Mode (chain proxies):

mitmproxy --mode upstream:http://corporate-proxy:8080

Routes traffic through another proxy.

Certificate Installation

Install mitmproxy CA certificate for HTTPS interception:

Browser/Desktop:

  1. Start mitmproxy and configure proxy settings
  2. Visit http://mitm.it
  3. Download certificate for your platform
  4. Install in system/browser certificate store

Android:

  1. Push certificate to device: adb push ~/.mitmproxy/mitmproxy-ca-cert.cer /sdcard/
  2. Settings → Security → Install from SD card
  3. Select mitmproxy certificate

iOS:

  1. Email certificate or host on web server
  2. Install profile on device
  3. Settings → General → About → Certificate Trust Settings
  4. Enable trust for mitmproxy certificate

Common Patterns

Pattern 1: API Authentication Testing

Test authentication mechanisms and token handling:

# auth-test.py
from mitmproxy import http

class AuthTester:
    def __init__(self):
        self.tokens = []

    def request(self, flow: http.HTTPFlow):
        # Capture auth tokens
        if "authorization" in flow.request.headers:
            token = flow.request.headers["authorization"]
            if token not in self.tokens:
                self.tokens.append(token)
                print(f"[+] Captured token: {token[:20]}...")

        # Test for missing authentication
        if "api.example.com" in flow.request.url:
            flow.request.headers.pop("authorization", None)
            print(f"[*] Testing unauthenticated: {flow.request.path}")

addons = [AuthTester()]

Pattern 2: API Parameter Fuzzing

Fuzz API parameters for injection vulnerabilities:

# fuzz-params.py
from mitmproxy import http

class ParamFuzzer:
    def request(self, flow: http.HTTPFlow):
        if flow.request.method == "POST" and "api.example.com" in flow.request.url:
            # Clone and modify request
            original_body = flow.request.text
            payloads = ["' OR '1'='1", "<script>alert(1)</script>", "../../../etc/passwd"]

            for payload in payloads:
                # Modify parameters and test
                # (Implementation depends on content-type)
                print(f"[*] Testing payload: {payload}")

addons = [ParamFuzzer()]

Pattern 3: GraphQL API Testing

Inspect and test GraphQL APIs:

# graphql-test.py
from mitmproxy import http
import json

class GraphQLTester:
    def request(self, flow: http.HTTPFlow):
        if "/graphql" in flow.request.path:
            try:
                data = json.loads(flow.request.text)
                query = data.get("query", "")
                print(f"[+] GraphQL Query:\n{query}")

                # Test for introspection
                if "__schema" not in query:
                    introspection = {"query": "{__schema{types{name}}}"}
                    print(f"[*] Testing introspection")
            except:
                pass

addons = [GraphQLTester()]

Pattern 4: HAR Export for Analysis

Export traffic as HTTP Archive for analysis:

# Export flows to HAR format
mitmdump -s export-har.py -r captured-traffic.flow

# export-har.py
from mitmproxy import http, ctx
import json

class HARExporter:
    def done(self):
        har_entries = []
        # Build HAR structure
        # (Simplified - use mitmproxy's built-in HAR addon)
        ctx.log.info(f"Exported {len(har_entries)} entries")

addons = [HARExporter()]

Or use built-in addon:

mitmdump --set hardump=./traffic.har

Security Considerations

  • Sensitive Data Handling: Captured traffic may contain credentials, tokens, PII. Encrypt and secure stored flows. Never commit flow files to version control
  • Access Control: Restrict access to mitmproxy instance. Use authentication for mitmweb (--web-user/--web-password flags)
  • Audit Logging: Log all intercepted traffic and modifications for security auditing and compliance
  • Compliance: Ensure proper authorization before intercepting production traffic. Comply with GDPR, PCI-DSS for sensitive data
  • Safe Defaults: Use isolated testing environments. Avoid intercepting production traffic without explicit authorization

Integration Points

Penetration Testing Workflow

  1. Reconnaissance: Identify API endpoints via mitmproxy
  2. Authentication testing: Capture and analyze auth tokens
  3. Authorization testing: Modify user IDs, roles, permissions
  4. Input validation: Inject payloads to test for vulnerabilities
  5. Business logic: Test workflows for logical flaws
  6. Export findings as HAR for reporting

CI/CD Integration

Run automated API security tests:

# Run mitmdump with test script in CI
mitmdump -s api-security-tests.py --anticache -w test-results.flow &
PROXY_PID=$!

# Run API tests through proxy
export HTTP_PROXY=http://localhost:8080
export HTTPS_PROXY=http://localhost:8080
pytest tests/api_tests.py

# Stop proxy and analyze results
kill $PROXY_PID
python3 analyze-results.py test-results.flow

Mobile App Security Testing

Standard workflow for iOS/Android apps:

  1. Configure device to use mitmproxy
  2. Install CA certificate
  3. Bypass SSL pinning if needed
  4. Exercise app functionality
  5. Analyze API security (OWASP Mobile Top 10)
  6. Document API vulnerabilities

Advanced Features

Traffic Filtering

Filter displayed traffic by expression:

# Show only API calls
mitmproxy --view-filter '~d api.example.com'

# Show only POST requests
mitmproxy --view-filter '~m POST'

# Show responses with specific status
mitmproxy --view-filter '~c 401'

# Combine filters
mitmproxy --view-filter '~d api.example.com & ~m POST'

Request/Response Modification

Modify traffic using built-in mappers:

# Replace request headers
mitmproxy --modify-headers '/~u example/Authorization/Bearer fake-token'

# Replace response body
mitmproxy --modify-body '/~s & ~b "error"/success'

WebSocket Interception

Intercept and modify WebSocket traffic:

# websocket-test.py
from mitmproxy import websocket

class WebSocketTester:
    def websocket_message(self, flow):
        message = flow.messages[-1]
        print(f"[+] WebSocket: {message.content[:100]}")

        # Modify messages
        if message.from_client:
            message.content = message.content.replace(b"user", b"admin")

addons = [WebSocketTester()]

Troubleshooting

Issue: SSL Certificate Errors

Solution: Ensure mitmproxy CA certificate is properly installed and trusted:

# Verify certificate location
ls ~/.mitmproxy/

# Regenerate certificates if needed
rm -rf ~/.mitmproxy/
mitmproxy  # Regenerates on startup

Issue: Mobile App Not Sending Traffic Through Proxy

Solution:

  • Verify WiFi proxy configuration
  • Check firewall rules aren't blocking proxy port
  • Ensure mitmproxy is listening on correct interface (0.0.0.0)
  • Test with browser first to verify proxy works

Issue: Certificate Pinning Blocking Interception

Solution: Use SSL unpinning tools:

# Android with Frida
frida -U -l universal-android-ssl-pinning-bypass.js -f com.example.app

# Or modify app to disable pinning (development builds)

Issue: Cannot Intercept HTTP/2 or HTTP/3

Solution: mitmproxy supports HTTP/2 by default. For HTTP/3:

# Enable HTTP/3 support (experimental)
mitmproxy --set http3=true

OWASP API Security Top 10 Testing

Use mitmproxy to test for OWASP API Security Top 10 vulnerabilities:

  • API1: Broken Object Level Authorization - Modify object IDs in requests
  • API2: Broken Authentication - Test token validation, session management
  • API3: Broken Object Property Level Authorization - Test for mass assignment
  • API4: Unrestricted Resource Consumption - Test rate limiting, pagination
  • API5: Broken Function Level Authorization - Modify roles, escalate privileges
  • API6: Unrestricted Access to Sensitive Business Flows - Test business logic
  • API7: Server Side Request Forgery - Inject URLs in parameters
  • API8: Security Misconfiguration - Check headers, CORS, error messages
  • API9: Improper Inventory Management - Enumerate undocumented endpoints
  • API10: Unsafe Consumption of APIs - Test third-party API integrations

References

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。