work on tor blocking detection
This commit is contained in:
parent
a24086da62
commit
2ddeab8788
22
scripts/block-tor.sh
Executable file
22
scripts/block-tor.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
# Block Tor Exit nodes
|
||||
# Adapted from: https://securityonline.info/block-tor-client-iptablesiptables-tor-transparent-proxy/
|
||||
IPTABLES_TARGET="DROP"
|
||||
IPTABLES_CHAINNAME="Tor"
|
||||
if ! iptables -L Tor -n >/dev/null 2>&1 ; then
|
||||
iptables -N Tor >/dev/null 2>&1
|
||||
iptables -A OUTPUT -p tcp -j Tor 2>&1
|
||||
fi
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
cd "$DIR/../"
|
||||
iptables -F Tor
|
||||
CMD=$(cat static-data/tor-node-list.dat | uniq | sort)
|
||||
for IP in $CMD; do
|
||||
if [[ $IP =~ .*:.* ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
let COUNT=COUNT+1
|
||||
iptables -A Tor -d "$IP" -j DROP
|
||||
done
|
||||
iptables -A Tor -j RETURN
|
@ -22,6 +22,7 @@ import logger
|
||||
|
||||
def add_bridges(torrc: str) -> str:
|
||||
"""Configure tor to use a bridge using Onionr config keys."""
|
||||
config.reload()
|
||||
if config.get('tor.use_bridge', False) is True:
|
||||
bridge = config.get('tor.bridge_ip', None)
|
||||
if bridge is not None:
|
||||
@ -29,6 +30,7 @@ def add_bridges(torrc: str) -> str:
|
||||
fingerprint = config.get('tor.bridge_fingerprint', '')
|
||||
torrc += '\nUseBridges 1\nBridge %s %s\n' % (bridge, fingerprint)
|
||||
else:
|
||||
logger.warn('bridge was enabled but not specified in config')
|
||||
logger.error('Bridge was enabled but not specified in config, ' +
|
||||
'this probably won\'t work', terminal=True)
|
||||
|
||||
return torrc
|
||||
|
7649
static-data/tor-node-list.dat
Normal file
7649
static-data/tor-node-list.dat
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user