forked from cloudshark/pi-in-the-middle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·89 lines (70 loc) · 2.1 KB
/
setup.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Set -e so that if any command fails the script will exit immediately.
set -e
# Install packages
pacman -Syu --needed \
mitmproxy dnsmasq hostapd tcpdump
# Configure
bak() {
if [ ! -e $1.bak ]; then
cp $1 $1.bak
fi
}
unbak() {
if [ -e $1.bak ]; then
cp $1.bak $1
fi
}
setup_wlan_target() {
cp config/wlan_target/dhcpcd.conf /etc/dhcpcd.conf
cp config/wlan_target/dnsmasq.conf /etc/dnsmasq.conf
cp config/wlan_target/iptables.rules /etc/iptables/iptables.rules
cp config/wlan_target/hostapd.conf /etc/hostapd/hostapd.conf
cp config/wlan_target/hostapd /etc/default/hostapd
systemctl unmask hostapd
systemctl enable hostapd
}
setup_eth_target() {
cp config/eth_target/dhcpcd.conf /etc/dhcpcd.conf
cp config/eth_target/dnsmasq.conf /etc/dnsmasq.conf
cp config/eth_target/iptables.rules /etc/iptables/iptables.rules
systemctl disable hostapd
systemctl mask hostapd
}
setup_common() {
bak /etc/dhcpcd.conf
bak /etc/iptables/iptables.rules
cp config/99-sysctl.conf /etc/sysctl.d/99-pi-proxy.conf
systemctl stop systemd-resolved
systemctl disable systemd-resolved
systemctl mask systemd-resolved
systemctl enable iptables
systemctl enable dnsmasq
}
setup_clear() {
systemctl disable hostapd
systemctl mask hostapd
systemctl disable iptables
systemctl disable dnsmasq
systemctl unmask systemd-resolved
systemctl enable systemd-resolved
unbak /etc/dhcpcd.conf
unbak /etc/iptables/iptables.rules
rm /etc/sysctl.d/99-pi-proxy.conf
}
if [ "$1" = "wlan" ]; then
echo "[I] Setting up proxy for wlan connected device"
setup_common
setup_wlan_target
echo "[I] Please reboot to finish configuring the network."
elif [ "$1" = "eth" ]; then
echo "[I] Setting up proxy for eth connected device"
setup_common
setup_eth_target
echo "[I] Please reboot to finish configuring the network."
elif [ "$1" = "clr" ]; then
setup_clear
echo "[I] Please reboot to finish configuring the network."
else
echo "[E] Unknown setup, choose one of: wlan|eth|clr"
fi