-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (36 loc) · 1.24 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
import string
import random
import concurrent.futures
import os
import requests
from stem import Signal
from stem.control import Controller
def generate_domain(length):
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
def check_domain(domain):
try:
with Controller.from_port(port=9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)
response = requests.get(f'http://{domain}.onion')
if response.status_code == 200:
return True
else:
return False
except Exception as e:
print(f'Error: {e}')
return False
def check_domains(domains):
with concurrent.futures.ThreadPoolExecutor() as executor:
results = list(executor.map(check_domain, domains))
return results
domains = [generate_domain(i) for i in range(2, 549755813888)]
results = check_domains(domains)
if os.path.exists('result.txt'):
os.remove('result.txt')
with open('result.txt', 'w') as f:
for domain, result in zip(domains, results):
if result:
f.write(f'The domain {domain}.onion is available\n')
else:
f.write(f'The domain {domain}.onion is unavailable\n')