Joined: Sat Jul 02, 2011 8:56 pm Posts: 2
|
|
It's solved, thanks anyway. Here is the solution:
#!/bin/bash
MYIP=`ifconfig ${iface} | grep 'inet' | cut -d: -f2 | cut -d " " -f1 | grep -v 127` tcpdump -tn > file & sleep 10 pkill tcpdump AUX=`cat file | awk -F "." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | awk '$1 > 250' | grep -v "$MYIP"` if [ "$AUX" ] then i=0 for IP in $AUX do if [ $i -eq 2 ] then iptables -I INPUT -s $IP -j DROP i=0 else i=`expr $i + 1` fi done echo "DoS attack from:" echo $AUX echo "Sources blocked." rm file exit 2 else rm file exit 0 fi
|
|