Description // Info
Source Code
<?php
define ('BLACKLIST','black.list');
foreach ($list as $addr) {
$host_addr=$_SERVER['REMOTE_ADDR'];
// Semplice indirizzo IP
if ($host_addr==$addr)
die ("Your IP is {$addr} and you're not allowed to view this page\n");
// Subnet di classe C
else if (preg_match('/(\d+\.\d+\.\d+)\.0\/24/',$addr,$sub)) {
die ("Your IP is {$host_addr} and you're not allowed to view this page\n");
}
// Subnet di classe B
else if (preg_match('/(\d+\.\d+)\.0\.0\/16/',$addr,$sub)) {
die ("Your IP is {$host_addr} and you're not allowed to view this page\n");
}
// Subnet di classe A
else if (preg_match('/(\d+)\.0\.0\.0\/8/',$addr,$sub)) {
die ("Your IP is {$host_addr} and you're not allowed to view this page\n");
}
}
?>
Comments
| POSTED BY: nexos ON 2010-10-08 13:46:50 |
| I won't use this script, because there are more effective ways to block (especially http) dos.
This script was userfull if it would save the dosing ips on its onwn. but i don't think this would work in php.
some simple iptables rules are much more effective and fast.
In addition, if your blacklist goes bigger and you are dosed, this script will put your webserver over the edge, because it reads and searches in the file every time a website is requested... |
You must be logged in to post comments.
|
|