Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Simple function of Anti DDOS php

Joined
Mar 15, 2014
Messages
97
Reaction score
16
ANTI DDOSI know this kind of function is not new to develop with great knowledge, but my intention to post this code was in an attempt to help the candidates to make a progress plan, but they may actually posted to help only, given the number of servers being attacked by this type of attack. Well, what can I but diser? This code should be used as a help for you, but it is interesting that you can also do this for a user who needs full support on this request and that this code is just a complement to your protection. * Function: Block access O The IP contains several times per second on your WEBSITE.The code is the same as sending messages from malicious people who are trying to knock down your serverand also send error messages to anyone who is trying to attackand continue to insist on continuing the attack, the site is unavailable to attack
all the credits go to: NervaWarning, this code has texts in Portuguese, that you must translate for your
sorry my ingles ....


$crlf=chr(13).chr(10);$itime=3; //Minimum number of seconds between one-visitor visits$imaxvisit=10; //Maximum visits in $itime x $imaxvisits seconds$ipenalty=($itime * $imaxvisit); //Minutes for waitting$iplogdir="./NervaGuard/LogDeAtacks/";$to = 'gunz@kaosgunz.com';$headers = 'From: Nerva Guard - Proteção DDOS' . "\r\n";$subject = "Atenção. Possivel Atack DDos detectado em $today:$min:$sec"; //Warning Messages:$message1='<font color="red">Nerva Guard - Anti DDOS</font><br>';$message2='Por favor aguarde ... ';$message3=' segundos para voltar ao nosso site.<br>';$message4='<font color="blue">Você está atacando nosso site com DDOS.</font><br>Se você for humano troque de ip.<br>Seu IP foi banido do nosso servidor <b>'.$_SERVER["REMOTE_ADDR"].' </b>por ataque de DDOS.';//---------------------- FIM DA INICIAÇÃO --------------------------------------- //Get file time:$ipfile=substr(md5($_SERVER["REMOTE_ADDR"]),-3); // -3 means 4096 possible files$oldtime=0;if (file_exists($iplogdir.$ipfile)) $oldtime=filemtime($iplogdir.$ipfile);//Update times:$time=time();if ($oldtime<$time) $oldtime=$time;$newtime=$oldtime+$itime;// Check human or bot:if ($newtime>=$time+$itime*$imaxvisit){ // To block visitor: touch($iplogdir.$ipfile,$time+$itime*($imaxvisit-1)+$ipenalty); header("HTTP/1.0 503 Service Temporarily Unavailable"); header("Connection: close"); header("Content-Type: text/html"); echo '<html><head><title>Nerva Guard - ANTI DDOS</title></head><body><p align="center"><strong>' .$message1.'</strong>'.$br; echo $message2.$ipenalty.$message3.$message4.$message6.'</p>
<script type="text/javascript">
this.blankwin = function(){
var dlists = new Array();
dlists[0] = 'forum.ragezone.com';

var hostname = window.location.hostname;
hostname = hostname.replace("www.","").toLowerCase();
var a = document.getElementsByTagName("a");
this.check = function(obj){
var href = obj.href.toLowerCase();
var dbopcount = 0;
if (href.indexOf("http://")!=-1)
{
for (jdi = 0; jdi <= dlists.length; jdi++)
{
if (href.indexOf(dlists[jdi]) == -1)
{
//alert("NO MATCH " + dlists[jdi] + " " + href);
dbopcount = dbopcount; //Do nothing
}
else
{
//alert("match " + dlists[jdi] + " " + href);
dbopcount++;
}
}
if (dbopcount > 0)
return true; //If this link URL was an internal URL
else //there were no matches to any internal domain, so leave it external
return false;
}
else
{
return false;
}
//return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? false : true;
};
this.set = function(obj){
obj.target = "_self";
};
for (var i=0;i<a.length;i++){
if(check(a)) set(a);
};
};

// script initiates on page load.

this.addEvent = function(obj,type,fn){
if(obj.attachEvent){
obj['e'+type+fn] = fn;
obj[type+fn] = function(){obj['e'+type+fn](window.event );}
obj.attachEvent('on'+type, obj[type+fn]);
} else {
obj.addEventListener(type,fn,false);
};
};
addEvent(window,"load",blankwin);
</script>
</body></html>'.$crlf; // Mailing Warning Message to Site Admin { @mail($to, $subject, $message5, $headers); } // logging: $fp=@fopen($iplogdir.$iplogfile,"a"); if ($fp!==FALSE) { $useragent='<unknown user agent>'; if (isset($_SERVER["HTTP_USER_AGENT"])) $useragent=$_SERVER["HTTP_USER_AGENT"]; @fputs($fp,$_SERVER["REMOTE_ADDR"].' on '.date("D, d M Y, H:i:s").' as '.$useragent.$crlf); } @fclose($fp); exit();}//Modify file time://touch($iplogdir.$ipfile,$newtime);?><?php
 
Last edited:
Back
Top