Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified tor blocking to use iptables
- Loading branch information
OP
committed
Jan 31, 2014
1 parent
82a90a9
commit d7731d5
Showing
2 changed files
with
32 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
IPTABLES_TARGET="DROP" | ||
IPTABLES_CHAINNAME="TOR" | ||
|
||
WORKING_DIR="/tmp/" | ||
|
||
# get IP address of eth0 network interface | ||
IP_ADDRESS=$(ifconfig eth0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}') | ||
|
||
if ! iptables -L "$IPTABLES_CHAINNAME" -n >/dev/null 2>&1 ; then #If chain doesn't exist | ||
iptables -N "$IPTABLES_CHAINNAME" >/dev/null 2>&1 #Create it | ||
fi | ||
|
||
cd $WORKING_DIR | ||
|
||
wget -q -O - "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=80" -U NoSuchBrowser/1.0 > temp_tor_list | ||
wget -q -O - "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=9998" -U NoSuchBrowser/1.0 >> temp_tor_list | ||
sed -i 's|^#.*$||g' temp_tor_list | ||
|
||
iptables -F "$IPTABLES_CHAINNAME" | ||
|
||
CMD=$(cat temp_tor_list | uniq | sort) | ||
|
||
for IP in $CMD; do | ||
let COUNT=COUNT+1 | ||
iptables -A "$IPTABLES_CHAINNAME" -s $IP -j $IPTABLES_TARGET | ||
done | ||
|
||
iptables -A "$IPTABLES_CHAINNAME" -j RETURN | ||
|
||
rm temp_tor* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters