Advertisement
Neo-Craft

Anti-Syn-Flood

May 4th, 2012
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. while [ true ]
  4. do
  5.   BL=`iptables -L -n`
  6.   LISTE_IPS=`netstat -tanpu | awk '/SYN_RECV/ {print $5}' | cut -f1 -d':' | sort | uniq -c | awk '{if ($1 > 2) {print $2}}'`
  7.   if [ ! -z "$LISTE_IPS" ]
  8.   then
  9.     echo "$LISTE_IPS" | while read IP
  10.     do
  11.       echo "$BL" | grep "$IP" > /dev/null 2>&1
  12.       if [ $? -ne 0 ]
  13.       then
  14.         iptables -A INPUT -s $IP/24 -j DROP
  15.         echo "`date` - $IP bloquee"
  16.       fi
  17.     done
  18.     /etc/init.d/httpd stop > /dev/null 2>&1
  19.     sleep 5
  20.     /etc/init.d/httpd start > /dev/null 2>&1
  21.   fi
  22.   sleep 2
  23. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement