From e06d632e92c61ba1c079dbf25dd230e9b60f54eb Mon Sep 17 00:00:00 2001 From: domx4q Date: Tue, 21 May 2024 22:22:49 +0200 Subject: [PATCH 1/3] run linter (ruff) --- autoTOR.py | 83 +++++++++++++++++++++++++++--------------------------- install.py | 30 +++++++++++--------- 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/autoTOR.py b/autoTOR.py index 2d928d5..758808f 100644 --- a/autoTOR.py +++ b/autoTOR.py @@ -5,49 +5,50 @@ import subprocess - - try: - check_pip3 = subprocess.check_output('dpkg -s python3-pip', shell=True) - if str('install ok installed') in str(check_pip3): + 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') - + 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 ') + 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) + 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 ') + 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 ") 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')) + 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("[+] Your IP has been Changed to : " + str(ma_ip())) -print('''\033[1;32;40m \n + +print("""\033[1;32;40m \n _ _______ /\ | | |__ __| / \ _ _| |_ ___ | | ___ _ __ @@ -56,31 +57,29 @@ def change(): /_/ \_\__,_|\__\___/ |_|\___/|_| 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() +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() + for i in range(int(lin)): + time.sleep(int(x)) + change() diff --git a/install.py b/install.py index e697d8f..3abe371 100644 --- a/install.py +++ b/install.py @@ -1,18 +1,20 @@ import os -choice = input('[+] to install press (Y) to uninstall press (N) >> ') -run = os.system -if str(choice) =='Y' or str(choice)=='y': - run('chmod 777 autoTOR.py') - run('mkdir /usr/share/aut') - run('cp autoTOR.py /usr/share/aut/autoTOR.py') +choice = input("[+] to install press (Y) to uninstall press (N) >> ") +run = os.system +if str(choice) == "Y" or str(choice) == "y": + run("chmod 777 autoTOR.py") + run("mkdir /usr/share/aut") + run("cp 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 & 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") From 8c366ee87bf3aa6fec16efe8e837f33ab13400fe Mon Sep 17 00:00:00 2001 From: domx4q Date: Tue, 21 May 2024 22:55:45 +0200 Subject: [PATCH 2/3] basic refactoring (backup) --- autoTOR.py | 110 ++++++++++++++++++++++++++--------------------------- install.py | 30 ++++++++++----- utils.py | 36 ++++++++++++++++++ 3 files changed, 110 insertions(+), 66 deletions(-) create mode 100644 utils.py diff --git a/autoTOR.py b/autoTOR.py index 758808f..77857da 100644 --- a/autoTOR.py +++ b/autoTOR.py @@ -1,37 +1,44 @@ # -*- coding: utf-8 -*- -import time import os import subprocess +import time +import requests -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") +from utils import OS, detectOS, printLogo -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 init(): + isLinux = detectOS() == OS.LINUX -os.system("clear") + if not isLinux: + print("Please make sure: python3, pip3, requests, tor are installed") + return + 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: + pass + 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 successfully ") + os.system("clear") def ma_ip(): @@ -48,38 +55,29 @@ def change(): 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") +if __name__ == "__main__": + init() + printLogo() -os.system("service tor start") + 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(3) + print("\033[1;32;40m change your SOCKETS 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 infinite 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() - except KeyboardInterrupt: - print("\nauto tor is closed ") - quit() - -else: - for i in range(int(lin)): - time.sleep(int(x)) - change() diff --git a/install.py b/install.py index 3abe371..566e76d 100644 --- a/install.py +++ b/install.py @@ -1,20 +1,30 @@ import os +import shutil -choice = input("[+] to install press (Y) to uninstall press (N) >> ") +from utils import detectOS, OS + +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 str(choice) == "Y" or str(choice) == "y": +if choice.lower() in ("y", "yes"): run("chmod 777 autoTOR.py") - run("mkdir /usr/share/aut") - run("cp autoTOR.py /usr/share/aut/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 "$@"' + 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") + 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 """ ) -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") +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") From b45dff61662d0c05d382874705612b0bb411868f Mon Sep 17 00:00:00 2001 From: domx4q Date: Tue, 21 May 2024 23:36:36 +0200 Subject: [PATCH 3/3] refactored to be usable on windows too --- autoTOR.py | 144 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 98 insertions(+), 46 deletions(-) diff --git a/autoTOR.py b/autoTOR.py index 77857da..6815a70 100644 --- a/autoTOR.py +++ b/autoTOR.py @@ -8,76 +8,128 @@ 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(): - isLinux = detectOS() == OS.LINUX + os_type = detectOS() - if not isLinux: - print("Please make sure: python3, pip3, requests, tor are installed") + if os_type == OS.UNKNOWN: + print("Unsupported operating system") return - 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: - pass - 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 successfully ") - os.system("clear") + + 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=dict(http="socks5://127.0.0.1:9050", https="socks5://127.0.0.1:9050"), - ) + get_ip = requests.get(url, proxies=DEFAULT_PROXIES) return get_ip.text +def __run_command(win_command: str, linux_command: str): + if detectOS() == OS.WINDOWS: + os.system(win_command) + else: + os.system(linux_command) + + def change(): - os.system("service tor reload") - print("[+] Your IP has been Changed to : " + str(ma_ip())) + __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() - os.system("service tor start") + start() time.sleep(3) - print("\033[1;32;40m change your SOCKETS 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 infinite ip change type [0] >>" - ) - if int(lin) == int(0): + 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(int(x)) + time.sleep(x) change() except KeyboardInterrupt: - print("\nauto tor is closed ") + print("\nAuto TOR is closed.") quit() - else: - for i in range(int(lin)): - time.sleep(int(x)) + for i in range(limit): + time.sleep(x) change()