44import sys
55import os
66
7- if os .name == 'nt' :
8- sys .exit ("This tool can only run on Linux!" )
7+ if os .name not in [ 'nt' , 'posix' ] :
8+ sys .exit ("This tool only supports Linux and Windows !" )
99
1010def display_banner ():
1111 os .system ('cls' if os .name == 'nt' else 'clear' )
12- DEFAULT , GREEN , RED , YELLOW , YELLOW2 , ITALIC , BLINK = '\033 [0m' , '\033 [1;92m' , '\033 [1;31m' , '\033 [1;33m' , '\033 [1;93m' , '\033 [3m' , ' \033 [5m '
12+ DEFAULT , GREEN , RED , YELLOW , YELLOW2 , ITALIC = '\033 [0m' , '\033 [1;92m' , '\033 [1;31m' , '\033 [1;33m' , '\033 [1;93m' , '\033 [3m'
1313
1414 print ('''
1515{4} █████ ███████████ █████████ █████ █████ █████████ ██████ █████ █████████ ██████████ ███████████{0}
@@ -22,28 +22,22 @@ def display_banner():
2222{4}░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░{0}
2323
2424 {1}{5}================ {1}{5}======================
25- {3}{5}Version: {2}1 .0{2} {3}{5}Code Author: {2}isPique
25+ {3}{5}Version: {2}2 .0{2} {3}{5}Code Author: {2}isPique
2626 {1}{5}================ {1}{5}======================
2727
28- {3}{5}GitHub Profile {2}{6}:{0}{1} https://github.com/isPique{0}
29- ''' .format (DEFAULT , GREEN , RED , YELLOW , YELLOW2 , ITALIC , BLINK ))
30-
31- def install_tor ():
32- if subprocess .run (['which' , 'tor' ], stdout = subprocess .PIPE , stderr = subprocess .PIPE ).returncode != 0 :
33- print ("\033 [1;91m[!]\033 [1;93m Tor is not installed. Installing it...\033 [0m" )
34- if os .system ("sudo apt install tor -y > /dev/null 2>&1" ):
35- print ("\033 [1;91m[!]\033 [1;93m Failed to install Tor!\n \033 [1;91m[!]\033 [1;93m Please check your network connection.\033 [0m" )
36- return False
37- else :
38- print ("\033 [1;92m[+] Tor has been successfully installed.\033 [0m" )
39- time .sleep (1 )
40- return True
28+ {3}{5}GitHub Profile {2}:{0}{1} https://github.com/isPique{0}
29+ ''' .format (DEFAULT , GREEN , RED , YELLOW , YELLOW2 , ITALIC ))
4130
4231def main ():
43- # Check if script is running with root privileges
44- if os .geteuid () != 0 :
32+ os . system ( 'cls' if os . name == 'nt' else 'clear' )
33+ if os .name == 'posix' and os . geteuid () != 0 :
4534 print ("\033 [1;91m[!]\033 [1;93m This script must be run with root privileges.\033 [0m" )
4635 return
36+ else :
37+ tor_process = None
38+ tor_url = "https://archive.torproject.org/tor-package-archive/torbrowser/14.0.4/tor-expert-bundle-windows-x86_64-14.0.4.tar.gz"
39+ filename = "tor.tar.gz"
40+ default_extract_path = "tor_path.txt"
4741
4842 url = "https://httpbin.org/ip"
4943 proxy = {
@@ -54,18 +48,69 @@ def main():
5448 try :
5549 print ("\033 [1;34m[*] Checking if Tor is installed...\033 [0m" )
5650 time .sleep (1 )
57- if not install_tor ():
58- return
59- else :
60- print ("\033 [1;92m[+] Tor is already installed.\033 [0m" )
61- time .sleep (1 )
62-
51+ if os .name == 'posix' :
52+ if subprocess .run (['which' , 'tor' ], stdout = subprocess .PIPE , stderr = subprocess .PIPE ).returncode != 0 :
53+ print ("\033 [1;91m[!]\033 [1;93m Tor is not installed. Installing it...\033 [0m" )
54+ if os .system ("sudo apt install tor -y > /dev/null 2>&1" ):
55+ print ("\033 [1;91m[!]\033 [1;93m Failed to install Tor!\n \033 [1;91m[!]\033 [1;93m Please check your network connection.\033 [0m" )
56+ return False
57+ else :
58+ print ("\033 [1;92m[+] Tor has been successfully installed.\033 [0m" )
59+ time .sleep (1 )
60+ else :
61+ print ("\033 [1;92m[+] Tor is already installed.\033 [0m" )
62+ time .sleep (1 )
63+ elif os .name == 'nt' :
64+ with open (default_extract_path , "r" ) as f :
65+ extract_path = f .read ().strip ()
66+ tor_path = f"{ extract_path } \\ Tor Expert Bundle\\ tor\\ tor.exe"
67+
68+ if not os .path .exists (tor_path ):
69+ print ("\033 [1;91m[!]\033 [1;93m Tor is not installed.\033 [0m" )
70+ import urllib .request
71+ import tarfile
72+
73+ try :
74+ print (f"\033 [1;34m[*] Downloading latest stable Tor version from '{ tor_url } '" )
75+ urllib .request .urlretrieve (tor_url , filename )
76+ print ("\033 [1;92m[+] Download complete.\033 [0m" )
77+ except urllib .error .HTTPError as err :
78+ sys .exit (f"\033 [1;91m[-] HTTP Error { err .code } : { err .reason } \033 [0m" )
79+
80+ user_choice = input (f"\033 [1;92m[>] The script will extract Tor to the '{ extract_path } ' by default. Do you want to change it? (y/N) \xBB \033 [0m\033 [1;77m " ).strip ().lower ()
81+ if user_choice in ['n' , 'no' ]:
82+ print (f"\033 [1;34m[*] Extracting Tor to the default directory '{ extract_path } \\ Tor Expert Bundle'..." )
83+ elif user_choice in ['y' , 'yes' ]:
84+ extract_path = input ("\033 [1;92m[>] Enter the desired extraction directory:\033 [0m\033 [1;77m " ).strip ()
85+ if not os .path .exists (extract_path ):
86+ sys .exit (f"\033 [1;93m[!] The path '{ extract_path } ' does not exist.\033 [0m" )
87+ elif not os .access (extract_path , os .W_OK ):
88+ sys .exit (f"\033 [1;91m[-] The path '{ extract_path } ' is not writable. Please choose another location.\033 [0m" )
89+ else :
90+ sys .exit ("\033 [1;91m[-] Invalid choice.\033 [0m" )
91+ try :
92+ with tarfile .open (filename , "r:gz" ) as tar :
93+ tar .extractall (f"{ extract_path } \\ Tor Expert Bundle" , filter = 'fully_trusted' )
94+ os .remove (filename )
95+ print (f"\033 [1;92m[+] Tor has been successfully extracted to the '{ extract_path } \\ Tor Expert Bundle'\033 [0m" )
96+ with open (default_extract_path , "w" ) as f :
97+ f .write (extract_path )
98+ time .sleep (3 )
99+ except tarfile .ReadError :
100+ sys .exit ("\033 [1;91m[-] The file is not a valid tar archive or is corrupted.\033 [0m" )
101+ else :
102+ print ("\033 [1;92m[+] Tor is already installed.\033 [0m" )
103+ time .sleep (1 )
104+ tor_path = f'{ extract_path } \\ Tor Expert Bundle\\ tor\\ tor.exe'
63105 display_banner ()
64106
65107 try :
66- version_info = os .popen ("tor --version" ).read ().strip ()
67- version = version_info .split ('\n ' )[0 ].split (' ' )[2 ]
68- print (f"\033 [1;34m[*] Your Tor version is: { version } \033 [0m" )
108+ if os .name == 'posix' :
109+ version = os .popen ("tor --version" ).read ().strip ().split ('\n ' )[0 ].split (' ' )[2 ]
110+ print (f"\033 [1;34m[*] Your Tor version is: { version } \033 [0m" )
111+ elif os .name == 'nt' :
112+ version = subprocess .run ([tor_path , "--version" ], capture_output = True , text = True , check = True ).stdout .splitlines ()[0 ].split (" " )[2 ]
113+ print (f"\033 [1;34m[*] Your Tor version is: { version } \033 [0m" )
69114 except Exception :
70115 pass
71116
@@ -90,33 +135,44 @@ def main():
90135 time .sleep (1 )
91136
92137 print ("\033 [1;34m[*] Checking for Tor connection...\033 [0m" )
93-
94- tor_status = subprocess .run (["sudo" , "service" , "tor" , "status" ], capture_output = True , text = True )
95- if "Active: active" in tor_status .stdout :
96- print ("\033 [1;92m[+] Tor is already running.\033 [0m" )
97-
98- else :
99- print ("\033 [1;93m[-] Tor is not running.\033 [0m" )
100- print ("\033 [1;34m[*] Starting Tor service...\033 [0m" )
101- subprocess .run ("sudo service tor start" , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
102- time .sleep (3 )
138+ if os .name == 'posix' :
139+ if "Active: active" in subprocess .run (["sudo" , "service" , "tor" , "status" ], capture_output = True , text = True ).stdout :
140+ print ("\033 [1;92m[+] Tor is already running.\033 [0m" )
141+ else :
142+ print ("\033 [1;93m[-] Tor is not running. Starting Tor service...\033 [0m" )
143+ subprocess .run ("sudo service tor start" , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
144+ time .sleep (3 )
145+ elif os .name == 'nt' :
146+ if "tor.exe" in subprocess .run (["tasklist" ], capture_output = True , text = True ).stdout :
147+ print ("\033 [1;92m[+] Tor is already running.\033 [0m" )
148+ else :
149+ print ("\033 [1;93m[-] Tor is not running. Starting Tor...\033 [0m" )
150+ tor_process = subprocess .Popen ([tor_path ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
151+ time .sleep (3 )
103152
104153 while True :
105154 try :
106- response = requests .get (url , proxies = proxy )
155+ response = requests .get (url , proxies = proxy )
107156 changed_ip = response .json ().get ('origin' )
108157 print (f"\033 [1;92m[+] Your IP has been changed to { changed_ip } \033 [0m" )
109-
110158 except Exception :
111159 print (f"\033 [1;91m[-] Error!\033 [1;93m Failed to change IP. Retrying...\033 [0m" )
112160
113161 time .sleep (time_interval )
114- subprocess .run ("sudo service tor reload" , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
162+ if os .name == 'posix' :
163+ subprocess .run ("sudo service tor reload" , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
164+ elif os .name == 'nt' :
165+ subprocess .run (['taskkill' , '/F' , '/IM' , 'tor.exe' ], stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
166+ subprocess .Popen ([tor_path ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
115167
116168 except KeyboardInterrupt :
117169 print ("\n \033 [1;91m[!]\033 [1;93m Exiting...\033 [0m" )
118- print ("\033 [1;34m[*] Stopping Tor service...\033 [0m" )
119- subprocess .run ("sudo service tor stop" , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
170+ if os .name == 'posix' and "Active: active" in subprocess .run (["sudo" , "service" , "tor" , "status" ], capture_output = True , text = True ).stdout :
171+ print ("\033 [1;34m[*] Stopping Tor service...\033 [0m" )
172+ subprocess .run ("sudo service tor stop" , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
173+ elif os .name == 'nt' and tor_process :
174+ print ("\033 [1;34m[*] Stopping Tor service...\033 [0m" )
175+ tor_process .kill ()
120176
121177if __name__ == '__main__' :
122178 main ()
0 commit comments