diff --git a/IP-Changer.py b/IP-Changer.py index dcfa122..cc2aae3 100644 --- a/IP-Changer.py +++ b/IP-Changer.py @@ -1,122 +1,25 @@ -import subprocess -import requests -import time -import sys import os +import sys +from scr import main_win +from scr import main_linux -if os.name == 'nt': - sys.exit("This tool can only run on Linux!") - -def display_banner(): - os.system('cls' if os.name == 'nt' else 'clear') - 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' - - print(''' -{4} █████ ███████████ █████████ █████ █████ █████████ ██████ █████ █████████ ██████████ ███████████{0} -{4}░░███ ░░███░░░░░███ ███░░░░░███░░███ ░░███ ███░░░░░███ ░░██████ ░░███ ███░░░░░███░░███░░░░░█░░███░░░░░███{0} -{4} ░███ ░███ ░███ ███ ░░░ ░███ ░███ ░███ ░███ ░███░███ ░███ ███ ░░░ ░███ █ ░ ░███ ░███{0} -{4} ░███ ░██████████ ░███ ░███████████ ░███████████ ░███░░███░███ ░███ ░██████ ░██████████{0} -{4} ░███ ░███░░░░░░ ░███ ░███░░░░░███ ░███░░░░░███ ░███ ░░██████ ░███ █████ ░███░░█ ░███░░░░░███{0} -{4} ░███ ░███ ░░███ ███ ░███ ░███ ░███ ░███ ░███ ░░█████ ░░███ ░░███ ░███ ░ █ ░███ ░███{0} -{4} █████ █████ ░░█████████ █████ █████ █████ █████ █████ ░░█████ ░░█████████ ██████████ █████ █████{0} -{4}░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░{0} - - {1}{5}================ {1}{5}====================== - {3}{5}Version: {2}1.0{2} {3}{5}Code Author: {2}isPique - {1}{5}================ {1}{5}====================== - {3}{5}GitHub Profile {2}{6}:{0}{1} https://github.com/isPique{0} - '''.format(DEFAULT, GREEN, RED, YELLOW, YELLOW2, ITALIC, BLINK)) +def run_windows_script(): + print("Running Windows script...") + main_win.main() -def install_tor(): - if subprocess.run(['which', 'tor'], stdout = subprocess.PIPE, stderr = subprocess.PIPE).returncode != 0: - print("\033[1;91m[!]\033[1;93m Tor is not installed. Installing it...\033[0m") - if os.system("sudo apt install tor -y > /dev/null 2>&1"): - 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") - return False - else: - print("\033[1;92m[+] Tor has been successfully installed.\033[0m") - time.sleep(1) - return True +def run_linux_script(): + print("Running Linux script...") + main_linux.main() def main(): - # Check if script is running with root privileges - if os.geteuid() != 0: - print("\033[1;91m[!]\033[1;93m This script must be run with root privileges.\033[0m") - return - - url = "https://httpbin.org/ip" - proxy = { - 'http': 'socks5://127.0.0.1:9050', - 'https': 'socks5://127.0.0.1:9050' - } - - try: - print("\033[1;34m[*] Checking if Tor is installed...\033[0m") - time.sleep(1) - if not install_tor(): - return - else: - print("\033[1;92m[+] Tor is already installed.\033[0m") - time.sleep(1) - - display_banner() - - try: - version_info = os.popen("tor --version").read().strip() - version = version_info.split('\n')[0].split(' ')[2] - print(f"\033[1;34m[*] Your Tor version is: {version}\033[0m") - except Exception: - pass - - try: - response = requests.get(url) - current_ip = response.json()["origin"] - print(f"\033[1;34m[*] Your current IP address is: {current_ip}\033[0m") - except: - pass - - try: - time_interval = int(input("\033[1;92m[>] How often do you want to change your IP? (in seconds) \xBB\033[0m\033[1;77m ")) - if time_interval <= 0: - raise Exception - - except Exception: - print("\033[1;91m[!]\033[1;93m Time interval must be a positive integer.\033[0m") - return - - print(f"\033[1;91m[!]\033[1;93m Your IP address will be changed every {time_interval} seconds until you stop the script!") - print("\033[1;91m[!]\033[1;93m Press Ctrl + C to stop.") - time.sleep(1) - - print("\033[1;34m[*] Checking for Tor connection...\033[0m") - - tor_status = subprocess.run(["sudo", "service", "tor", "status"], capture_output = True, text = True) - if "Active: active" in tor_status.stdout: - print("\033[1;92m[+] Tor is already running.\033[0m") - - else: - print("\033[1;93m[-] Tor is not running.\033[0m") - print("\033[1;34m[*] Starting Tor service...\033[0m") - subprocess.run("sudo service tor start", shell = True, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) - time.sleep(3) - - while True: - try: - response = requests.get(url, proxies = proxy) - changed_ip = response.json().get('origin') - print(f"\033[1;92m[+] Your IP has been changed to {changed_ip}\033[0m") - - except Exception: - print(f"\033[1;91m[-] Error!\033[1;93m Failed to change IP. Retrying...\033[0m") - - time.sleep(time_interval) - subprocess.run("sudo service tor reload", shell = True, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) - - except KeyboardInterrupt: - print("\n\033[1;91m[!]\033[1;93m Exiting...\033[0m") - print("\033[1;34m[*] Stopping Tor service...\033[0m") - subprocess.run("sudo service tor stop", shell = True, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) + if os.name == 'nt': + run_windows_script() + elif os.name == 'posix': + run_linux_script() + else: + print("Unsupported operating system") + sys.exit(1) if __name__ == '__main__': main() diff --git a/README.md b/README.md index 81c8f51..04ba9af 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,21 @@ + # Auto Change Tor IP -* This tool automates the process of periodically changing the Tor IP address. -* Basically it enters a loop where it continuously fetches a new IP address through Tor proxies. -* Restart tor service, and you got a new IP :D +This tool automates the process of periodically changing the Tor IP address. +Basically, it enters a loop where it continuously fetches a new IP address through Tor proxies. +Restart the Tor service, and you got a new IP :D -> [!IMPORTANT] -> This version of the tool is currently supported only on Unix-like operating systems. +> **IMPORTANT** +> This version of the tool is supported on both Linux and Windows operating systems. -## Usage +## Features +- Automatic Tor IP address change. +- Supports both Linux and Windows. +- Requires Tor service to be running. + +## Installation + +### Linux 1. Clone the repository: @@ -27,11 +35,71 @@ pip install -r requirements.txt ``` -4. Run the script: +4. Install Tor (if not already installed): + + For Ubuntu/Debian-based systems, run: + + ```bash + sudo apt update + sudo apt install tor + ``` + +5. Run the script with root privileges: ```bash sudo python3 IP-Changer.py ``` -
+ +### Windows + +1. Clone the repository: + + ```bash + git clone https://github.com/isPique/Tor-IP-Changer.git + ``` + +2. Navigate to the project directory: + + ```bash + cd Tor-IP-Changer + ``` + +3. Install required libraries: + + ```bash + pip install -r requirements.txt + ``` + +4. Install Tor: + + Download and install Tor from the official website: [Tor Browser Download](https://www.torproject.org/download/) + + After installing, you should be able to start the Tor service. + +5. Run the script: + + Open Command Prompt (CMD) and navigate to the directory where the script is located, then run: + + ```bash + python IP-Changer.py + ``` + +## Usage + +1. The script will automatically detect your operating system (Linux or Windows) and run the appropriate version. +2. Once the script is running, it will periodically change your Tor IP address. +3. The IP address will be changed at the interval you specify (in seconds). +4. To stop the script, press `Ctrl + C` in the terminal. + +## Additional Information + +- On Linux, you may need to run the script with `sudo` privileges to interact with the Tor service. +- On Windows, make sure that the Tor service is running and accessible. If you face issues, ensure that the Tor executable is correctly set up in your system's PATH. + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +## Screenshot ![Terminal](https://github.com/isPique/Tor-IP-Changer/blob/main/Terminal.jpg) diff --git a/scr/main_linux.py b/scr/main_linux.py new file mode 100644 index 0000000..17601ac --- /dev/null +++ b/scr/main_linux.py @@ -0,0 +1,118 @@ +import subprocess +import requests +import time +import sys +import os +import platform + +def display_banner(): + os.system('cls' if platform.system() == 'Windows' else 'clear') # Clear the screen based on OS + 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' + + print(''' +{4} █████ ███████████ █████████ █████ █████ █████████ ██████ █████ █████████ ██████████ ███████████{0} +{4}░░███ ░░███░░░░░███ ███░░░░░███░░███ ░░███ ███░░░░░███ ░░██████ ░░███ ███░░░░░███░░███░░░░░█░░███░░░░░███{0} +{4} ░███ ░███ ░███ ███ ░░░ ░███ ░███ ░███ ░███ ░███░███ ░███ ███ ░░░ ░███ █ ░ ░███ ░███{0} +{4} ░███ ░██████████ ░███ ░███████████ ░███████████ ░███░░███░███ ░███ ░██████ ░██████████{0} +{4} ░███ ░███░░░░░░ ░███ ░███░░░░░███ ░███░░░░░███ ░███ ░░██████ ░███ █████ ░███░░█ ░███░░░░░███{0} +{4} ░███ ░███ ░░███ ███ ░███ ░███ ░███ ░███ ░███ ░░█████ ░░███ ░░███ ░███ ░ █ ░███ ░███{0} +{4} █████ █████ ░░█████████ █████ █████ █████ █████ █████ ░░█████ ░░█████████ ██████████ █████ █████{0} +{4}░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░{0} + + {1}{5}================ {1}{5}====================== + {3}{5}Version: {2}1.0{2} {3}{5}Code Author: {2}isPique + {1}{5}================ {1}{5}====================== + + {3}{5}GitHub Profile {2}{6}:{0}{1} https://github.com/isPique{0} + '''.format(DEFAULT, GREEN, RED, YELLOW, YELLOW2, ITALIC, BLINK)) + +def install_tor(): + if platform.system() == "Windows": + tor_installed = subprocess.run(["where", "tor"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode == 0 + if not tor_installed: + print("\033[1;91m[!]\033[1;93m Tor is not installed. Please install Tor from https://www.torproject.org/ and ensure it's added to your PATH.\033[0m") + return False + else: + tor_installed = subprocess.run(["which", "tor"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode == 0 + if not tor_installed: + print("\033[1;91m[!]\033[1;93m Tor is not installed. Installing it...\033[0m") + if subprocess.run(["sudo", "apt", "install", "tor", "-y"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode != 0: + 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") + return False + else: + print("\033[1;92m[+] Tor has been successfully installed.\033[0m") + return True + +def main(): + url = "https://httpbin.org/ip" + proxy = { + 'http': 'socks5://127.0.0.1:9050', + 'https': 'socks5://127.0.0.1:9050' + } + + try: + print("\033[1;34m[*] Checking if Tor is installed...\033[0m") + time.sleep(1) + if not install_tor(): + return + else: + print("\033[1;92m[+] Tor is already installed.\033[0m") + time.sleep(1) + + display_banner() + + try: + version_info = subprocess.run("tor --version", capture_output=True, text=True, shell=True) + version = version_info.stdout.split('\n')[0].split(' ')[2] + print(f"\033[1;34m[*] Your Tor version is: {version}\033[0m") + except Exception: + pass + + try: + response = requests.get(url) + current_ip = response.json()["origin"] + print(f"\033[1;34m[*] Your current IP address is: {current_ip}\033[0m") + except: + pass + + try: + time_interval = int(input("\033[1;92m[>] How often do you want to change your IP? (in seconds) \xBB\033[0m\033[1;77m ")) + if time_interval <= 0: + raise Exception + + except Exception: + print("\033[1;91m[!]\033[1;93m Time interval must be a positive integer.\033[0m") + return + + print(f"\033[1;91m[!]\033[1;93m Your IP address will be changed every {time_interval} seconds until you stop the script!") + print("\033[1;91m[!]\033[1;93m Press Ctrl + C to stop.") + time.sleep(1) + + print("\033[1;34m[*] Checking for Tor connection...\033[0m") + tor_status = subprocess.run(["tasklist", "/FI", "imagename eq tor.exe"], capture_output=True, text=True, shell=True) + if "tor.exe" in tor_status.stdout: + print("\033[1;92m[+] Tor is already running.\033[0m") + else: + print("\033[1;93m[-] Tor is not running.\033[0m") + print("\033[1;34m[*] Starting Tor service...\033[0m") + subprocess.run("start tor", shell=True) + time.sleep(3) + + while True: + try: + response = requests.get(url, proxies=proxy) + changed_ip = response.json().get('origin') + print(f"\033[1;92m[+] Your IP has been changed to {changed_ip}\033[0m") + except Exception: + print(f"\033[1;91m[-] Error!\033[1;93m Failed to change IP. Retrying...\033[0m") + + time.sleep(time_interval) + subprocess.run("start tor", shell=True) + + except KeyboardInterrupt: + print("\n\033[1;91m[!]\033[1;93m Exiting...\033[0m") + print("\033[1;34m[*] Stopping Tor service...\033[0m") + subprocess.run("taskkill /IM tor.exe /F", shell=True) + +if __name__ == '__main__': + main() diff --git a/scr/main_win.py b/scr/main_win.py new file mode 100644 index 0000000..e8d46fa --- /dev/null +++ b/scr/main_win.py @@ -0,0 +1,110 @@ +import subprocess +import requests +import time +import sys +import os + +if os.name != 'nt': + sys.exit("This tool can only run on Windows!") + +def display_banner(): + os.system('cls') # Clears screen on Windows + 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' + + print(''' +{4} █████ ███████████ █████████ █████ █████ █████████ ██████ █████ █████████ ██████████ ███████████{0} +{4}░░███ ░░███░░░░░███ ███░░░░░███░░███ ░░███ ███░░░░░███ ░░██████ ░░███ ███░░░░░███░░███░░░░░█░░███░░░░░███{0} +{4} ░███ ░███ ░███ ███ ░░░ ░███ ░███ ░███ ░███ ░███░███ ░███ ███ ░░░ ░███ █ ░ ░███ ░███{0} +{4} ░███ ░██████████ ░███ ░███████████ ░███████████ ░███░░███░███ ░███ ░██████ ░██████████{0} +{4} ░███ ░███░░░░░░ ░███ ░███░░░░░███ ░███░░░░░███ ░███ ░░██████ ░███ █████ ░███░░█ ░███░░░░░███{0} +{4} ░███ ░███ ░░███ ███ ░███ ░███ ░███ ░███ ░███ ░░█████ ░░███ ░░███ ░███ ░ █ ░███ ░███{0} +{4} █████ █████ ░░█████████ █████ █████ █████ █████ █████ ░░█████ ░░█████████ ██████████ █████ █████{0} +{4}░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░{0} + + {1}{5}================ {1}{5}====================== + {3}{5}Version: {2}1.0{2} {3}{5}Code Author: {2}isPique + {1}{5}================ {1}{5}====================== + + {3}{5}GitHub Profile {2}{6}:{0}{1} https://github.com/isPique{0} + '''.format(DEFAULT, GREEN, RED, YELLOW, YELLOW2, ITALIC, BLINK)) + +def install_tor(): + tor_installed = subprocess.run(["where", "tor"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode == 0 + if not tor_installed: + print("\033[1;91m[!]\033[1;93m Tor is not installed. Please install Tor from https://www.torproject.org/ and ensure it's added to your PATH.\033[0m") + return False + return True + +def main(): + url = "https://httpbin.org/ip" + proxy = { + 'http': 'socks5://127.0.0.1:9050', + 'https': 'socks5://127.0.0.1:9050' + } + + try: + print("\033[1;34m[*] Checking if Tor is installed...\033[0m") + time.sleep(1) + if not install_tor(): + return + else: + print("\033[1;92m[+] Tor is already installed.\033[0m") + time.sleep(1) + + display_banner() + + try: + version_info = subprocess.run("tor --version", capture_output=True, text=True, shell=True) + version = version_info.stdout.split('\n')[0].split(' ')[2] + print(f"\033[1;34m[*] Your Tor version is: {version}\033[0m") + except Exception: + pass + + try: + response = requests.get(url) + current_ip = response.json()["origin"] + print(f"\033[1;34m[*] Your current IP address is: {current_ip}\033[0m") + except: + pass + + try: + time_interval = int(input("\033[1;92m[>] How often do you want to change your IP? (in seconds) \xBB\033[0m\033[1;77m ")) + if time_interval <= 0: + raise Exception + + except Exception: + print("\033[1;91m[!]\033[1;93m Time interval must be a positive integer.\033[0m") + return + + print(f"\033[1;91m[!]\033[1;93m Your IP address will be changed every {time_interval} seconds until you stop the script!") + print("\033[1;91m[!]\033[1;93m Press Ctrl + C to stop.") + time.sleep(1) + + print("\033[1;34m[*] Checking for Tor connection...\033[0m") + tor_status = subprocess.run(["tasklist", "/FI", "imagename eq tor.exe"], capture_output=True, text=True, shell=True) + if "tor.exe" in tor_status.stdout: + print("\033[1;92m[+] Tor is already running.\033[0m") + else: + print("\033[1;93m[-] Tor is not running.\033[0m") + print("\033[1;34m[*] Starting Tor service...\033[0m") + subprocess.run("start tor", shell=True) + time.sleep(3) + + while True: + try: + response = requests.get(url, proxies=proxy) + changed_ip = response.json().get('origin') + print(f"\033[1;92m[+] Your IP has been changed to {changed_ip}\033[0m") + except Exception: + print(f"\033[1;91m[-] Error!\033[1;93m Failed to change IP. Retrying...\033[0m") + + time.sleep(time_interval) + subprocess.run("start tor", shell=True) + + except KeyboardInterrupt: + print("\n\033[1;91m[!]\033[1;93m Exiting...\033[0m") + print("\033[1;34m[*] Stopping Tor service...\033[0m") + subprocess.run("taskkill /IM tor.exe /F", shell=True) + +if __name__ == '__main__': + main()