Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Coded by DSTAT | Instagram: @DDoS_Filter
- // Public release of layer7.php from http://ddosfilter.net/
- //*********************************************************************************
- // In the command line type:
- // crontab -e
- // Paste this into the crontab and save: (Change directory to match your setup.)
- //
- // */1 * * * * > /var/www/html/conns.txt
- // 0 */1 * * * > /var/www/html/blacklist.txt
- //
- // Create files: blacklist.txt and conns.txt and put them in the layer7 directory.
- // IMPORTANT! Set both files permissions to 646.
- //
- // To protect a page with layer7.php add this code to the top of your pages:
- //
- // require '/var/www/html/layer7.php';
- /*
- /**********************************************************************************/
- $A = '/var/www/html/'; // Full path to layer7 files.
- $B = 'DOS Protection by @DDoS_Filter'; // Page title when displaying layer7.php.
- $C = 10; // SETS MAX REQUESTS PER MINUTE LIMIT.
- 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