Created
August 5, 2012 21:42
-
-
Save ruslanchek/3267237 to your computer and use it in GitHub Desktop.
Litle DDoS hack :-)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
if((!isset($_COOKIE) || !isset($_GET['r'])) || $_GET['r'] != $_COOKIE['r']){ | |
$rnd = md5(mt_rand()); | |
if($_SERVER['QUERY_STRING'] && !$_GET['r']){ | |
$s = '?' . $_SERVER['QUERY_STRING'] . '&r='.$rnd; | |
}else{ | |
$s = '?r='.$rnd; | |
}; | |
$request = "http://" . $_SERVER['HTTP_HOST'] . "/" . $_SERVER['PHP_SELF'] . $s; | |
die('<html><head><script type="text/javascript"> | |
function setCookie (name, value, expires, path, domain, secure) { | |
document.cookie = name + "=" + escape(value) + | |
((expires) ? "; expires=" + expires : "") + | |
((path) ? "; path=" + path : "") + | |
((domain) ? "; domain=" + domain : "") + | |
((secure) ? "; secure" : ""); | |
}; | |
var d = new Date(); | |
d.setHours(d.getHours() + 1); | |
setCookie("r", "'.$rnd.'", d, "/"); | |
document.location.href="'.$request.'" | |
</script></head><body></body></html>'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Скрипт пишет при помощи JS куку, с рандомным MD5-хешем, затем перебрасывает клиента опять на тот же самый, запрошенный им ранее адрес, с теми же параметрами + тот самый хеш, и проверяет его, в случае несовпадения или отсутствия куки делает die().
Помогает от небольших атак DDOS-ботов.