From 7ac40198efb4f47d4ffdcc191ed24bf36b7ffe81 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 15 Nov 2017 16:38:25 +0100 Subject: Add torblock.sh Signed-off-by: Florian Pritz --- torblock.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 torblock.sh 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 -- cgit v1.2.3-24-g4f1b