Can I detect Tor Browser inside the browser itself, via Javascript I suppose?

前端 未结 5 950
别那么骄傲
别那么骄傲 2021-01-02 15:05

I\'d like to disable some features of a web app I\'m building, if the browser is Tor Browser. Can I inside the browser itself (client side, not server side) find out if the

相关标签:
5条回答
  • 2021-01-02 15:43

    By the firefox resource bundle you can check it.

    The resource:// URI scheme is used by Firefox to call on-disk resources from internal modules and extensions.

    But some of these resources may also be included to any web page and executed via script tag. Mozilla developers is not consider the resources as a fingerprinting vector, despite the fact that some of them can reveal what the user does not wish. For example, differences in built-in preferences files clearly indicates you are using Windows or Linux or Mac, even if you're behind Tor Browser.

    https://www.browserleaks.com/firefox

    0 讨论(0)
  • 2021-01-02 15:50

    There is no reliable way to detect the TOR Browser... That's kind of a goal of that browser. If you find a reliable way, chances are somebody else finds it too, tells the TOR developers and they close it.

    E.g. all TOR Browser bundles report bogus, but reasonable User-Agents. The current release version e.g. says it is Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0 no matter what OS you're actually using.

    You may apply some heuristics to detect a TOR Browser with a certain probability, but will also generate some false-positives...

    • Check the user agent. TOR Browser will report the latest Firefox ESR on a certain OS, currently Windows 7 32-bit (but some users might have changed that again and other users might simply use the ESR release but not the TOR Browser)
    • Plugins are disabled, so navigator.plugins will be empty (but some users might have re-enabled plugins again).
    • etc.
    • Detect the browser actually uses the TOR network.

    Of course, you'll have to keep your checks up to date, so it requires a fair amount of maintenance busywork.

    Personally, given the less than stellar detection results, maintenance burden and very modest experience improvements for users, I wouldn't try to handle TOR Browser differently at all.

    0 讨论(0)
  • 2021-01-02 15:56

    The Tor browser is not designed to be undetectable (that's impossible to do). Rather, it is designed so that all copies are indistinguishable from each other: you cannot track a browser from one site to another, or from one visit to another, strictly through browser fingerprinting.

    This gives it a distinct fingerprint of its own. As of right now, a browser that

    1. Has a User-Agent of Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0
    2. Has a screen resolution that matches the browser window size (particularly if that size is 1000x800)
    3. Has a time zone of "0" (GMT)
    4. Has no plugins (navigator.plugins is empty)

    is probably the TBB browser. The User-Agent string may change when the next ESR version of Firefox comes out, most likely to Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/38.0.

    The screen resolution/browser window match alone may uniquely identify TBB: even in fullscreen mode, there's a one-pixel difference between window height and screen height in Firefox.

    0 讨论(0)
  • 2021-01-02 16:03

    The "official" way to detect tor is to check the user's IP address and see if it's a tor exit node. Tor runs TorDNSEL for this purpose.

    Here's a PHP implementation of a TorDNSEL lookup from a tutorial by Irongeek

    function IsTorExitPoint(){
        if (gethostbyname(ReverseIPOctets($_SERVER['REMOTE_ADDR']).".".$_SERVER['SERVER_PORT'].".".ReverseIPOctets($_SERVER['SERVER_ADDR']).".ip-port.exitlist.torproject.org")=="127.0.0.2") {
            return true;
        } else {
            return false;
        } 
    }
    
    function ReverseIPOctets($inputip){
        $ipoc = explode(".",$inputip);
        return $ipoc[3].".".$ipoc[2].".".$ipoc[1].".".$ipoc[0];
    }
    

    If you're not using PHP, you should still be able to adapt this relatively easily.

    Another method of detecting Tor is to have a script download the list of Tor exit nodes every half hour or so, then check each user's IP address against that list. This may be less reliable, though, as not all exit nodes are published. There's a list you can use, and instructions, available at dan.me.uk.

    EDIT: Since you updated your question, the second option (a list you host locally) is going to be preferable.

    0 讨论(0)
  • 2021-01-02 16:04

    There might be a quite reliable way. Check if it returns you a blank (white) image when you try to Base64 it using canvas. When you do so an notification is shown.

    No matter what user chooses JS returns a white image. So you can try to base64 (<-- it's a verb ;)) a non white image and then check if a white base64 image returned.

    UPD. Here is an example I made for myself. For me it was important to detect if I have an access to the image, but it can be used for Tor detecting in some way.

    UPD2. There even might be no notification shown as it's shown in code snippet below. Maybe because it's ran in an iframe.

    function isTorBrowser() {
        var img = document.createElement("img");
        // Creates a black 1x1 px image
        img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIW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6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAABJJREFUeNpiYmBgAAAAAP//AwAADAADpaqVBgAAAABJRU5ErkJggg==';
    
        var canvas = document.createElement("canvas");
        canvas.width = 1;
        canvas.height = 1;
        var ctx = canvas.getContext("2d");
        var imagedata = ctx.getImageData(0, 0, canvas.width, canvas.height);
        
        return imagedata.data[0] == 255 
                    && imagedata.data[1] == 255
                    && imagedata.data[2] == 255
                    && imagedata.data[3] == 255;
    }
    
    document.getElementById('tor-browser-test').innerHTML = isTorBrowser() ? 'Is Tor' : 'Not Tor';
    <div id="tor-browser-test"></div>

    0 讨论(0)
提交回复
热议问题