Is it possible to block Tor users?

后端 未结 14 2147
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 04:03

Would it be possible to block Tor users? (https://www.torproject.org/)

Due to the nature of the site I run I should do all I can to stop multiple accounts and block cert

14条回答
  •  无人及你
    2021-01-30 04:46

    Since TorDNSEL was deprecated and replaced by a new system in Abril 2020 [1], most of the answers in this thread are outdated.

    After a bit of wrangling I came up with this code that uses the new checker. What id does is it reverses the ip octets and creates a URL for the new checker, then performs a DNS request and checks wether or not the first answer has the "127.0.0.2" IP. If this is the case, the user is deemed to come from Tor, otherwise it returns false.

    function IsTorExitPoint(){
        $dns_record = dns_get_record(ReverseIPOctets($_SERVER['REMOTE_ADDR']).".dnsel.torproject.org.");
    
        if ($dns_record && $dns_record[0] && $dns_record[0]["ip"] == "127.0.0.2") {
            return true;
        } else {
            return false;
        }
    }
    function ReverseIPOctets($inputip){
        $ipoc = explode(".",$inputip);
        return $ipoc[3].".".$ipoc[2].".".$ipoc[1].".".$ipoc[0];
    }
    

    [1] https://lists.torproject.org/pipermail/tor-project/2020-March/002759.html

    PD: It's been a while since I've posted an answer to stackoverflow, so please bear with me and help me improve if possible.

提交回复
热议问题