Advertisement
Guest User

noflood.php

a guest
Apr 22nd, 2012
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.53 KB | None | 0 0
  1. <?php
  2. //Download http://hidemyass.com/files/8jjbx/
  3. error_reporting('off');
  4. /*
  5. Ban HTTP flooders V2
  6. By AkaStep 4 brothers.
  7.  
  8. */
  9. define("MYDIRFORINC",substr(str_ireplace('\\','/',htmlentities(str_ireplace('\\','/',__FILE__))),0,strrpos(htmlentities(__FILE__),DIRECTORY_SEPARATOR)+1));//el vurma
  10. define("ROOTDIR",htmlentities($_SERVER['DOCUMENT_ROOT']).str_ireplace('\\','/',DIRECTORY_SEPARATOR). '.htaccess');//el vurma
  11. define("DEBUGMSG","INCLUDE EDILIB");// bu debug ucundur pozma ve deyisdirme onu.
  12. define("CRONFILE",'crontask.txt');
  13.  
  14.  
  15.  
  16.  
  17.  
  18. /*
  19. 1-saniyede maximum nece connect etse ban edek? default 7 connect
  20. Problem yaratsa ve gunahsiz userleri ban etse bu reqemi bir qeder artir.
  21.  
  22. */
  23. $limit=7;//
  24.  
  25. // HTACCESS BLOK IP //
  26. /* 1 yazsin htaccess-e.
  27. 0 yazmasin */
  28. $usehtaccess=1;// default yazir .htaccess-e
  29. // EOF HTACCESS BLOK IP //
  30.  
  31. /* EL VURMA HECNEYE ASAGIDA amma
  32. $msg-i ureyin istediyin kimi deyisdire bilersen)
  33. */
  34.  
  35. /* EOF */
  36.  
  37. $msg='<html>
  38. <head>
  39. <style type="text/css">
  40. body, a, a:hover {cursor: url(../images/cur116.cur), progress;}
  41. body
  42. {
  43. background-color: black;
  44. background-image: url(../images/backaground.jpg);
  45. }
  46. </style>' .
  47. '<title>Banned For Flood!</title></head>
  48. <body>' .
  49. str_repeat('<ul>'. PHP_EOL,8) .
  50. '<br>
  51. <br>
  52. <font color="red" size="15">' .PHP_EOL .
  53. 'Ban Edilmis&#601;n!<br>
  54. S&#601;b&#601;b:Flood Edirs&#601;n!<br>
  55. No Flood!<br>
  56. CoDeD By /AkaStep.<br>
  57. <br>'.PHP_EOL .
  58. '</font>'. str_repeat('</ul>'. PHP_EOL,8) .
  59. '</body>
  60. </html>';
  61.  
  62.  
  63.  
  64.  
  65. /* request kimden gelir onun IP adresini aliriq */
  66. $ip=htmlspecialchars($_SERVER['REMOTE_ADDR']);
  67. /* IP-nin formatini da yoxlayaq
  68. Cunki ekser hostlarda spoof edildiyi tedqirde IP adres real ip evezine istenilen pox pusur gostere biler(spoof edilmisi)
  69. */
  70. if(!filter_var($ip,FILTER_VALIDATE_IP,FILTER_FLAG_IPV4))
  71. {
  72. $error=1;
  73. }
  74.  
  75. if(isset($error))
  76. {
  77. unset($error);
  78. die($msg);
  79. }
  80. /* EOF IP CHECK */
  81.  
  82.  
  83. $usehtaccess=(int)$usehtaccess;
  84.  
  85.  
  86. /* Istesen deyisdir amma pozma bezi seyler bundan asilidir skriptde */
  87. $saltedhash='Ka?ydE#hdZeBOopzo~[BFy_S11?9G43FH
  88. <S3M+,\j[Reo#Av^+]1)>0k`=OVz5iZL=
  89. ,;&cAx/\3wMoj<Hks$wb(BU\KYqMCq_Am
  90. O^uh~pn(,{N7]8l[6^~j^\2Y54N8?2;M?
  91. |3(h>:}9C5-6#e(gxG?-W.vG{)VhGT:Ey
  92. xla;nIaG1$iO7P\ij5>>-c710YFbPI=QL
  93. n(kB#V4IC-JlO1zQcU=k9P}r;$g44d~s(
  94. Bc$4ru/EBT[p/sUl3yR4NLPl`2e3[ZHcF
  95. :aNgeGC+4FIUJTGXXH%kE-dlQnQpjp72]
  96. PI7DycRj#{YRz@okPP2%4rAb)#9r;yb4$
  97. jC@by(t5m[t&Kuv|)g/.6p\)zmnNHv5^u
  98. eN8+^mNYUi^DjnC1YJn:KIVPh(,;QbB6c
  99. B#{E6H=)KL:+MAt[fw4m~Y$--/7oa-7=Z
  100. ?%0kcc6`7L9i59pt@IW!]%W&}osx?|CaR
  101. >$k^_k?F>^M\{dJ7^Bros\)g7fnYb<by1
  102. @y`.2Hj/M?nz%r/exKD-`Ez65okP>McV!
  103. M1|UwI@yraH&yy7b<!;k5,8{*;nc1rW?F
  104. ';
  105.  
  106.  
  107.  
  108. $logfile=MYDIRFORINC .substr(sha1(md5($ip) . sha1(md5($saltedhash))),0,20) . '_temp_' . md5(str_ireplace('.','_',$ip)) . '.txt';// muveqqeti faylmiz.Deyisdirme!
  109. //die($logfile);
  110. $banfile=MYDIRFORINC .'banned.txt';// ban edilmislerin siyahisi.
  111.  
  112.  
  113. if(file_exists($banfile) && is_readable($banfile))
  114. {
  115.  
  116. $yoxlayiriqbanedilibyayox=file($banfile,FILE_IGNORE_NEW_LINES);
  117. /*
  118. Ban siyahisinda 50 den yuxari yazi varsa resurslari az yemesi ucun log faylin
  119. kopyasini yaradib kohnesini pozuruq.
  120. */
  121. if(count($yoxlayiriqbanedilibyayox) >50)
  122. {
  123. if(copy($banfile,MYDIRFORINC . 'bancopy_' .time() . '_.bak'))
  124. {
  125. @unlink($banfile);
  126. }
  127. }
  128. if(in_array($ip,$yoxlayiriqbanedilibyayox)) die($msg);
  129. }
  130.  
  131.  
  132. $time=time();
  133.  
  134.  
  135. $handle=fopen($logfile,'a+');
  136. fwrite($handle,$ip . '#' .$time . PHP_EOL);
  137. fclose($handle);
  138.  
  139.  
  140. $arr=file($logfile);
  141. $newtime=NULL;
  142. foreach($arr as $items)
  143. {
  144. $newip=substr($items,0,strpos($items,'#'));
  145. if($ip===$newip)
  146. {
  147. $newtime.=str_ireplace($newip . '#','',$items);
  148.  
  149. if(substr_count($newtime,$time) >=$limit)
  150. {
  151.  
  152.  
  153. //echo $newtime . '<br>';
  154. // Ban siyahisina atiriq //
  155. $newbanhandle=fopen($banfile,'a+');
  156. fwrite($newbanhandle,$ip . PHP_EOL);
  157. fclose($newbanhandle);
  158. // Ban siyahisina atdiq //
  159.  
  160.  
  161. /* .htaccess faylina atiriq hemin IP-ni *deny from xxx.xxx.xxx.xxx* metodu ile*/
  162. if($usehtaccess===1)
  163. {
  164. $htblockhandle=fopen(ROOTDIR,'a+');
  165. /* internal server errorun qarsini almaq ucun 2 CRLF (PHP_EOL) buraxdim burda.
  166. Xususile bu aiddir boyuk nagruzka altinda olanda Server .htaccess-e yazi sehv duse biler ve ehtimal boyuk olur log sehv yazilsin movqe baximindan.
  167. Her ehtimal ucun 2CRLF buraxdim internal server errorun qarsisini almaq ucun.*/
  168. fwrite($htblockhandle,PHP_EOL.'deny from ' . $ip .PHP_EOL);
  169. fclose($htblockhandle);
  170. }
  171.  
  172. /*EOF .htaccess -e atdiq IP adresi ve davam edirik */
  173.  
  174.  
  175. /* indi ise isimizi dayandiririq */
  176.  
  177. unlink($logfile);
  178. die($msg);
  179.  
  180. }
  181.  
  182.  
  183.  
  184. }
  185.  
  186. unset($items);
  187. }
  188.  
  189. /* EOF */
  190. writemydate();
  191.  
  192.  
  193. function writemydate()
  194. {
  195. if(!file_exists(MYDIRFORINC . CRONFILE))
  196. {
  197. $startdate=date('j/n/Y');
  198. $cronhandle=fopen(MYDIRFORINC . CRONFILE,'w+');
  199. fwrite($cronhandle,$startdate);
  200. fclose($cronhandle);
  201.  
  202. }
  203. }
  204.  
  205. checkcleanup();
  206.  
  207.  
  208. function checkcleanup()
  209.  
  210. {
  211.  
  212. $enddate=date('j/n/Y');// hesablamaq ucun. Indiki ile kecmisi.
  213. $croncontent=file_get_contents(MYDIRFORINC . CRONFILE);
  214. //die($croncontent);
  215. /* Cron faylimiza mudaxile olunubsa ve formati korlanibsa yenisini yaradiriq*/
  216. if(!ctype_digit(str_ireplace('/','',$croncontent)))
  217. {
  218. //die(MYDIRFORINC .CRONFILE);
  219.  
  220. unlink(MYDIRFORINC .CRONFILE);
  221. writemydate();
  222. }
  223. $startexplode=explode('/',$croncontent);
  224.  
  225. $startyear=@$startexplode[2]; // il
  226.  
  227. $startmonth=@$startexplode[1]; // ay
  228.  
  229. $startday=@$startexplode[0]; // gun
  230.  
  231. $strt = strtotime("{$startyear}/{$startmonth}/{$startday}");
  232.  
  233.  
  234. /* */
  235. $enddateexplode=explode('/',$enddate);
  236.  
  237. $enddate = strtotime("{$enddateexplode[2]}/{$enddateexplode[1]}/{$enddateexplode[0]}");
  238.  
  239. /* */
  240. //die((round(abs($strt-$enddate)/60/60/24) + 1));
  241.  
  242.  
  243. /* BU CRON 1 GUNDEN 1 TEKRARLANACAQ */
  244. //die(MYDIRFORINC);
  245.  
  246. if((round(abs($strt-$enddate)/60/60/24) + 1) >1)// 1 gunden bir temizleyeceyik
  247. {
  248. //baslayiriq temizlemeye zir zibilden bu direktoriyani
  249. $tempfiles=@scandir(MYDIRFORINC);
  250.  
  251. if(is_array($tempfiles) && count($tempfiles)!==0)
  252. {
  253. $initialize=NULL;
  254. foreach($tempfiles as $pozbunlari)
  255. {
  256. $pozbunlari=basename($pozbunlari);
  257. if($pozbunlari==='.' || $pozbunlari==='..' || is_dir(MYDIRFORINC .$pozbunlari)) continue;
  258. if(is_file(MYDIRFORINC .$pozbunlari) && stristr(MYDIRFORINC .$pozbunlari,'_temp_') && strlen($pozbunlari) >60)
  259. {
  260. $initialize++;
  261. @unlink(MYDIRFORINC.$pozbunlari);
  262. }
  263.  
  264.  
  265. }
  266. unset($pozbunlari);
  267. if(isset($initialize) && $initialize>=1) @unlink(MYDIRFORINC . CRONFILE);unset($initialize);
  268.  
  269. }
  270.  
  271.  
  272. }
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282. }
  283. /* EOF */
  284.  
  285.  
  286.  
  287. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement