Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 25th, 2012  |  syntax: PHP  |  size: 4.12 KB  |  hits: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3.    Yangon Ethical Hacker Group's DDoS Shield Beta 1.02
  4.    Proof of Concept and modified by br0 AKA TweetyCoaster(Myanmar, http://www.yehg.org)
  5.        0.9/Add remote IP to Warning messages modified by SaturnGod
  6.        (Myanmar, http://www.mysteryzillion.com, http://edu.mysteryzillion.com)
  7.        30-July-2008(Wednesday)
  8.        1.01/Added mailing system on 31-July-2008(Thursday) by TweetyCoaster
  9.        1.02/Added cross icon and seconds of at mail subject
  10.             on 31-July-2008(Thursday) by TweetyCoaster  
  11.    Based on a PHP script written by an unkown programmer(who we forgot name).
  12.    Special thanks to him/her.
  13. ================= How To Setup ============================
  14.    ------------------------------------------------------------
  15.    Copy this file and folder to same folder of ur index.php.
  16.    Add following line to ur index.php, after symbol "<?php"
  17.    include("tweety.php");
  18.    O.K. Now .... Ready to prevent .... !! good luck guys.... !! :-)
  19.    ------------------------------------------------------------
  20. */
  21.  
  22.   // INITIALIZATIONS:
  23.  
  24.   //   Set Value as ur choice but read first comment beside of values !!!!
  25.   //   I set it up my choice now !!!
  26.   //     Fixed:
  27.   $crlf=chr(13).chr(10);
  28.   $itime=3;  // minimum number of seconds between one-visitor visits
  29.   $imaxvisit=10;  // maximum visits in $itime x $imaxvisits seconds
  30.   $ipenalty=($itime * $imaxvisit);  // minutes for waitting
  31.   $iplogdir="./Tweetylogs/";
  32.   $iplogfile="AttackersIPs.Log";
  33.  
  34.   // Time
  35.   $today = date("Y-m-j,G");
  36.   $min = date("i");
  37.   $sec = date("s");
  38.   $r = substr(date("i"),0,1);
  39.   $m =  substr(date("i"),1,1);
  40.   $minute = 0;
  41.  
  42.   // Set ur admin's email address and others as u like
  43.   $to      = 'tweetycoaster@gmail.com';   //ur admin's email address
  44.   $headers = 'From: Little Lady Baby@yehg.net' . "\r\n" .   //  change as ur wish          
  45.                  'X-Mailer: yehg.net DDoS Attack Shield';
  46.   $subject = "Warning of Possible DoS Attack @ $today:$min:$sec";
  47.  
  48.  
  49.   //     Warning Messages:
  50.   $message1='<font color="red">Temporarily under heavy traffic or some like as DoS attack !!!</font><br>';
  51.   $message2='Please wait ... ';
  52.   $message3=' seconds or try again after some minutes from now.<br>';
  53.   $message4='<font color="blue">Protected by TweetyCoaster Little Lady Baby DDoS Shield !!!</font><br>If you are a human, change IP or using freedom, ultra surf etc.<br>We temporarily banned IP <b>'.$_SERVER["REMOTE_ADDR"].' </b>from DoS attack.';
  54.   $message5=' Your site got attacking or bot like visiting from IP address: '.$_SERVER["REMOTE_ADDR"];
  55.   $message6='<br><img src="./Tweetylogs/cross.gif" alt="" border="0">';
  56. //---------------------- End of Initialization ---------------------------------------  
  57.  
  58.   //     Get file time:
  59.   $ipfile=substr(md5($_SERVER["REMOTE_ADDR"]),-3);  // -3 means 4096 possible files
  60.   $oldtime=0;
  61.   if (file_exists($iplogdir.$ipfile)) $oldtime=filemtime($iplogdir.$ipfile);
  62.  
  63.   //     Update times:
  64.   $time=time();
  65.   if ($oldtime<$time) $oldtime=$time;
  66.   $newtime=$oldtime+$itime;
  67.  
  68.   //     Check human or bot:
  69.   if ($newtime>=$time+$itime*$imaxvisit)
  70.   {
  71.     //     To block visitor:
  72.     touch($iplogdir.$ipfile,$time+$itime*($imaxvisit-1)+$ipenalty);
  73.     header("HTTP/1.0 503 Service Temporarily Unavailable");
  74.     header("Connection: close");
  75.     header("Content-Type: text/html");
  76.     echo '<html><head><title>Overload Warning by Little Lady Baby DDoS Shield beta 1.02!!!</title></head><body><p align="center"><strong>'
  77.           .$message1.'</strong>'.$br;
  78.     echo $message2.$ipenalty.$message3.$message4.$message6.'</p></body></html>'.$crlf;
  79.    //     Mailing Warning Message to Site Admin
  80.      {
  81.         @mail($to, $subject, $message5, $headers);     
  82.      }
  83.     //     logging:
  84.     $fp=@fopen($iplogdir.$iplogfile,"a");
  85.     if ($fp!==FALSE)
  86.     {
  87.       $useragent='<unknown user agent>';
  88.       if (isset($_SERVER["HTTP_USER_AGENT"])) $useragent=$_SERVER["HTTP_USER_AGENT"];
  89.       @fputs($fp,$_SERVER["REMOTE_ADDR"].' on '.date("D, d M Y, H:i:s").' as '.$useragent.$crlf);
  90.     }
  91.     @fclose($fp);
  92.     exit();
  93.  
  94.   }
  95.  
  96.   //     Modify file time:
  97.   touch($iplogdir.$ipfile,$newtime);
  98.  
  99. ?>