2013-10-18 14:06:19 +02:00
#!/bin/bash
#$1 client_ip_as_string
#$2 data_direction
#$3 pps_as_string
2014-06-09 13:58:55 +02:00
email_notify = "root,please_fix_this_email@domain.ru"
2013-10-18 14:06:19 +02:00
2013-10-19 16:01:24 +02:00
# Далее возможны два варианта:
# это первый запуск, при котором нужно банить IP (на stdin пусто)
# это второй запуск, когда скрипт уже собрал (если смог) детали о б атаке (на stdin даные о б атаке)
2013-10-18 14:06:19 +02:00
2013-10-19 16:01:24 +02:00
# check stdin type
if [ -t 0 ] ; then
2013-10-19 17:15:17 +02:00
echo "Subject, please execute all related tasks :) You may (not always) got atack details in next letter" | mail -s " Myflower Guard: IP $1 blocked because $2 attack with power $3 pps " $email_notify ;
2014-06-09 11:05:52 +02:00
# You can add ban code here!
# iptables -A INPUT -s $1 -j DROP
# iptables -A INPUT -d $1 -j DROP
2013-10-19 16:01:24 +02:00
else
2013-10-19 17:15:17 +02:00
cat | mail -s " Myflower Guard: IP $1 blocked because $2 attack with power $3 pps " $email_notify ;
2013-10-19 16:01:24 +02:00
fi