mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-01 10:09:49 +00:00
111 lines
4.6 KiB
Bash
Executable file
111 lines
4.6 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
|
|
# ------------------------
|
|
|
|
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 default)
|
|
|
|
# ---------
|
|
# Variables
|
|
# ---------
|
|
|
|
outputfile=${TRAVIS_BUILD_DIR}/_generator_lists/bad-ip-addresses.list
|
|
tmp=${TRAVIS_BUILD_DIR}/_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.
|
|
# ------------------------------------------------------------------------------
|