make it invisible to those ip..

#! /bin/bash
#
IP=`echo $* | sed ‘s/^.* from //’ | awk ‘{print $1}’ | sed ‘s/::ffff://’`
ATTEMPTS=`grep $IP /var/log/secure | grep “Failed password for”  | wc -l`

if [ $ATTEMPTS -gt 2 ]
then
route add $IP lo
MINUTES=`expr $ATTEMPTS – 2`
echo “route del $IP lo 2> /dev/null” | at now +$MINUTES minutes 2>&1 > /tmp/.bad_user.$$
(hostname ; echo $* ; echo “IP=$IP” ; echo “ATTEMPTS=$ATTEMPTS” ; \
echo “Blocking for $MINUTES minutes” ; \
cat /tmp/.bad_user.$$ ) | Mail -s “bad user” root
fi

rm -f /tmp/.bad_user.$$
~

Related Post

3 Responses

  1. ahstod says:

    Copy the /boot/config.2.6.x.x.x.el5 from centos into your kernel source directory as .config, and “make oldconfig” … and them make menuconfig and tweak from there. That brings your kernel config as close to the original centos settings as possible …

    Reply
  2. gratis downloaden says:

    Hey, ok, I get it, I guess – but does this really work?

    Reply
  3. namran says:

    well.. it worked for me..

    much depend on how did u want to use it..

    … this is just another note for me.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *