|
@@ -6993,19 +6993,6 @@ function route_outgoing_traffic_through_tor {
|
6993
|
6993
|
fi
|
6994
|
6994
|
apt-get -y --force-yes install tor tor-arm
|
6995
|
6995
|
|
6996
|
|
- ### set variables
|
6997
|
|
- # Destinations you don't want routed through Tor
|
6998
|
|
- _non_tor="192.168.0.0/24 192.168.1.0/24 192.168.2.0/24 192.168.3.0/24 192.168.10.0/24 192.168.42.0/24"
|
6999
|
|
-
|
7000
|
|
- # The user that Tor runs as
|
7001
|
|
- _tor_uid="debian-tor"
|
7002
|
|
-
|
7003
|
|
- # Tor's TransPort
|
7004
|
|
- _trans_port="9040"
|
7005
|
|
-
|
7006
|
|
- # Your internal interface
|
7007
|
|
- _int_if="br0"
|
7008
|
|
-
|
7009
|
6996
|
# Ensure that redirects are possible
|
7010
|
6997
|
sed -i "s/net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 1/g" /etc/sysctl.conf
|
7011
|
6998
|
sed -i "s/net.ipv4.conf.all.send_redirects = 0/net.ipv4.conf.all.send_redirects = 1/g" /etc/sysctl.conf
|
|
@@ -7013,39 +7000,13 @@ function route_outgoing_traffic_through_tor {
|
7013
|
7000
|
sed -i "s/net.ipv4.conf.default.rp_filter=1/#net.ipv4.conf.default.rp_filter=1/g" /etc/sysctl.conf
|
7014
|
7001
|
sed -i "s/net.ipv4.conf.all.rp_filter=1/#net.ipv4.conf.all.rp_filter=1/g" /etc/sysctl.conf
|
7015
|
7002
|
sed -i 's/net.ipv4.icmp_echo_ignore_all = 1/net.ipv4.icmp_echo_ignore_all = 0/g' /etc/sysctl.conf
|
|
7003
|
+ sed -i "s/net.ipv4.ip_forward=0/net.ipv4.ip_forward=1/g" /etc/sysctl.conf
|
7016
|
7004
|
|
7017
|
|
- iptables --flush
|
7018
|
|
- iptables --table nat --flush
|
7019
|
|
- iptables --delete-chain
|
7020
|
|
- iptables --table nat --delete-chain
|
7021
|
|
-
|
7022
|
|
- ### Set iptables *nat
|
7023
|
|
- iptables -t nat -A OUTPUT -o lo -j RETURN
|
7024
|
|
- iptables -t nat -A OUTPUT -m owner --uid-owner $_tor_uid -j RETURN
|
7025
|
|
- iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-ports 53
|
7026
|
|
-
|
7027
|
|
- # Allow clearnet access for hosts in $_non_tor
|
7028
|
|
- for _clearnet in $_non_tor; do
|
7029
|
|
- iptables -t nat -A OUTPUT -d $_clearnet -j RETURN
|
7030
|
|
- iptables -t nat -A PREROUTING -i $_int_if -d $_clearnet -j RETURN
|
7031
|
|
- done
|
7032
|
|
-
|
7033
|
|
- # Redirect all other pre-routing and output to Tor
|
7034
|
|
- iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports $_trans_port
|
7035
|
|
- iptables -t nat -A PREROUTING -i $_int_if -p udp --dport 53 -j REDIRECT --to-ports 53
|
7036
|
|
- iptables -t nat -A PREROUTING -i $_int_if -p tcp --syn -j REDIRECT --to-ports $_trans_port
|
7037
|
|
-
|
7038
|
|
- ### set iptables *filter
|
7039
|
|
- iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
|
7040
|
|
-
|
7041
|
|
- # Allow clearnet access for hosts in $_non_tor
|
7042
|
|
- for _clearnet in $_non_tor 127.0.0.0/8; do
|
7043
|
|
- iptables -A OUTPUT -d $_clearnet -j ACCEPT
|
7044
|
|
- done
|
7045
|
|
-
|
7046
|
|
- # Allow only Tor output
|
7047
|
|
- iptables -A OUTPUT -m owner --uid-owner $_tor_uid -j ACCEPT
|
7048
|
|
- iptables -A OUTPUT -j REJECT
|
|
7005
|
+ iptables -F
|
|
7006
|
+ iptables -t nat -F
|
|
7007
|
+ iptables -t nat -A PREROUTING -i $WIFI_INTERFACE -p tcp --dport $SSH_PORT -j REDIRECT --to-ports $SSH_PORT
|
|
7008
|
+ iptables -t nat -A PREROUTING -i $WIFI_INTERFACE -p udp --dport 53 -j REDIRECT --to-ports 53
|
|
7009
|
+ iptables -t nat -A PREROUTING -i $WIFI_INTERFACE -p tcp --syn -j REDIRECT --to-ports 9040
|
7049
|
7010
|
|
7050
|
7011
|
save_firewall_settings
|
7051
|
7012
|
|
|
@@ -7062,6 +7023,10 @@ function route_outgoing_traffic_through_tor {
|
7062
|
7023
|
echo 'VirtualAddrNetworkIPv4 10.192.0.0/10' >> /etc/tor/torrc
|
7063
|
7024
|
fi
|
7064
|
7025
|
|
|
7026
|
+ if ! grep -q "AutomapHostsSuffixes .onion,.exit" /etc/tor/torrc; then
|
|
7027
|
+ echo 'AutomapHostsSuffixes .onion,.exit' >> /etc/tor/torrc
|
|
7028
|
+ fi
|
|
7029
|
+
|
7065
|
7030
|
if ! grep -q "AutomapHostsOnResolve" /etc/tor/torrc; then
|
7066
|
7031
|
echo 'AutomapHostsOnResolve 1' >> /etc/tor/torrc
|
7067
|
7032
|
fi
|
|
@@ -7215,7 +7180,7 @@ function enable_wifi_hotspot {
|
7215
|
7180
|
fi
|
7216
|
7181
|
fi
|
7217
|
7182
|
|
7218
|
|
- apt-get -y install hostapd isc-dhcp-server bridge-utils
|
|
7183
|
+ apt-get -y install hostapd isc-dhcp-server
|
7219
|
7184
|
|
7220
|
7185
|
if [ ! -f /etc/default/hostapd ]; then
|
7221
|
7186
|
echo 'Unable to find /etc/default/hostapd. hostapd may not have installed correctly'
|
|
@@ -7240,29 +7205,12 @@ function enable_wifi_hotspot {
|
7240
|
7205
|
echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
|
7241
|
7206
|
echo 'rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf
|
7242
|
7207
|
|
7243
|
|
- if ! grep -q "auto lo br0" /etc/network/interfaces; then
|
7244
|
|
- sed -i 's/auto lo/auto lo br0/g' /etc/network/interfaces
|
7245
|
|
- fi
|
7246
|
|
-
|
7247
|
7208
|
if ! grep -q "Wifi hotspot" /etc/network/interfaces; then
|
7248
|
7209
|
echo '' >> /etc/network/interfaces
|
7249
|
7210
|
echo '# Wifi hotspot' >> /etc/network/interfaces
|
7250
|
|
- echo "allow-hotplug $WIFI_INTERFACE" >> /etc/network/interfaces
|
7251
|
|
- echo "iface $WIFI_INTERFACE inet manual" >> /etc/network/interfaces
|
7252
|
|
- fi
|
7253
|
|
-
|
7254
|
|
- if ! grep -q "Wireless bridge" /etc/network/interfaces; then
|
7255
|
|
- echo '' >> /etc/network/interfaces
|
7256
|
|
- echo '# Wireless bridge' >> /etc/network/interfaces
|
7257
|
|
- echo 'iface br0 inet static' >> /etc/network/interfaces
|
7258
|
|
- echo " bridge_ports $WIFI_INTERFACE eth0" >> /etc/network/interfaces
|
|
7211
|
+ echo "iface $WIFI_INTERFACE inet static" >> /etc/network/interfaces
|
7259
|
7212
|
echo " address $WIFI_STATIC_IP_ADDRESS" >> /etc/network/interfaces
|
7260
|
7213
|
echo ' netmask 255.255.255.0' >> /etc/network/interfaces
|
7261
|
|
- echo " network $WIFI_SUBNET" >> /etc/network/interfaces
|
7262
|
|
- echo " gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
|
7263
|
|
- echo " dns-nameservers $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
|
7264
|
|
- echo " up iptables -t nat -I POSTROUTING -s $WIFI_SUBNET/24 -j MASQUERADE" >> /etc/network/interfaces
|
7265
|
|
- echo " down iptables -t nat -D POSTROUTING -s $WIFI_SUBNET/24 -j MASQUERADE" >> /etc/network/interfaces
|
7266
|
7214
|
fi
|
7267
|
7215
|
|
7268
|
7216
|
if ! grep -q '#option domain-name "example.org";' /etc/network/interfaces; then
|