41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
import requests
|
|
import concurrent.futures
|
|
import time
|
|
from requests_tor import RequestsTor
|
|
import os
|
|
from dotenv import load_dotenv
|
|
from ktvmanager.lib.get_urls import generate_urls_for_user
|
|
import json
|
|
load_dotenv()
|
|
|
|
rt = RequestsTor(tor_ports=(9001, 9002, 9003, 9004, 9005), tor_cport=9051, password=os.getenv('TORSPWD'), autochange_id=3)
|
|
|
|
def get_status(url):
|
|
try:
|
|
resp = rt.get(url=url, timeout=2)
|
|
if resp.status_code == 200:
|
|
if "<html><head>" not in resp.text:
|
|
response_data = json.loads(resp.text)
|
|
if response_data['user_info']['auth'] == 1:
|
|
return response_data
|
|
except:
|
|
pass
|
|
|
|
def find_url_for_user_details(username, password):
|
|
urls = generate_urls_for_user(username, password)
|
|
tm1 = time.perf_counter()
|
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
futures = []
|
|
for url in urls:
|
|
futures.append(executor.submit(get_status, url=url))
|
|
for future in concurrent.futures.as_completed(futures):
|
|
if future._result != None:
|
|
executor.shutdown(wait=False)
|
|
print(f"{future._result['user_info']['username']} - {future._result['server_info']['url']}:{future._result['server_info']['port']}")
|
|
tm2 = time.perf_counter()
|
|
print(f'Total time elapsed: {tm2-tm1:0.2f} seconds')
|
|
|
|
find_url_for_user_details('Karl061122', 'gkuEDWzxHD')
|
|
find_url_for_user_details('Karl130623', 'emYZWPs')
|
|
find_url_for_user_details('Karlos2306', 'Gg58Wg8MB9')
|
|
find_url_for_user_details('Maxine2306', 'EszFDNNcb2') |