add ipban plugins - plugins to check attacks under iptables
This commit is contained in:
parent
96e4e5dd03
commit
b2a12cae46
37
plugins/ipban/ipban.plugin.zsh
Normal file
37
plugins/ipban/ipban.plugin.zsh
Normal file
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user