Skip to content

Instantly share code, notes, and snippets.

@DenBond7
Created May 3, 2022 17:17
Show Gist options
  • Save DenBond7/80f5d9ec75ba258038ade0cd81400fce to your computer and use it in GitHub Desktop.
Save DenBond7/80f5d9ec75ba258038ade0cd81400fce to your computer and use it in GitHub Desktop.
redirect_trafic_for_emulators.sh
#!/usr/bin/env bash
for device in `adb devices | awk '{print $1}'`; do
if [ ! "$device" = "" ] && [ ! "$device" = "List" ]
then
echo " "
echo "adb -s $device"
echo "------------------------------------------------------"
adb -s $device root
echo "adb -s $device root"
adb -s $device shell "echo 1 > /proc/sys/net/ipv4/ip_forward"
echo "adb -s $device shell 'echo 1 > /proc/sys/net/ipv4/ip_forward'"
adb -s $device shell "iptables -t nat -A PREROUTING -s 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to 1212"
echo "adb -s $device shell 'iptables -t nat -A PREROUTING -s 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to 1212'"
adb -s $device shell "iptables -t nat -A OUTPUT -s 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to 1212"
echo "adb -s $device shell 'iptables -t nat -A OUTPUT -s 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to 1212'"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment