-
Notifications
You must be signed in to change notification settings - Fork 5
/
proxysetup.sh
executable file
·37 lines (29 loc) · 1.67 KB
/
proxysetup.sh
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
#!/bin/bash
# User input
local=$1 # local for mitm traffic running on same device, don't include to mitm a different device
# MITM virtualenv
source mitm-env/bin/activate
# Setup based on: https://docs.mitmproxy.org/stable/howto-transparent/
# Enable IP forwarding
sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -w net.ipv6.conf.all.forwarding=1
# Disable ICMP redirects
sudo sysctl -w net.ipv4.conf.all.send_redirects=0
if [ "$local" = "-r" ]; then # check if is via router
echo "Setting all proxied router traffic for port 8080"
sudo iptables -t nat -A PREROUTING -i wlp0s20f3 -p udp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i wlp0s20f3 -p udp --dport 443 -j REDIRECT --to-port 8080
sudo ip6tables -t nat -A PREROUTING -i wlp0s20f3 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo ip6tables -t nat -A PREROUTING -i wlp0s20f3 -p tcp --dport 443 -j REDIRECT --to-port 8080
mitmproxy --mode transparent --showhost --set block_global=false -w ~/traffic.log --listen-port 8080
fi
if [ "$local" = "-w" ]; then # check if is local waydroid vm, simple
echo "Waydroid VM traffic routed to port 8080"
sudo iptables -t nat -A PREROUTING -i waydroid0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i waydroid0 -p tcp --dport 443 -j REDIRECT --to-port 8080
sudo ip6tables -t nat -A PREROUTING -i waydroid0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo ip6tables -t nat -A PREROUTING -i waydroid0 -p tcp --dport 443 -j REDIRECT --to-port 8080
mitmweb --mode transparent --showhost --set block_global=false -w ~/traffic.log --listen-port 8080
fi
echo "Setting ports 80, 443 to redirect to 8080. Finished"
sudo iptables -t nat -F