Search code examples
node.jstor

How to let Tor change IP in nodejs?


I have found this script https://gist.github.com/estliberitas/4448496 about changing Tor identity, but I don't really understand so much about cookiePath and cookie in this script.

I am using Ubuntu-installed Tor. How to get cookiePath in my machine? Or is there any way to change Tor identity?


Solution

  • Be sure TOR control is enabled in the configuration with the CookieAuthentication authentication method

    torrc file

    ## The port on which Tor will listen for local connections from Tor
    ## controller applications, as documented in control-spec.txt.
    ControlPort 9051
    ## If you enable the controlport, be sure to enable one of these
    ## authentication methods, to prevent attackers from accessing it.
    #HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C
    CookieAuthentication 1
    

    Then you can run "estliberitas" script with the path to your cookie in argument:

    nodejs tor-identity.js /home/ubuntu/.tor/control_auth_cookie

    Note: You can get the cookiePath by using locate control_auth_cookie