From a5582401d438485e05a041427aaef6f8661a3a4a Mon Sep 17 00:00:00 2001 From: Karsten Date: Mon, 23 Nov 2015 11:00:11 +0100 Subject: [PATCH] Create blocklist.de-update.sh --- blocklist.de-update.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 blocklist.de-update.sh diff --git a/blocklist.de-update.sh b/blocklist.de-update.sh new file mode 100644 index 0000000..b756678 --- /dev/null +++ b/blocklist.de-update.sh @@ -0,0 +1,39 @@ +#!/bin/bash +### +### Idea from +### http://wiki.kvs1.de/doku.php?id=pimp-fail2ban-with-blocklist.de +### + +### SERVICE: apache, bots, mail, imap, ftp, ssh oder voip, all +### With Default Values: ssh, mail, imap +### Requires a jail named -blocklist +#service=${1-("ssh" "mail" "imap")} +#service=$1 + +if [ -z "$1" ] +then + service=("ssh" "mail" "imap") +elif ! [ -z "$1" ] +then + service=($1) +fi + +### TIME: Unix time, hh:ii, hh.ii, difference in seconds +time=${2-3600} + +for i in "${service[@]}" +do + : + + tmp=$(mktemp) + + wget -qO $tmp "http://api.blocklist.de/getlast.php?service=$i&time=$time" + + ### Prepend date and time: + ### YYYY-MM-DD HH:II:SS : + sed -i "s/^/$(date +'%F %X') : /g" $tmp + + ### Trigger fail2ban with new log file + mv $tmp /var/log/blocklist-$i.log + +done