-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmitmwrap
More file actions
executable file
·42 lines (35 loc) · 1.13 KB
/
mitmwrap
File metadata and controls
executable file
·42 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# have a mitmproxy running before on 127.0.0.1:8080
set -eu -o pipefail
host="${MITMWRAP_HOST-127.0.0.1}"
port="${MITMWRAP_PORT-8080}"
proxychains=0
for arg in "$@"; do
case "$arg" in
--proxychains) proxychains=1; shift ;;
--) shift; break ;;
esac
done
if (( proxychains )); then
file="$(mktemp)"
trap 'code="$?"; rm -f -- "$file"; exit "$code"' EXIT
export PROXYCHAINS_CONF_FILE="$file"
cat <<EOF >"$file"
proxy_dns
quiet_mode
[ProxyList]
http $host $port
EOF
cmd=(proxychains4 -q "$@")
else
for proxy in http_proxy https_proxy HTTP_PROXY HTTPS_PROXY; do
export "$proxy=$host:$port"
done
cmd=("$@")
fi
# thanks https://github.com/lincheney/ffcli/blob/ac89f62ae7039fb0fcdb77fd09203b413ac2d2f3/ffcli.py#L581-L587
cert="$HOME"/.mitmproxy/mitmproxy-ca-cert.cer
for var in AWS_CA_BUNDLE CURL_CA_BUNDLE SSL_CERT_FILE NODE_EXTRA_CA_CERTS REQUESTS_CA_BUNDLE GIT_SSL_CAINFO; do
export "$var=$cert"
done
bwrap --dev-bind / / --ro-bind "$cert" "$(readlink -f /etc/ssl/certs/ca-certificates.crt)" --ro-bind "$cert" "$(readlink -f "$(python3 -m certifi)")" -- "${cmd[@]}"