Código
<? /* /************************************************************ / / NST Anti Denial of Service Script v 0.1 / / / / Author: Link < link07@gmail.com > / / ..::[N]eo [S]ecurity [T]eam::.. / / http://www.neosecurityteam.net / / Date: October - 2006 / / /************************************************************* This script will prevent Dos and DDos attacks using request flood of http packets, that causes your server to excecute to much connections with the database and execute tha php interpreter a lot of times in a few seconds, all you have to do to install this is include it in a script that all your scripts use , an script for the database connection for example and create three empty txt files on the same folder with write and read permissions: log.txt , bans.txt , counter.txt This script will ban users using the .htaccess file, so dont forget to put this is script on the same folder as the .htaccess file as well It is very configurable just modify the parameters indicated below , to asign how sctrict the script will act. */ $data = ""; $ban = ""; $visits = 1; $error = 0; $safemode = 0; $new = ""; $flooder =0; $registered = 0; $wwwdir = "/home/neosecur/public_html/"; $error = 1; { } $i=0; while($visitor[$i]) { if ($_SERVER['REMOTE_ADDR'] == $iptime[0]) { if ($tiempo <= 1) // this line controls the acces of an ip, only one request during the number of seconds you replace here { $safemode = 1; $flooder = 1; } $registered = 1; } $new .=$iptime[0]."@".$iptime[1]."\n"; $i++; } if (!$registered) $error = 1; $error = 1; $error = 1; $error = 1; { $visits = $count[0] + 1; $count[0] = $visits; } else { $count[0] = 1; } $error = 1; $new = $count[0]."@".$count[1]; $error = 1; $error = 1; $new = ""; $registered = 0; if ($visits > 4) // this line controls visits during a second, it is used to prevent ddos attacks you can modify this depending on the capacity of your server { $safemode = 1; if ($flooder) { { } $i=0; while ($ips[$i]) { if ($_SERVER['REMOTE_ADDR'] == $ips[$i]) $registered = 1; $i++; $new .=$ips[$i]; } if (!$registered) { $new .=$_SERVER['REMOTE_ADDR']."\n"; } else { $error = 1; $cont = ""; $cont2 = ""; $eob = 0; { if ($eob) $cont2.=$a; else { if ($a == "</Limit>\r\n" or $a == "</Limit>" or $a == "</Limit>\n") { $eob = 1; $cont2.=$a; } else $cont.=$a; } } $error = 1; $error = 1; $cont .= "Deny from ".$_SERVER['REMOTE_ADDR']."\n"; $cont .= $cont2; $error = 1; } } } if ($error) { echo "ocurrio un error inesperado por favor trata actualizando de nuevo o vuelve en un rato. Gracias por tu comprensión."; } if($safemode) { echo '<META HTTP-EQUIV="Refresh" CONTENT="2;URL=">'; } // if no restrictions have been activated , the content of the web will be displayed normally //echo "contenido"; ?>