-
-
Save alsyundawy/f601cc60e55cda136d38a77e692f2924 to your computer and use it in GitHub Desktop.
A script to download bad IP addresses and deny them with UFW
This file contains hidden or 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 | |
| TMP_DIR="/tmp" | |
| URL_LINKS=$"http://www.blocklist.de/lists/ssh.txt | |
| http://www.blocklist.de/lists/apache.txt | |
| http://www.blocklist.de/lists/asterisk.txt | |
| http://www.blocklist.de/lists/bots.txt | |
| http://www.blocklist.de/lists/courierimap.txt | |
| http://www.blocklist.de/lists/courierpop3.txt | |
| http://www.blocklist.de/lists/email.txt | |
| http://www.blocklist.de/lists/ftp.txt | |
| http://www.blocklist.de/lists/imap.txt | |
| http://www.blocklist.de/lists/ircbot.txt | |
| http://www.blocklist.de/lists/pop3.txt | |
| http://www.blocklist.de/lists/postfix.txt | |
| http://www.blocklist.de/lists/proftpd.txt | |
| http://www.blocklist.de/lists/sip.txt | |
| http://www.ciarmy.com/list/ci-badguys.txt | |
| http://charles.the-haleys.org/ssh_dico_attack_hdeny_format.php/hostsdeny.txt | |
| http://www.nothink.org/blacklist/blacklist_ssh_day.txt | |
| http://malc0de.com/bl/IP_Blacklist.txt | |
| http://www.nothink.org/blacklist/blacklist_malware_dns.txt | |
| http://www.nothink.org/blacklist/blacklist_malware_http.txt | |
| http://www.nothink.org/blacklist/blacklist_malware_irc.txt" | |
| function denyHost() { | |
| sudo ufw deny from $1; | |
| } | |
| function getLists() { | |
| if [[ ! -d "${BACKUP_DIR}" ]]; then | |
| mkdir -p "${BACKUP_DIR}"; | |
| fi; | |
| for line in echo ${URL_LINKS}; do | |
| filename=$(python -c 'import string; import random; acc=string.ascii_letters; d=["".join([random.choice(acc) for _ in range(1)]) for _ in range(7)]; print("".join(d))') | |
| writeTo="${TMP_DIR}/${filename}.deny"; | |
| touch $writeTo; | |
| curl -o "${writeTo}" $line; | |
| while read item; do | |
| denyHost $item; | |
| done < "${writeTo}"; | |
| done; | |
| } | |
| getLists; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment