Anti DDOS Abwehr ohne iptables bei Vservern von Netcup (VCP)

1. Downloaden

2. Installieren,in der synd.conf folgende Zeile ändern IPT=“Pfad/sync.sh“

3.in der synd.sh abändern:

netstat -ntu | grep SYN_RECV  | head -n6000 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr > $BAD_IP_LIST
cat $BAD_IP_LIST
if [ $KILL -eq 1 ]; then
IP_BAN_NOW=0
while read line; do
CURR_LINE_CONN=$(echo $line | cut -d" " -f1)
CURR_LINE_IP=$(echo $line | cut -d" " -f2)
if [ $CURR_LINE_CONN -lt $NO_OF_CONNECTIONS ]; then
break
fi
IGNORE_BAN=`grep -c $CURR_LINE_IP $IGNORE_IP_LIST`
if [ $IGNORE_BAN -ge 1 ]; then
continue
fi
IP_BAN_NOW=1
echo "$CURR_LINE_IP with $CURR_LINE_CONN SYN_RECV connections" >> $BANNED_IP_MAIL
echo $CURR_LINE_IP >> $BANNED_IP_LIST
echo $CURR_LINE_IP >> $IGNORE_IP_LIST
if [ $APF_BAN -eq 1 ]; then
$APF -d $CURR_LINE_IP
else
  $IPT $CURR_LINE_IP add
fi

4. Fail2ban Script von n-durch-x installieren.

5. cron checken sonst synd.sh selbst nachtragen.

CEPK78 CE-PK78 CE-PK 78 CE PK 78

Netcup Backup Rotation

Hier ein Kleines Script um das Backup durch Images bei Netcup-Vservern zu automatisieren. (Rotierendes Backup).

Das ganze per Cron einbinden. Achtung es werden zum Beispiel bei wöchentlicher Ausführung des Crons alle Backups überschrieben in Wochen zurückgezählt.

#!/bin/sh
#
# Als Anreiz diente ein Script von
# Michael Geiger - tux1337 - www.geigers-site.de
#
# Copyright (C) 2011 Christoph Schuster | ndurchx | www.n-durch-x.de
#Copyright (C) 2011 Phil
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
#</sup>

#check for running process
while [ -e /tmp/nvcp/vcp.pid ]; do
if ( kill -0 `cat /tmp/nvcp/vcp.pid` 2&gt; /dev/null ); then
sleep 5
else
rm -R /tmp/nvcp
fi
done
#CONFIG
user="" #your vcp login name
password="" #your vcp password
servername="" #your vserver name (vXXXXXXXXXXXX)
maxbackups=2 # Maximale Backup des Hostingpaketes
#CONFIG END
#PARAMETERS # normally you dont have to change that
#PARAMETERS END

mkdir /tmp/nvcp
chmod 600 /tmp/nvcp
cd /tmp/nvcp
echo $$ &gt; vcp.pid
#Login
curl -b cookie.txt -c cookie.txt -d "doLogin=Login&amp;username=$user&amp;password=$password" --url https://www.vservercontrolpanel.de/Login

curl -b cookie.txt -o tmp.txt --url https://www.vservercontrolpanel.de/Home
tr -d \\012 &lt; tmp.txt &gt; servers.txt

serverid=`grep -o "selectedVServerId=[0-9]\{1,10\}[^0-9]*$servername" servers.txt | grep -m 1 -o "Id=[0-9]*" | grep -o [0-9]*`
curl -b cookie.txt -o backups.txt --url "https://www.vservercontrolpanel.de/VServers?selectedVServerId=$serverid&amp;page=backup"
grep -o -R $servername"_[0-9]\{4\}.[0-9]\{2\}.[0-9]\{2\}_[0-9]\{2\}:[0-9]\{2\}" backups.txt |uniq &gt; backupsavailable.txt

lines=`wc -l backupsavailable.txt | cut -f1 -d' '`
echo $lines
if [ $lines -eq $maxbackups ]
then
btime=`grep -o -R $servername"_[0-9]\{4\}.[0-9]\{2\}.[0-9]\{2\}_[0-9]\{2\}:[0-9]\{2\}" backupsavailable.txt |uniq |sort |head -n1`
curl -b cookie.txt -d "renewBackup=yes&amp;backupToRenew=$btime&amp;comment=Weekly&amp;renewBackup=Backup%20erneuern" --url "https://www.vservercontrolpanel.de/VServers?selectedVServerId=$serverid&amp;page=backup"
echo "Backup erneuern"
echo $btime
else
curl -b cookie.txt -d "createNewBackup=yes&amp;newBackup=neues%20Backup%20anlegen&amp;comment=Weekly" --url "https://www.vservercontrolpanel.de/VServers?selectedVServerId=$serverid&amp;page=backup"
echo "NEUES BACKUP ANLEGEN"
fi

#Logout
curl -b cookie.txt --url https://www.vservercontrolpanel.de/Logout

rm -R /tmp/nvcp

exit 0