diff --git a/autoTOR.py b/autoTOR.py index 2d928d5..6815a70 100644 --- a/autoTOR.py +++ b/autoTOR.py @@ -1,86 +1,135 @@ # -*- coding: utf-8 -*- -import time import os import subprocess +import time +import requests + +from utils import OS, detectOS, printLogo + +DEFAULT_CONNECTION = "127.0.0.1:9050" + +DEFAULT_PROXIES = { + "http": f"socks5://{DEFAULT_CONNECTION}", + "https": f"socks5://{DEFAULT_CONNECTION}", +} + + +def init(): + os_type = detectOS() + + if os_type == OS.UNKNOWN: + print("Unsupported operating system") + return + + if os_type == OS.WINDOWS: + print("Please make sure: python, pip, requests, tor are installed") + try: + subprocess.check_output("pip --version", shell=True) + print("[!] pip is installed successfully") + except subprocess.CalledProcessError: + print("[+] pip is not installed. Please install it manually.") + return + + try: + __import__("requests") + print("[!] python requests is installed") + except ImportError: + print("[+] python requests is not installed") + os.system("pip install requests") + os.system("pip install requests[socks]") + print("[!] python requests is installed successfully") + + try: + check_tor = subprocess.check_output("where tor", shell=True) + print("[!] tor is installed successfully") + except subprocess.CalledProcessError: + print("[+] tor is not installed! Please install it manually.") + return + else: # Assuming Linux or Mac + print("Please make sure: python3, pip3, requests, tor are installed") + try: + check_pip3 = subprocess.check_output("dpkg -s python3-pip", shell=True) + if str("install ok installed") in str(check_pip3): + pass + except subprocess.CalledProcessError: + print("[+] pip3 not installed") + subprocess.check_output("sudo apt update", shell=True) + subprocess.check_output("sudo apt install python3-pip -y", shell=True) + print("[!] pip3 installed successfully") + + try: + __import__("requests") + print("[!] python3 requests is installed") + except ImportError: + print("[+] python3 requests is not installed") + os.system("pip3 install requests") + os.system("pip3 install requests[socks]") + print("[!] python3 requests is installed successfully") + + try: + subprocess.check_output("which tor", shell=True) + except subprocess.CalledProcessError: + print("[+] tor is not installed!") + subprocess.check_output("sudo apt update", shell=True) + subprocess.check_output("sudo apt install tor -y", shell=True) + print("[!] tor is installed successfully") + os.system("clear") +def ma_ip(): + url = "https://www.myexternalip.com/raw" + get_ip = requests.get(url, proxies=DEFAULT_PROXIES) + return get_ip.text -try: - check_pip3 = subprocess.check_output('dpkg -s python3-pip', shell=True) - if str('install ok installed') in str(check_pip3): - pass -except subprocess.CalledProcessError: - print('[+] pip3 not installed') - subprocess.check_output('sudo apt update',shell=True) - subprocess.check_output('sudo apt install python3-pip -y', shell=True) - print('[!] pip3 installed succesfully') - - - -try: - - import requests -except Exception: - print('[+] python3 requests is not installed') - os.system('pip3 install requests') - os.system('pip3 install requests[socks]') - print('[!] python3 requests is installed ') -try: - - check_tor = subprocess.check_output('which tor', shell=True) -except subprocess.CalledProcessError: - print('[+] tor is not installed !') - subprocess.check_output('sudo apt update',shell=True) - subprocess.check_output('sudo apt install tor -y',shell=True) - print('[!] tor is installed succesfully ') +def __run_command(win_command: str, linux_command: str): + if detectOS() == OS.WINDOWS: + os.system(win_command) + else: + os.system(linux_command) -os.system("clear") -def ma_ip(): - url='https://www.myexternalip.com/raw' - get_ip= requests.get(url,proxies=dict(http='socks5://127.0.0.1:9050',https='socks5://127.0.0.1:9050')) - return get_ip.text def change(): - os.system("service tor reload") - print ('[+] Your IP has been Changed to : '+str(ma_ip())) - -print('''\033[1;32;40m \n - _ _______ - /\ | | |__ __| - / \ _ _| |_ ___ | | ___ _ __ - / /\ \| | | | __/ _ \ | |/ _ \| '__| - / ____ \ |_| | || (_) | | | (_) | | - /_/ \_\__,_|\__\___/ |_|\___/|_| - V 2.1 -from mrFD -''') -print("\033[1;40;31m http://facebook.com/ninja.hackerz.kurdish/\n") - -os.system("service tor start") - - - - -time.sleep(3) -print("\033[1;32;40m change your SOCKES to 127.0.0.1:9050 \n") -os.system("service tor start") -x = input("[+] time to change Ip in Sec [type=60] >> ") -lin = input("[+] how many time do you want to change your ip [type=1000]for infinte ip change type [0] >>") -if int(lin) ==int(0): - - while True: - try: - time.sleep(int(x)) - change() - except KeyboardInterrupt: - - print('\nauto tor is closed ') - quit() - -else: - for i in range(int(lin)): - time.sleep(int(x)) - change() + __run_command("tor.exe -service reload", "service tor reload") + print("[+] Your IP has been changed to: " + str(ma_ip())) + + +def start(): + __run_command("tor.exe", "service tor start") + + +if __name__ == "__main__": + init() + printLogo() + + start() + + time.sleep(3) + print(f"\033[1;32;40m Change your SOCKETS to {DEFAULT_CONNECTION}\n") + start() + try: + x = int(input("[+] Time to change IP in seconds [default=60] >> ")) + limit = int( + input( + "[+] how many times do you want to change your IP [default=1000]? For infinite IP change type [0] >> " + ) + ) + except ValueError: + x = 60 + limit = 1000 + print("[!] Invalid input. Using default values.") + + if limit == 0: + while True: + try: + time.sleep(x) + change() + except KeyboardInterrupt: + print("\nAuto TOR is closed.") + quit() + else: + for i in range(limit): + time.sleep(x) + change() diff --git a/install.py b/install.py index e697d8f..566e76d 100644 --- a/install.py +++ b/install.py @@ -1,18 +1,30 @@ import os -choice = input('[+] to install press (Y) to uninstall press (N) >> ') -run = os.system -if str(choice) =='Y' or str(choice)=='y': +import shutil + +from utils import detectOS, OS - run('chmod 777 autoTOR.py') - run('mkdir /usr/share/aut') - run('cp autoTOR.py /usr/share/aut/autoTOR.py') +if detectOS() != OS.LINUX: + print("This script is only for Linux") + exit() + +choice = str(input("[+] to install press (Y) to uninstall press (N) >> ")) +run = os.system +if choice.lower() in ("y", "yes"): + run("chmod 777 autoTOR.py") + os.mkdir("/usr/share/aut") + shutil.copy("utils.py", "/usr/share/aut/utils.py") + shutil.copy("autoTOR.py", "/usr/share/aut/autoTOR.py") - cmnd=(' #! /bin/sh \n exec python3 /usr/share/aut/autoTOR.py "$@"') - with open('/usr/bin/aut','w')as file: + cmnd = '#! /bin/sh \n exec python3 /usr/share/aut/autoTOR.py "$@"' + with open("/usr/bin/aut", "w") as file: file.write(cmnd) - run('chmod +x /usr/bin/aut & chmod +x /usr/share/aut/autoTOR.py') - print('''\n\ncongratulation auto Tor Ip Changer is installed successfully \nfrom now just type \x1b[6;30;42maut\x1b[0m in terminal ''') -if str(choice)=='N' or str(choice)=='n': - run('rm -r /usr/share/aut ') - run('rm /usr/bin/aut ') - print('[!] now Auto Tor Ip changer has been removed successfully') + run("chmod +x /usr/bin/aut") + print( + """\n\ncongratulation auto Tor Ip Changer is installed successfully \nfrom now just type \x1b[6;30;42maut\x1b[0m in terminal """ + ) +elif choice.lower() in ("n", "no"): + shutil.rmtree("/usr/share/aut") + os.remove("/usr/bin/aut") + print("[!] now Auto Tor Ip changer has been removed successfully") +else: + print("[!] wrong choice") diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..164a858 --- /dev/null +++ b/utils.py @@ -0,0 +1,36 @@ +import sys +from enum import Enum +from functools import cache + + +class OS(Enum): + WINDOWS = "windows" + MAC = "mac" + LINUX = "linux" + UNKNOWN = "unknown" + + +@cache +def detectOS() -> OS: + if sys.platform.startswith("win"): + return OS.WINDOWS + elif sys.platform.startswith("darwin"): + return OS.MAC + elif sys.platform.startswith("linux"): + return OS.LINUX + else: + return OS.UNKNOWN + + +def printLogo(): + print("""\033[1;32;40m \n + _ _______ + /\ | | |__ __| + / \ _ _| |_ ___ | | ___ _ __ + / /\ \| | | | __/ _ \ | |/ _ \| '__| + / ____ \ |_| | || (_) | | | (_) | | + /_/ \_\__,_|\__\___/ |_|\___/|_| + V 2.1 + from mrFD + """) + print("\033[1;40;31m http://facebook.com/ninja.hackerz.kurdish/\n")