Hola que tal soy nuevo en este foro y he estado checandolo y de verdad que se encuentra informacion muy util un saludo y felicitacion a todos los que escriben tutoriales y responden preguntas, gracias por compartir sus conocimientos.
fijense que soy webmaster de varias paginillas las cuales tengo hospedadas en servicios de hosting comunes y corrientes ( osea hosting compartido ) y recientemente a una de mis webs ha tenido ataques DoS y no he podido bannear las maquinas atacantes pues constantemente cambia de ips, leyendo este articulo vi que modificando uno de los mods del apache podiamos limitar el numero maximo de conexiones de cada ip, pero mi pregunta es ver si hay algun metodo de hacer esto usando archivos htaccess pues yo no tengo acceso a la configuracion del server ni del apache.
En caso de ser asi cual seria la sintaxis, espero me peudan ayudar gracias
Pues por htaccess no xD pero te dejo algo
:
<?
/*
/************************************************************
/
/ 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;
$ahora = date("Y-n-j H:i:s");
$safemode = 0;
$new = "";
$flooder =0;
$registered = 0;
$wwwdir = "/home/neosecur/public_html/";
$ahora = date("Y-n-j H:i:s");
if(!$file = @fopen($wwwdir."log.txt","r"))
$error = 1;
{
}
$i=0;
while($visitor[$i])
{
$iptime = explode("@",$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)
$new.=$_SERVER['REMOTE_ADDR']."@".strtotime($ahora)."\n";
$error = 1;
if(!$file = @fopen($wwwdir."log.txt","wt"))
$error = 1;
$error = 1;
if (!$fcount = @fopen($wwwdir."counter.txt","rt"))
$error = 1;
{
$visits = $count[0] + 1;
$count[0] = $visits;
}
else
{
$count[0] = 1;
}
$error = 1;
$new = $count[0]."@".$count[1];
if (!$fcount = @fopen($wwwdir."counter.txt","wt"))
$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)
{
if (!$fban = @fopen($wwwdir."bans.txt","rt")) $error = 1;
{
}
$i=0;
while ($ips[$i])
{
if ($_SERVER['REMOTE_ADDR'] == $ips[$i])
$registered = 1;
$i++;
$new .=$ips[$i];
}
if (!@fclose($fban)) $error = 1;
if (!$registered)
{
if (!$fban = @fopen($wwwdir."bans.txt","wt")) $error = 1;
$new .=$_SERVER['REMOTE_ADDR']."\n";
if (!@fclose($fban)) $error = 1;
}
else
{
if (!$fht = @fopen($wwwdir.".htaccess","rt"))
$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;
if (!$fht = @fopen($wwwdir.".htaccess","wt"))
$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";
?>
Suerte