diff --git a/android/conf/docker-entrypoint.sh b/android/conf/docker-entrypoint.sh index 3446143..645d2c2 100644 --- a/android/conf/docker-entrypoint.sh +++ b/android/conf/docker-entrypoint.sh @@ -3,8 +3,22 @@ npm i -C /code bash /conf/wait_for_sd.sh adb shell su root /tmp/frida-server & +apt-get install iptables -y -cd /frida-scripts && perl -i -0777p -e 's|CERT_PEM = .*?;|CERT_PEM = `'"$(cat /certificates/ca.pem | sed -z 's/\n/\\n/g')"'`;|gsm' config.js +# configuring the pinning / unpinning scripts +perl -i -0777p -e 's|CERT_PEM = .*?;|CERT_PEM = `'"$(cat /certificates/mitmproxy-ca-cert.pem | sed -z 's/\n/\\n/g')"'`;|gsm' /frida-scripts/config.js +perl -i -0777p -e 's|const PROXY_SUPPORTS_SOCKS5 = false|const PROXY_SUPPORTS_SOCKS5 = true|gsm' /frida-scripts/config.js +perl -i -0777p -e 's|const BLOCK_HTTP3 = true|const BLOCK_HTTP3 = true|gsm' /frida-scripts/config.js +perl -i -0777p -e 's|const PROXY_PORT = 8000|const PROXY_PORT = 8000|gsm' /frida-scripts/config.js + +# configuring forwarding the proxy info to mitmproxy adb reverse tcp:8000 tcp:8000 +# iptables -t nat -A OUTPUT -p tcp --dport 8000 -j DNAT --to-destination $(getent hosts mitmproxy | awk '{ print $1 }'):8000 + +iptables -t nat -A OUTPUT -m addrtype --src-type LOCAL --dst-type LOCAL -p tcp --dport 8000 -j DNAT --to-destination $(getent hosts mitmproxy | awk '{ print $1 }'):1080 +iptables -t nat -A POSTROUTING -m addrtype --src-type LOCAL --dst-type UNICAST -j MASQUERADE + +# iptables -t nat -A POSTROUTING -p tcp -d mitmproxy --dport 8000 -j SNAT --to-source 127.0.0.1:8000 + node /code/index.mjs diff --git a/android/entrypoint.sh b/android/entrypoint.sh index 8c4dd8e..ecb5f2e 100755 --- a/android/entrypoint.sh +++ b/android/entrypoint.sh @@ -1,23 +1,23 @@ #!/bin/bash set -e -node /proxy_cache_thing/dist/index.js & -CACHE_PID=$! +# node /proxy_cache_thing/dist/index.js & +# CACHE_PID=$! -/httptoolkit-server/bin/run start -c /certificates & -HTTPTOOLKIT_SERVER_PID=$! +# /httptoolkit-server/bin/run start -c /certificates & +# HTTPTOOLKIT_SERVER_PID=$! bash /conf/docker-entrypoint.sh & ANDROID_PID=$! function check_dead() { - if ! ps -p $CACHE_PID > /dev/null; then - echo "[ERROR] The proxy cache died, exiting..."; - exit 1; - fi - if ! ps -p $HTTPTOOLKIT_SERVER_PID > /dev/null; then - echo "[ERROR] The httptoolkit_server died, exiting..."; - exit 1; - fi + # if ! ps -p $CACHE_PID > /dev/null; then + # echo "[ERROR] The proxy cache died, exiting..."; + # exit 1; + # fi + # if ! ps -p $HTTPTOOLKIT_SERVER_PID > /dev/null; then + # echo "[ERROR] The httptoolkit_server died, exiting..."; + # exit 1; + # fi if ! ps -p $ANDROID_PID > /dev/null; then echo "[ERROR] The android emulator died, exiting..."; exit 1; diff --git a/docker-compose.yaml b/docker-compose.yaml index 0b693af..f374de8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,6 +11,7 @@ services: container_name: android sysctls: - net.ipv6.conf.all.disable_ipv6=1 + - net.ipv4.conf.all.route_localnet=1 cap_add: - NET_ADMIN devices: @@ -30,6 +31,13 @@ services: - $PWD/certificates:/certificates - $PWD/android/code:/code + mitmproxy: + build: ./mitmproxy + networks: + - rent_gen_android + volumes: + - $PWD/certificates:/root/.mitmproxy + container_name: mitmproxy httptoolkit_ui: build: context: ./httptoolkit_ui/ diff --git a/http_server/code/index.html b/http_server/code/index.html index 3ac14b2..2dd1c6c 100644 --- a/http_server/code/index.html +++ b/http_server/code/index.html @@ -90,12 +90,12 @@