2015-03-22 12:05:58 +01:00
|
|
|
#!/usr/bin/env bash
|
2013-10-18 14:06:19 +02:00
|
|
|
|
2015-06-16 21:09:02 +02:00
|
|
|
#
|
|
|
|
# Hello, lovely FastNetMon customer! I'm really happy to see you here!
|
2020-07-29 22:22:21 +02:00
|
|
|
# Pavel Odintsov, author
|
2015-06-16 21:09:02 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
# This script will get following params:
|
|
|
|
# $1 client_ip_as_string
|
|
|
|
# $2 data_direction
|
|
|
|
# $3 pps_as_string
|
|
|
|
# $4 action (ban or unban)
|
2013-10-18 14:06:19 +02:00
|
|
|
|
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
|
|
|
|
2015-06-16 21:09:02 +02:00
|
|
|
#
|
2020-07-29 22:22:21 +02:00
|
|
|
# Please be careful ! You should not remove cat >
|
2015-06-16 21:09:02 +02:00
|
|
|
#
|
2013-10-18 14:06:19 +02:00
|
|
|
|
2014-10-21 09:20:18 +02:00
|
|
|
if [ "$4" = "unban" ]; then
|
2015-06-16 21:09:02 +02:00
|
|
|
# No details arrived to stdin here
|
|
|
|
|
2014-10-21 09:20:18 +02:00
|
|
|
# Unban actions if used
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-06-16 21:09:02 +02:00
|
|
|
#
|
|
|
|
# For ban and attack_details actions we will receive attack details to stdin
|
|
|
|
# if option notify_script_pass_details enabled in FastNetMon's configuration file
|
2020-07-29 22:22:21 +02:00
|
|
|
#
|
2015-06-16 21:09:02 +02:00
|
|
|
# If you do not need this details, please set option notify_script_pass_details to "no".
|
|
|
|
#
|
|
|
|
# Please do not remove "cat" command if you have notify_script_pass_details enabled, because
|
|
|
|
# FastNetMon will crash in this case (it expect read of data from script side).
|
|
|
|
#
|
|
|
|
|
2014-11-27 16:43:00 +01:00
|
|
|
if [ "$4" = "ban" ]; then
|
|
|
|
cat | mail -s "FastNetMon Guard: IP $1 blocked because $2 attack with power $3 pps" $email_notify;
|
|
|
|
# You can add ban code here!
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-12-11 21:32:36 +01:00
|
|
|
|
|
|
|
if [ "$4" == "attack_details" ]; then
|
|
|
|
cat | mail -s "FastNetMon Guard: IP $1 blocked because $2 attack with power $3 pps" $email_notify;
|
2020-07-29 22:22:21 +02:00
|
|
|
|
2015-06-16 21:09:02 +02:00
|
|
|
exit 0
|
2014-12-11 21:32:36 +01:00
|
|
|
fi
|