#!/usr/bin/python ########################################################################### ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## ## Please see: http://www.gnu.org/licenses/gpl.html for legal details, ## ## rights of fair usage, the disclaimer and warranty conditions. ## ########################################################################### ########################### Configuration ################################# # Add servers to this following the format in-sequence: # server name, server port, password TOR_SERVERS = [ [ 'tor1.server', 9151, 'password' ], [ 'tor2.server', 9151, 'password' ] ] ########################################################################### import os import socket def renewTorIdentity(host, port, password): try: s = socket.socket() s.connect((host, port)) s.send('AUTHENTICATE "' + password + '"' + os.linesep) resp = s.recv(1024) if not resp.startswith('250'): raise Exception(resp) s.send("SIGNAL NEWNYM" + os.linesep) resp = s.recv(1024) if not resp.startswith('250'): raise Exception(resp); s.send("QUIT" + os.linesep) if not resp.startswith('250'): raise Exception(resp); except: raise for server in TOR_SERVERS: try: renewTorIdentity(server[0], server[1], server[2]); except Exception as e: print "Unable to renew identity of", server[0], "due to:", e