summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-11-15 16:38:25 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-11-15 16:38:42 +0100
commit7ac40198efb4f47d4ffdcc191ed24bf36b7ffe81 (patch)
tree7bd088f12906b5b6f80d558be61e8dce8d46adce
parent5011f2521ea1f6f2f3b1d22a7ff7e802e4ce3bcf (diff)
downloadbin-7ac40198efb4f47d4ffdcc191ed24bf36b7ffe81.tar.gz
bin-7ac40198efb4f47d4ffdcc191ed24bf36b7ffe81.tar.xz
Add torblock.sh
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xtorblock.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/torblock.sh b/torblock.sh
new file mode 100755
index 0000000..5638a80
--- /dev/null
+++ b/torblock.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+get_ips() {
+ curl -sSL "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$(curl icanhazip.com)" | sed '/^#/d' | grep -Eo "([0-9]{1,3}[\.]){3}[0-9]{1,3}"
+}
+
+ipset flush tor || true
+ipset create -exist tor iphash
+
+get_ips | sed 's#^#add tor #' | ipset restore
+
+iptables -I INPUT -m set --match-set tor src -j REJECT --reject-with icmp-admin-prohibited