Proxy

All the following solutions are implemented in HacknDroid.

System Proxy

  • Set the system proxy

    adb shell settings get global http_proxy <proxy_ip>:<port>
  • Get current system proxy

    adb shell settings get global http_proxy
  • Reset the system proxy

    adb shell settings put global http_proxy :0

Invisible proxy (iptables)

  • Set the proxy on ports 80 and 443

    adb shell
    su root
    iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination <proxy_ip>:443
    iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination <proxy_ip>:80
    iptables -t nat -A POSTROUTING -p tcp --dport 443 -j MASQUERADE
    iptables -t nat -A POSTROUTING -p tcp --dport 80 -j MASQUERADE
  • Set the proxy on port 80 and 443 only for the application with a specific owner UID

    adb shell
    su root
    iptables -t nat -A OUTPUT -m owner --uid-owner <owner_uid> -p tcp --dport 443 -j DNAT --to-destination <proxy_ip>:443
    iptables -t nat -A OUTPUT -m owner --uid-owner <owner_uid> -p tcp --dport 80 -j DNAT --to-destination <proxy_ip>:80
    iptables -t nat -A POSTROUTING -m owner --uid-owner <owner_uid> -p tcp --dport 443 -j MASQUERADE
    iptables -t nat -A POSTROUTING -m owner --uid-owner <owner_uid> -p tcp --dport 80 -j MASQUERADE
  • Get current system proxy

    adb shell
    su root
    iptables -t nat -L OUTPUT -v -n | grep 'DNAT'
  • Reset the system proxy

    adb shell
    su root
    iptables -t nat -F

Invisible Proxy (via DNS spoofing)

  1. Launch dnschef:

    sudo python3 dnschef/dnschef.py --fakeip <proxy_ip> --interface <dns_ip> --log-file /tmp/dnschef.log
  2. Open the Wifi settings and set the IP address specified in --interface related to dnschef execution

    adb shell am start -a android.settings.WIFI_SETTINGS

Last updated