Skip to content

Instantly share code, notes, and snippets.

@Ne00n
Last active July 28, 2023 19:16
Show Gist options
  • Save Ne00n/80bdcb1fabff690404a1f1645041b615 to your computer and use it in GitHub Desktop.
Save Ne00n/80bdcb1fabff690404a1f1645041b615 to your computer and use it in GitHub Desktop.
#!/bin/bash
#Original: http://www.hyenacloud.com/blog/?p=327
#Modified by Neoon
/sbin/iptables -D INPUT -m set --match-set blacklist src -j DROP
/sbin/ipset create blacklist hash:net hashsize 10000000 maxelem 200000
/sbin/iptables -I INPUT -m set --match-set blacklist src -j DROP
IP_TMP=/tmp/ip.tmp
IP_BLACKLIST=/root/ip-blacklist.conf
IP_BLACKLIST_TMP=/tmp/ip-blacklist.tmp
BLACKLISTS=(
"http://www.projecthoneypot.org/list_of_ips.php?t=d&rss=1" # Project Honey Pot Directory of Dictionary Attacker IPs
"http://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=1.1.1.1" # TOR Exit Nodes
"http://www.maxmind.com/en/anonymous_proxies" # MaxMind GeoIP Anonymous Proxies
"http://danger.rulez.sk/projects/bruteforceblocker/blist.php" # BruteForceBlocker IP List
"http://www.spamhaus.org/drop/drop.lasso" # Spamhaus Don't Route Or Peer List (DROP)
"http://cinsscore.com/list/ci-badguys.txt" # C.I. Army Malicious IP List
"http://lists.blocklist.de/lists/all.txt" # blocklist.de attackers
"https://iplists.firehol.org/files/firehol_level1.netset" #firehol_level1
"https://blocklist.greensnow.co/greensnow.txt"
"http://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt"
"https://blocklist.net.ua/blocklist.csv"
)
for i in "${BLACKLISTS[@]}"
do
curl "$i" > $IP_TMP
grep -Po '(?:\d{1,3}\.){3}\d{1,3}(?:/\d{1,2})?' $IP_TMP >> $IP_BLACKLIST_TMP
done
sort $IP_BLACKLIST_TMP -n | uniq > $IP_BLACKLIST
rm $IP_BLACKLIST_TMP
wc -l $IP_BLACKLIST
/sbin/ipset flush blacklist
egrep -v "^#|^$" $IP_BLACKLIST | while IFS= read -r ip
do
/sbin/ipset add blacklist $ip
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment