Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 113 additions & 16 deletions IP-Changer.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,122 @@
import os
import subprocess
import requests
import time
import sys
from scr import main_win
from scr import main_linux
import os

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}======================

def run_windows_script():
print("Running Windows script...")
main_win.main()
{3}{5}GitHub Profile {2}{6}:{0}{1} https://github.com/isPique{0}
'''.format(DEFAULT, GREEN, RED, YELLOW, YELLOW2, ITALIC, BLINK))

def run_linux_script():
print("Running Linux script...")
main_linux.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 main():
if os.name == 'nt':
run_windows_script()
elif os.name == 'posix':
run_linux_script()
else:
print("Unsupported operating system")
sys.exit(1)
# 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 __name__ == '__main__':
main()
84 changes: 8 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@

# 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 the Tor service, and you got a new IP :D

> **IMPORTANT**
> This version of the tool is supported on both Linux and Windows operating systems.

## Features
- Automatic Tor IP address change.
- Supports both Linux and Windows.
- Requires Tor service to be running.
* 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

## Installation
> [!IMPORTANT]
> This version of the tool is currently supported only on Unix-like operating systems.

### Linux
## Usage

1. Clone the repository:

Expand All @@ -35,71 +27,11 @@ Restart the Tor service, and you got a new IP :D
pip install -r requirements.txt
```

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:
4. Run the script:

```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
<br>

![Terminal](https://github.com/isPique/Tor-IP-Changer/blob/main/Terminal.jpg)
118 changes: 0 additions & 118 deletions scr/main_linux.py

This file was deleted.

Loading
Loading