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