{ "name": "mitmproxy", "version": "12.2.3", "summary": "mitmproxy: an interactive proxy that shows, records, replays and changes HTTP/1, HTTP/2, HTTP/3 and WebSocket traffic, TLS included through a CA of its own (console, command line and web page; Python)", "category": "network", "license": "MIT", "homepage": "https://mitmproxy.org", "source": { "url": "https://files.pythonhosted.org/packages/e0/56/0df365a56624472c397b45788b64a5c10ecabf0de3858bf538b42875a268/mitmproxy-12.2.3-py3-none-any.whl", "sha256": "df75ccd15ccb39ab55ce9dd4130312270e8ba208eb927a7cbe50cb52678ec722" }, "watch": { "kind": "pypi", "package": "mitmproxy", "pin": "any" }, "vendor": "vendor.txt", "deps": [ "python" ], "env_packages": [], "static": false, "nss": true, "check": "bin/mitmdump --version | has -x 'Mitmproxy: 12.2.3' && py=$PWD/share/mitmproxy/venv/bin/python3 && t=$(mktemp -d) && export HOME=$t && mkdir \"$t/w\" && echo bvs-mitm-page > \"$t/w/index.html\" && P=$(free_port) && { bin/mitmdump --listen-host 127.0.0.1 -p \"$P\" --ssl-insecure --set upstream_cert=false -w \"$t/flows\" > \"$t/log\" 2>&1 < /dev/null & echo $! > \"$t/mitm\"; } && wait_port \"$P\" && for _ in $(seq 1 50); do [ -s \"$t/.mitmproxy/mitmproxy-ca-cert.pem\" ] && break; sleep 0.2; done && [ -s \"$t/.mitmproxy/mitmproxy-ca.pem\" ] && W=$(free_port) && { \"$py\" -m http.server -b 127.0.0.1 -d \"$t/w\" \"$W\" > /dev/null 2>&1 < /dev/null & echo $! > \"$t/web\"; } && wait_port \"$W\" && TS=$(free_port) && { \"$py\" -c 'import http.server, os, ssl, sys; os.chdir(sys.argv[3]); s = http.server.HTTPServer((\"127.0.0.1\", int(sys.argv[1])), http.server.SimpleHTTPRequestHandler); c = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER); c.load_cert_chain(sys.argv[2]); s.socket = c.wrap_socket(s.socket, server_side=True); s.serve_forever()' \"$TS\" \"$t/.mitmproxy/mitmproxy-ca.pem\" \"$t/w\" > /dev/null 2>&1 < /dev/null & echo $! > \"$t/tls\"; } && wait_port \"$TS\" && \"$py\" -c 'import http.client, ssl, sys, urllib.request; p, w, s, ca = sys.argv[1:]; a = urllib.request.build_opener(urllib.request.ProxyHandler({\"http\": \"http://127.0.0.1:\" + p})).open(\"http://127.0.0.1:\" + w + \"/index.html\", timeout=10).read().decode().strip(); c = http.client.HTTPSConnection(\"127.0.0.1\", int(p), timeout=10, context=ssl.create_default_context(cafile=ca)); c.set_tunnel(\"127.0.0.1\", int(s)); c.request(\"GET\", \"/index.html\"); i = dict(x[0] for x in c.sock.getpeercert()[\"issuer\"]); print(a, c.getresponse().read().decode().strip(), i[\"organizationName\"])' \"$P\" \"$W\" \"$TS\" \"$t/.mitmproxy/mitmproxy-ca-cert.pem\" | has -x 'bvs-mitm-page bvs-mitm-page mitmproxy' && kill \"$(cat \"$t/mitm\")\" && for _ in $(seq 1 50); do kill -0 \"$(cat \"$t/mitm\")\" 2> /dev/null || break; sleep 0.2; done && bin/mitmdump -nr \"$t/flows\" > \"$t/read\" 2>&1 && has -F \"GET http://127.0.0.1:$W/index.html\" < \"$t/read\" && has -F \"GET https://127.0.0.1:$TS/index.html\" < \"$t/read\" && [ \"$(grep -c -F '<< HTTP/1.0 200 OK 14b' \"$t/read\")\" = 2 ] && tui_screen 8 bin/mitmproxy --listen-host 127.0.0.1 -p \"$(free_port)\" -r \"$t/flows\" > \"$t/tui\" && has -F \"127.0.0.1:$TS/index.html\" < \"$t/tui\" && X=$(free_port) && { bin/mitmweb --listen-host 127.0.0.1 -p \"$(free_port)\" --web-host 127.0.0.1 --web-port \"$X\" --no-web-open-browser --set web_password=\"$(\"$py\" -c 'import argon2; print(argon2.PasswordHasher().hash(\"bvs-check\"))')\" -r \"$t/flows\" > \"$t/wlog\" 2>&1 < /dev/null & echo $! > \"$t/mweb\"; } && wait_port \"$X\" && \"$py\" -c 'import re, sys, urllib.error, urllib.request; u = \"http://127.0.0.1:\" + sys.argv[1]; g = lambda q: urllib.request.urlopen(u + q, timeout=10); h = g(\"/?token=bvs-check\").read().decode(); n = len(__import__(\"json\").loads(g(\"/flows?token=bvs-check\").read())); j = g(\"/\" + re.search(r\"\\./(static/index-[^\\\"]+\\.js)\", h).group(1)).status; e = 0\ntry:\n g(\"/flows?token=wrong\")\nexcept urllib.error.HTTPError as x:\n e = x.code\nprint(n, j, e)' \"$X\" | has -x '2 200 403' && echo \"mitmproxy 12.2.3: mitmdump proxied a local page over HTTP and over TLS, the TLS one under a certificate its own CA issued and the client verified (cryptography, pyOpenSSL); both flows written and read back; the console showed them; mitmweb served them behind an argon2 password and refused a wrong token\"; r=$?; for p in mweb mitm tls web; do [ -f \"$t/$p\" ] && kill \"$(cat \"$t/$p\")\" 2> /dev/null; done; [ $r = 0 ] || cat \"$t/log\" \"$t/read\" \"$t/tui\" \"$t/wlog\" >&2; exit $r" }