Posted by: Mangesh_Linux_Administrator | July 25, 2010

Prevent DDOS on httpd


#!/bin/bash

z=10

cd ~/

netstat -plan |grep :80 | awk ‘{print $5}’ |cut -d: -f1 |sort |uniq -c |sort -n |tail -5 > ddos

cat ddos |sort -nr |awk ‘{print $1}’ > ddosnum
cat ddos |sort -nr |awk ‘{print $2}’ > ddosip

i=0

for j in `cat ddosnum`

do

if [ $j -ge $z ]
then
k=0
for l in `cat ddosip`
do
if [ $i = $k ]
then
csf -d $l
echo Denied $l
fi
k=k+1
done
fi

i=i+1

done

rm ddos ddosip ddosnum
~

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Categories

%d bloggers like this: