load URLs from a config file
This commit is contained in:
		
							
								
								
									
										18
									
								
								blacklist.sh
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								blacklist.sh
									
									
									
									
									
								
							@@ -4,6 +4,22 @@
 | 
				
			|||||||
# Pawel Krawczyk 2014-2015
 | 
					# Pawel Krawczyk 2014-2015
 | 
				
			||||||
# documentation https://github.com/kravietz/blacklist-scripts
 | 
					# documentation https://github.com/kravietz/blacklist-scripts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# try to load config file
 | 
				
			||||||
 | 
					# it should contain one blacklist URL per line
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config_file="/etc/ip-blacklist.conf"
 | 
				
			||||||
 | 
					if [ -f "${config_file}" ]; then
 | 
				
			||||||
 | 
					    exec <"${config_file}"
 | 
				
			||||||
 | 
					    read line
 | 
				
			||||||
 | 
					    while [ "$line" ]; do
 | 
				
			||||||
 | 
					        if ! echo "$line" | egrep -q '(^#|^$)'; then
 | 
				
			||||||
 | 
					            urls="${urls} $line"
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					        read line
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    # if no config file is available, load default set of blacklists
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Emerging Threats lists offensive IPs such as botnet command servers
 | 
					    # Emerging Threats lists offensive IPs such as botnet command servers
 | 
				
			||||||
    urls="http://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt"
 | 
					    urls="http://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -18,6 +34,8 @@ urls="$urls http://www.badips.com/get/list/ssh/2"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # iblocklist.com is also supported
 | 
					    # iblocklist.com is also supported
 | 
				
			||||||
    # urls="$urls http://list.iblocklist.com/?list=srzondksmjuwsvmgdbhi&fileformat=p2p&archiveformat=gz&username=USERNAMEx$&pin=PIN"
 | 
					    # urls="$urls http://list.iblocklist.com/?list=srzondksmjuwsvmgdbhi&fileformat=p2p&archiveformat=gz&username=USERNAMEx$&pin=PIN"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This is how it will look like on the server
 | 
					# This is how it will look like on the server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user