SHOW:
|
|
- or go back to the newest paste.
1 | #! /usr/bin/env python | |
2 | ||
3 | """ | |
4 | - How To Use: - | |
5 | Change Tor settings from random pass on control port to chosen passwd | |
6 | imgur.com/hCaY1m5 | |
7 | Then launch tor_switcher.py ,enter control port passwd ,change time interval to whatever and press enter! | |
8 | Enjoy ip change every X amount of seconds ^_^ | |
9 | """ | |
10 | ||
11 | import random, telnetlib, thread, time | |
12 | from Tkinter import * | |
13 | ||
14 | class Switcher(Tk): | |
15 | def __init__(self): | |
16 | Tk.__init__(self) | |
17 | self.title(string = ".o0O| TOR Switcher |O0o.") | |
18 | ||
19 | self.host = StringVar() | |
20 | self.port = IntVar() | |
21 | self.passwd = StringVar() | |
22 | self.time = DoubleVar() | |
23 | ||
24 | self.host.set('localhost') | |
25 | self.port.set('9051') | |
26 | self.passwd.set('') | |
27 | self.time.set('30') | |
28 | ||
29 | Label(self, text = 'Host:').grid(row = 1, column = 1) | |
30 | Label(self, text = 'Port:').grid(row = 2, column = 1) | |
31 | Label(self, text = 'Password:').grid(row = 3, column = 1) | |
32 | Label(self, text = 'Interval:').grid(row = 4, column = 1) | |
33 | ||
34 | Entry(self, textvariable = self.host).grid(row = 1, column = 2, columnspan = 2) | |
35 | Entry(self, textvariable = self.port).grid(row = 2, column = 2, columnspan = 2) | |
36 | Entry(self, textvariable = self.passwd, show = '*').grid(row = 3, column = 2, columnspan = 2) | |
37 | Entry(self, textvariable = self.time).grid(row = 4, column = 2, columnspan = 2) | |
38 | ||
39 | Button(self, text = 'Start', command = self.start).grid(row = 5, column = 2) | |
40 | Button(self, text = 'Stop', command = self.stop).grid(row = 5, column = 3) | |
41 | ||
42 | self.output = Text(self, foreground="white", background="black", highlightcolor="white", highlightbackground="purple", wrap=WORD, height = 8, width = 40) | |
43 | self.output.grid(row = 1, column = 4, rowspan = 5) | |
44 | ||
45 | def start(self): | |
46 | self.write('TOR Switcher starting.') | |
47 | self.ident = random.random() | |
48 | thread.start_new_thread(self.newnym, ()) | |
49 | ||
50 | def stop(self): | |
51 | try: | |
52 | self.write('TOR Switcher stopping.') | |
53 | except: | |
54 | pass | |
55 | self.ident = random.random() | |
56 | ||
57 | def write(self, message): | |
58 | t = time.localtime() | |
59 | try: | |
60 | self.output.insert(END, '[%02i:%02i:%02i] %s\n' % (t[3], t[4], t[3], message)) | |
61 | except: | |
62 | print('[%02i:%02i:%02i] %s\n' % (t[3], t[4], t[3], message)) | |
63 | ||
64 | def newnym(self): | |
65 | key = self.ident | |
66 | host = self.host.get() | |
67 | port = self.port.get() | |
68 | passwd = self.passwd.get() | |
69 | interval = self.time.get() | |
70 | ||
71 | try: | |
72 | tn = telnetlib.Telnet(host, port) | |
73 | if passwd == '': | |
74 | tn.write("AUTHENTICATE\r\n") | |
75 | else: | |
76 | tn.write("AUTHENTICATE \"%s\"\r\n" % (passwd)) | |
77 | res = tn.read_until('250 OK', 5) | |
78 | ||
79 | if res.find('250 OK') > -1: | |
80 | self.write('AUTHENTICATE accepted.') | |
81 | else: | |
82 | self.write('Control responded "%s".') | |
83 | key = self.ident + 1 | |
84 | self.write('Quitting.') | |
85 | except Exception, ex: | |
86 | self.write('There was an error: %s.' % (ex)) | |
87 | key = self.ident + 1 | |
88 | self.write('Quitting.') | |
89 | ||
90 | while key == self.ident: | |
91 | try: | |
92 | tn.write("signal NEWNYM\r\n") | |
93 | res = tn.read_until('250 OK', 5) | |
94 | if res.find('250 OK') > -1: | |
95 | self.write('New identity established.') | |
96 | else: | |
97 | self.write('Control responded "%s".') | |
98 | key = self.ident + 1 | |
99 | self.write('Quitting.') | |
100 | time.sleep(interval) | |
101 | except Exception, ex: | |
102 | self.write('There was an error: %s.' % (ex)) | |
103 | key = self.ident + 1 | |
104 | self.write('Quitting.') | |
105 | ||
106 | try: | |
107 | tn.write("QUIT\r\n") | |
108 | tn.close() | |
109 | except: | |
110 | pass | |
111 | ||
112 | if __name__ == '__main__': | |
113 | mw = Switcher() | |
114 | mw.mainloop() | |
115 | mw.stop() |