nginx-ultimate-bad-bot-blocker/dev-tools/update-bad-ips.sh
2025-01-19 08:35:25 +02:00

116 lines
4.7 KiB
Bash
Executable file

#!/bin/bash
# Generator Script for NGinx Ultimate Bad Bot Blocker
# REPO: https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker
# Copyright Mitchell Krog - mitchellkrog@gmail.com
# ------------------------------------------------------------------------------
# MIT License
# ------------------------------------------------------------------------------
# Copyright (c) 2017 Mitchell Krog - mitchellkrog@gmail.com
# https://github.com/mitchellkrogza
# ------------------------------------------------------------------------------
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# ------------------------------------------------------------------------------
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# ------------------------------------------------------------------------------
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ------------------------------------------------------------------------------
# ------------------------
# Set Terminal Font Colors
# ------------------------
export TERM=linux
# ------------------------
# Set Terminal Font Colors
# ------------------------
bold=$(tput bold)
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
magenta=$(tput setaf 5)
cyan=$(tput setaf 6)
white=$(tput setaf 7)
defaultcolor=$(tput setaf 7)
# ---------
# Variables
# ---------
outputfile="./_generator_lists/bad-ip-addresses.list"
tmp="./_generator_lists/tmp.list"
# ---------
# FUNCTIONS
# ---------
fetchBadIPs () {
sudo wget https://hosts.ubuntu101.co.za/ngxubbb/bad-ips.list -O ${outputfile}
echo "${bold}${green}----------------------------"
echo "${bold}${green}Fetching Latest BAD IPs List"
echo "${bold}${green}----------------------------"
printf "\n"
}
prepareBadIPs () {
sudo sort -u ${outputfile} -o ${outputfile}
grep '[^[:blank:]]' < ${outputfile} > ${tmp}
sudo mv ${tmp} ${outputfile}
sudo dos2unix ${outputfile}
echo "${bold}${green}-----------------------------"
echo "${bold}${green}Preparing Latest BAD IPs List"
echo "${bold}${green}-----------------------------"
printf "\n"
}
# -----------------
# Trigger Functions
# -----------------
fetchBadIPs
prepareBadIPs
# ----------------------
# Exit With Error Number
# ----------------------
exit ${?}
# ------------------------------------------------------------------------------
# MIT License
# ------------------------------------------------------------------------------
# Copyright (c) 2017 Mitchell Krog - mitchellkrog@gmail.com
# https://github.com/mitchellkrogza
# ------------------------------------------------------------------------------
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# ------------------------------------------------------------------------------
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# ------------------------------------------------------------------------------
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ------------------------------------------------------------------------------