Skip to content

Instantly share code, notes, and snippets.

@fo0nikens
Created September 28, 2015 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fo0nikens/7e52c24178f4e10d7a2a to your computer and use it in GitHub Desktop.
Save fo0nikens/7e52c24178f4e10d7a2a to your computer and use it in GitHub Desktop.
tor-control protocol for rapidly switching circuits / new exit node to your tor instance

Playing with the Tor control protocol in node

Required module:

Tor control protocol specification

nw.js GUI source code

Ideas

  • create GUI tool for OS X, Linux, and Windows
  • Set timer so that every n interval the circuit is rotated
  • button for manaully switching circuit / getting new identity
  • button for stopping TOR

UPDATE

I made a simple nw.js app just to test the concept of making an application that would allow you to control the onion router and request a new exit node / identity.

Example functions:

/*
  This script uses the tor-control module to talk to the TOR control protocol.
  You must start TOR with the control protocol flag in order for this to work:
    $ tor -controlport 9051

  See full protocol spec here:
    https://gitweb.torproject.org/torspec.git/tree/control-spec.txt

*/

var TorControl = require('tor-control');
var control = new TorControl();

/*
  NEWNYM    -- Switch to clean circuits, so new application requests
                   don't share any circuits with old ones.  Also clears
                   the client-side DNS cache.  (Tor MAY rate-limit its
                   response to this signal.)
*/
function newIdent(){
  control.signalNewnym(function (err, status) { // Get a new circuit
    console.log(status); // --> "OK"
  });
}

/*
  SHUTDOWN  -- Controlled shutdown: if server is an OP, exit immediately.
                 If it's an OR, close listeners and exit after
                 ShutdownWaitLength seconds. (like INT)
*/
function shutDown(){
  control.signalHalt(function (err, status) { // Get a new circuit
    console.log(status);
  });
}

/*
  DUMP      -- Dump stats: log information about open connections and
                   circuits. (like USR1)
*/
function dump(){
  control.signalDump(function (err, status) { // Get a new circuit
    console.log(status);
  });
}

/*
  DEBUG     -- Debug: switch all open logs to loglevel debug. (like USR2)
*/
function debug(){
  control.signalDebug(function (err, status) { // Get a new circuit
    console.log(status);
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment