Forked from donpdonp/gist:157f846004dc124c57d1f6ae7feacd7f
Created
November 7, 2017 19:46
-
-
Save eayoungs/302a30b9049a49efb8f2f904e7b7bf14 to your computer and use it in GitHub Desktop.
btmp iptables drop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TODAY=`date +'%b %e'` | |
WINNERS=`sudo lastb -a -10000 | grep "$TODAY" | awk '{print $10}' | sort | uniq -c| sort -n | tail -10` | |
echo WINNERS for $TODAY | |
OLDIFS="$IFS" | |
IFS=$'\n' | |
for i in $WINNERS | |
do | |
echo $i | |
i2=$(echo -e "${i}" | sed -e 's/^[[:space:]]*//') | |
count=$(echo $i2 | cut -f1 -d' ') | |
badhost=$(echo $i2 | cut -f2 -d' ') | |
if [[ $count -ge 200 ]] | |
then | |
echo iptables -A INPUT -s $i -j DROP | |
fi | |
done | |
IFS="$OLDIFS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment