Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function startsWith($haystack, $needle)
- {
- $length = strlen($needle);
- return (substr($haystack, 0, $length) === $needle);
- }
- function startsWithBlocked($needle)
- {
- $blockStarts = array(
- "wp-", "w00tw00t", "server-status", "cgi", "home", "docs", "xmlrpc", "admincp.php", "install.",
- "web.conf", "_vti_i", "version", "pass", "~", "php-bin", "thumbs", "appConf.htm", "user",
- "pma", "myadmin", "admin", "phpmyadmin", "php-my-admin", "webcalendar", "calendar", "dbadmin",
- "mysql", "include", "public_calendar", "web-calendar", "webcalendar", "wcalendar"
- );
- foreach($blockStarts as $i => $value)
- {
- if(startsWith($needle, $value))
- {
- return true;
- }
- }
- return false;
- }
- function Sanitize($uri)
- {
- $uri = strtolower($uri);
- $uri = urldecode($uri);
- while(startsWith($uri, "/") || startsWith($uri, "./"))
- {
- $length = strlen($uri);
- if(startsWith($uri, "/")) $uri = substr($uri, 1, $length - 1);
- else if(startsWith($uri, "./")) $uri = substr($uri, 2, $length - 2);
- }
- return $uri;
- }
- function Block($needle)
- {
- $needle = Sanitize($needle);
- return (startsWithBlocked($needle));
- }
- if(Block($_SERVER['REQUEST_URI']))
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- system("echo +$ip >> /proc/net/xt_recent/scandrop");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement