Advertisement
DSTAT

ddosfilter.net | Layer7 DOS Protection

Apr 18th, 2019 (edited)
3,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.84 KB | None | 0 0
  1. <?php
  2. // Coded by DSTAT | Instagram: @DDoS_Filter
  3. // Public release of layer7.php from http://ddosfilter.net/
  4. //*********************************************************************************
  5. // In the command line type:
  6. // crontab -e
  7. // Paste this into the crontab and save: (Change directory to match your setup.)
  8. //
  9. // */1 * * * * > /var/www/html/conns.txt
  10. // 0 */1 * * * > /var/www/html/blacklist.txt
  11. //
  12. // Create files: blacklist.txt and conns.txt and put them in the layer7 directory.
  13. // IMPORTANT! Set both files permissions to 646.
  14. //
  15. // To protect a page with layer7.php add this code to the top of your pages:
  16. //
  17. // require '/var/www/html/layer7.php';
  18. /*
  19. /**********************************************************************************/
  20.  
  21. $A = '/var/www/html/';                      // Full path to layer7 files.
  22. $B = 'DOS Protection by @DDoS_Filter';      // Page title when displaying layer7.php.
  23. $C = 10;                                    // SETS MAX REQUESTS PER MINUTE LIMIT.
  24.  
  25. if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $D = $_SERVER['HTTP_CF_CONNECTING_IP']; } else { $D = $_SERVER['REMOTE_ADDR']; } $E = file_get_contents($A.'blacklist.txt'); if (strpos($E, $D) !== false) { die('<html><head><title>'.$B.'</title></head><body><center><h1>Your IP is temporarily blacklisted.</h1><p>DOS Protection by @DDoS_Filter<br>http://ddosfilter.net/</p></center></body></html>'); } file_put_contents($A.'conns.txt',$D."\n", FILE_APPEND); $H = 0; if ($F = fopen($A.'conns.txt', 'r')) { while (!feof($F)) { $G = fgets($F); if ($D."\n" == $G) { $H++; if ($H == $C) { fclose($F); file_put_contents($A.'blacklist.txt',$D."\n", FILE_APPEND); die('<html><head><title>'.$B.'</title></head><body><center><h1>Your IP ('.$D.') has been temporarily blacklisted. Please try again later.</h1><p>DOS Protection by @DDoS_Filter<br>http://ddosfilter.net/</p></center></body></html>'); }}} fclose($F); } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement