-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.sh
More file actions
18 lines (18 loc) · 799 Bytes
/
proxy.sh
File metadata and controls
18 lines (18 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
if (adb root | grep -q "adbd is already running as root")
then
function finish {
adb shell "iptables -t nat -F"
adb reverse --remove-all
}
trap finish EXIT
adb shell "iptables -t nat -F"
adb shell "iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:8080"
adb shell "iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:8080"
adb shell "iptables -t nat -A POSTROUTING -p tcp --dport 80 -j MASQUERADE"
adb shell "iptables -t nat -A POSTROUTING -p tcp --dport 443 -j MASQUERADE"
adb reverse tcp:8080 tcp:$1
read -n1 -r -p "Android device traffic being redirected to $1 port on localhost. Press any key to stop and clean up device rules ..." key
adb shell "iptables -t nat -F"
adb reverse --remove-all
fi