Загрузка...

PHP Детект и Обход анонимайзера

Тема в разделе Backend создана пользователем LolzTeam4ik 19 янв 2017. 359 просмотров

Загрузка...
  1. LolzTeam4ik
    LolzTeam4ik Автор темы 19 янв 2017 Заблокирован(а) 24 17 янв 2017
    Скрипт обходящий анонимайзеры по типу hidemyass.com, hideme.ru итп. и выводящий реальный ип пользователя:
    Код
    <?php
    // Абсолютный URL указывающий на эту же страницу
    $next_stage_uri = "http://www.site/script.php?s=1";
    // For CloudFlare
    $_SERVER["REMOTE_ADDR"] = isset($_SERVER["HTTP_CF_CONNECTING_IP"]) ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"];
    $stage = @$_GET['s'];
    function encodeJsStr($str) {
    return preg_replace_callback('/[^\w]/', function($match) {
    $code = ord($match[0]);
    if ($code <=255) {
    return sprintf('\x%02x', $code);
    } else {
    return sprintf('\u%04x', $code);
    }
    return $ch;
    }, $str);
    }
    $ip_str = htmlentities($_SERVER["REMOTE_ADDR"]);
    // красивости. не обязательны
    $css = <<<CSS
    body{width:100%;position:fixed;bottom:0;top:0;text-align:center;margin:0;padding:0}
    .stage1 #userip{font-size:24px}
    .stage1 #userip{font-size:48px}
    .stage0 strong{color:red}
    .stage1 strong{color:green}
    iframe#ifr{width:600px;height:200px;margin:0 auto}
    .centered{text-align:center;margin:0 auto}
    CSS;
    if (!$stage) {
    // собственно обход.
    //главный момент это атрибут formaction
    $iframe_html =<<<HTML
    <body>
    <form id="frm" action="/" method="post" style="visibility:hidden">
    <input name="q" type= "submit" value='ok' formaction="$next_stage_uri">
    </form>
    </body>
    HTML;
    $iframe_html_js = encodeJsStr($iframe_html);
    $page_js = <<<JS
    window.onload = function() {
    // детект переписывания страницы анонимайзером
    function detect() {
    var cont = this['document'].getElementById('container');
    var cnext = cont.nextSibling;
    while (cnext && cnext.nodeType != 1) {
    cnext = cnext.nextSibling;
    }
    var cprev = cont.previousSibling;
    while (cprev && cprev.nodeType != 1) {
    cprev = cprev.previousSibling;
    }
    var cparent = cont.parentNode;
    return cparent != document.body || cnext || cprev;
    }
    if (detect()) {
    alert("Embedding detected");
    }
    // создаем айфрейм который будет работать в обход анонимайзера
    var iframe = this['document']['createElement']('iframe');
    iframe.id = "ifr";
    iframe.frameBorder = "0";
    iframe.klass = "centered";
    this['document']['body']['appendChild'](iframe);
    var doc = iframe['contentWindow']['document'];
    doc['open'].call(doc);
    doc['write'].call(doc,'$iframe_html_js');
    doc['close'].call(doc);
    doc.forms[0].q.click();
    }
    JS;
    echo <<<HTML
    <html>
    <style>
    $css
    </style>
    <script>
    $page_js
    </script>
    <body class="centered stage0"><div id="container">
    <div id="userip">
    Your apparent ip is <strong>$ip_str</strong>
    </div>
    </div></body>
    </html>
    HTML;
    } else if ($stage == '1') {
    echo <<<HTML
    <style>
    $css
    </style>
    <body class="centered stage1"><div id="container">
    <div id="userip">
    Your direct ip is <strong>$ip_str</strong>
    </div>
    </div></body>
    HTML;
    }
    ?>
     
Top