You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
508 B
16 lines
508 B
#!/bin/bash
|
|
|
|
# must run with sudo!!!
|
|
|
|
while [ 1 ]
|
|
do
|
|
count=$(netstat -tn | awk '{print $4}' | grep :22 | wc -l)
|
|
if [ $count -gt 10 ]
|
|
then
|
|
attacker=$(netstat -tn | awk '{print $5}' | grep -v :22 | cut -d ':' -f1 | tail -1)
|
|
iptables -I INPUT -p tcp --dport 22 -s $attacker -m state --state NEW -j DROP
|
|
sleep 90
|
|
iptables -D INPUT -p tcp --dport 22 -s $attacker -m state --state NEW -j DROP
|
|
fi
|
|
sleep 1
|
|
done
|
|
|