hallo dargoth,
super, danke für deinen tip.
schon ändert man das script minimal ab und danach funktionierts wie es soll ![]()
nun werden die regeln auch wieder zurückgesetzt ...
gruß
woodgee
hallo dargoth,
super, danke für deinen tip.
schon ändert man das script minimal ab und danach funktionierts wie es soll ![]()
nun werden die regeln auch wieder zurückgesetzt ...
gruß
woodgee
hallo,
erst mal tolles script, dankeschön !!
hab mir das script installiert, leider werden die firewall regeln zwar angelegt, aber danach nicht mehr gelöscht.
wann ich /pfad/zum/script/script.sh 192.168.1.1 add ausführe wird 192.168.1.1 in der firewall geblockt.
wenn ich nun /pfad/zum/script/script.sh 192.168.1.1 del ausführe wird 192.168.1.1 aber nicht mehr gelöscht.
#!/bin/sh
#
# Script um IPs ueber OpenVCP zu bannen
#
# Dieses Script empfaengt über den ersten Parameter die IP.
#
# Der zweite ist add fürs hinzufügen oder del fürs löschen der IP.
#
# Copyright (C) 2008 Michael Geiger - tux1337 - www.geigers-site.de
# Copyright (C) 2009 stachi
#
# 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/>.
#
# ##########################################################################
#
# Please let me know if you modify something. Maybe I can include it -
# and you can help to make the script better. Contact me with this form:
# http://contact.geigers-site.de - Thank you!
# Please give feedback over this form, too.
#
# ##########################################################################
#
#warten bis alle aktionen abgeschlossen sind
while [ -e /tmp/ovcp/openvcpcookie.txt ]; do
sleep 5
done
###init bereich
#openvcp login
user="Benutzername"
password="Passwort"
servername="vxxxxxxxx"
####init end
# DO NOT CHANGE ANYTHING UNDER THIS LINE!
##############################################
#parameter
direction="INPUT"
protokoll="tcp"
sourceip="$1"
sourceport="any"
destinationip="any"
destinationport="any"
policy="DROP"
match="STATE"
new="NEW"
established="ESTABLISHED"
related="RELATED"
addrule="Regel hinzufügen"
delrule="submit changes"
#tmp ordner (cookie)
mkdir /tmp/ovcp
chmod 700 /tmp/ovcp
cd /tmp/ovcp
#login
curl -b openvcpcookie.txt -c openvcpcookie.txt -d "loginname=$user&password=$password" --url https://www.vservercontrolpanel.de/index.php/auth/submit
if [ $2 = add ]
then
#regeln definieren und setzen
curl -b openvcpcookie.txt -d "proto=$protokoll&srcip=$sourceip&srcport=$sourceport&destip=$destinationip&destport=$destinationport&target=$policy&match=$match&match_value[NEW]=$new&match_value[ESTABLISHED]=$established&match_value[RELATED]=$related&direction=$direction&add_rule=$addrule" --url https://www.vservercontrolpanel.de/index.php/user/firewall/$servername/submit
protokoll="udp"
curl -b openvcpcookie.txt -d "proto=$protokoll&srcip=$sourceip&srcport=$sourceport&destip=$destinationip&destport=$destinationport&target=$policy&match=$match&match_value[NEW]=$new&match_value[ESTABLISHED]=$established&match_value[RELATED]=$related&direction=$direction&add_rule=$addrule" --url https://www.vservercontrolpanel.de/index.php/user/firewall/$servername/submit
protokoll="icmp"
curl -b openvcpcookie.txt -d "proto=$protokoll&srcip=$sourceip&srcport=$sourceport&destip=$destinationip&destport=$destinationport&target=$policy&match=$match&match_value[NEW]=$new&match_value[ESTABLISHED]=$established&match_value[RELATED]=$related&direction=$direction&add_rule=$addrule" --url https://www.vservercontrolpanel.de/index.php/user/firewall/$servername/submit
elif [ $2 = del ]
then
#regeln löschen
curl -b openvcpcookie.txt -o openvcpfirewall.txt --url https://www.vservercontrolpanel.de/index.php/user/firewall/$servername
grep -C "1" -e "$1" openvcpfirewall.txt | grep -o -e "rule\[[[:digit:]]*\]" | grep -o -e "[[:digit:]]*" | while read; do
ID="$REPLY"
curl -b openvcpcookie.txt -d "rule[$ID]=$ID&submit=$delrule" --url https://www.vservercontrolpanel.de/index.php/user/firewall/$servername/submit
done
fi
#logout
curl -b openvcpcookie.txt --url https://www.vservercontrolpanel.de/index.php/user/logout
rm -R /tmp/ovcp
Alles anzeigen
gibt es von dem script eine erweiterung oder ein update ??
gruß
woodgee