Last active
February 26, 2019 09:38
-
-
Save pallas/8bfb6b7da5c44efd2227227c5ca65c1b to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Author: Derrick Pallas | |
# License: zlib | |
BASE='feodo-set' | |
TEMP=${BASE}$$ | |
ipset create -exist "$BASE" hash:ip --netmask 32 || exit 1 | |
iptables -nL INPUT | grep -q "$BASE" || | |
( | |
( iptables -N "$BASE" || iptables -F "$BASE" ) && | |
iptables -A "$BASE" -m set --match-set "$BASE" src -j DROP && | |
iptables -A INPUT ! -i lo -j "$BASE" && | |
true | |
) || exit 1 | |
function atexit { | |
ipset destroy "$TEMP" | |
} ; trap atexit EXIT | |
ipset create "$TEMP" hash:ip --netmask 32 && | |
( set -o pipefail | |
curl -s \ | |
https://feodotracker.abuse.ch/downloads/ipblocklist.txt \ | |
https://sslbl.abuse.ch/blacklist/sslipblacklist.txt \ | |
https://ransomwaretracker.abuse.ch/downloads/RW_IPBL.txt \ | |
https://zeustracker.abuse.ch/blocklist.php?download=badips \ | |
| | |
sed -e '/^#/d' | | |
cut -f 1 | | |
address-filter | | |
sed s,^::ffff:,,i | | |
sort -u | | |
grep -v : | | |
while read ip ; do | |
ipset add "$TEMP" "$ip"/32 | |
done | |
) && ipset swap "$TEMP" "$BASE" | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment