From b2a12cae46ba452fdfffca8b4bf9464a461c462a Mon Sep 17 00:00:00 2001 From: Olivier Date: Sat, 11 Oct 2014 19:48:20 +0200 Subject: [PATCH] add ipban plugins - plugins to check attacks under iptables --- plugins/ipban/ipban.plugin.zsh | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 plugins/ipban/ipban.plugin.zsh diff --git a/plugins/ipban/ipban.plugin.zsh b/plugins/ipban/ipban.plugin.zsh new file mode 100644 index 00000000..d1d5b035 --- /dev/null +++ b/plugins/ipban/ipban.plugin.zsh @@ -0,0 +1,37 @@ +CSI="\033[" +CEND="${CSI}0m" +CRED="${CSI}1;31m" +CCYAN="${CSI}1;36m" + +ipban() { + +ACTION=$1 +IP=$2 + +case $ACTION in +"add") +if [[ $IP != "" ]]; then +iptables -A INPUT -s $IP -j DROP +iptables-save > /etc/iptables/rules.v4 +fi +;; +"remove") +if [[ $IP != "" ]]; then +iptables -D INPUT -s $IP -j DROP +iptables-save > /etc/iptables/rules.v4 +fi +;; +"list") +echo -e "${CCYAN}Liste des adresses ip bannies :${CEND}" +echo -e "${CCYAN}----------------------------------------------------------------${CEND}" +iptables -L INPUT | grep DROP +echo -e "${CCYAN}----------------------------------------------------------------${CEND}" +;; +"count") +CIP=$(iptables -L INPUT | grep DROP | wc -l) +echo -e "Nombre d'adresses ip bannies : ${CRED}$CIP${CEND}" +;; +*) +echo "Utilisation: $0 {add|remove|list|count} [IP]" +esac +}