-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautt.py
36 lines (30 loc) · 1009 Bytes
/
autt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time
import requests
import os
# Tor SOCKS5 proxy settings
proxies = {
'http': 'socks5h://127.0.0.1:9050',
'https': 'socks5h://127.0.0.1:9050'
}
# Function to check current IP
def get_current_ip():
try:
response = requests.get("http://httpbin.org/ip", proxies=proxies, timeout=10)
return response.json().get("origin")
except requests.RequestException as e:
print(f"Error: {e}")
return None
# Loop to restart Tor and check IP
while True:
# Restart Tor service to obtain new IP
print("Restarting Tor for new IP...")
os.system("pkill tor") # Stop Tor
time.sleep(2) # Wait briefly
os.system("tor -f ~/.tor/torrc &") # Restart Tor with config
# Wait a moment for Tor to re-establish connection
time.sleep(5)
# Get and print the current IP
current_ip = get_current_ip()
print(f"Current IP: {current_ip}")
# Wait before restarting again (adjust this delay as needed)
time.sleep(10)