initial commit
This commit is contained in:
commit
e12d10a1b1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.venv
|
84
main.py
Normal file
84
main.py
Normal file
@ -0,0 +1,84 @@
|
||||
import requests
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, Final
|
||||
|
||||
GET_ACCESS_TOKEN_URL: Final[str] = (
|
||||
"https://api-pro.ducunt.com/rest/v1/security/tokens/accs"
|
||||
)
|
||||
|
||||
get_access_token_payload: dict[str, str | dict[str, str]] = {
|
||||
"clientApp": {"name": "URBAN_VPN_BROWSER_EXTENSION"},
|
||||
"type": "accs",
|
||||
}
|
||||
|
||||
with requests.post(
|
||||
GET_ACCESS_TOKEN_URL,
|
||||
json=get_access_token_payload,
|
||||
headers={"Authorization": "Bearer On9GLm0c8B5GFWI9FYtdfPWlXfjhpF0Q"},
|
||||
) as request:
|
||||
security_token_payload: Any = request.json()
|
||||
|
||||
authentication_token: str = security_token_payload["value"]
|
||||
|
||||
GET_COUNTRIES_URL: Final[str] = (
|
||||
"https://stats.ducunt.com/api/rest/v2/entrypoints/countries"
|
||||
)
|
||||
|
||||
with requests.get(
|
||||
GET_COUNTRIES_URL,
|
||||
headers={
|
||||
"X-Client-App": "URBAN_VPN_BROWSER_EXTENSION",
|
||||
"Authorization": f"Bearer {authentication_token}",
|
||||
},
|
||||
) as request:
|
||||
countries_payload: Any = request.json()
|
||||
|
||||
hosts: list[Any] = [
|
||||
element["servers"]["elements"]
|
||||
for element in countries_payload["countries"]["elements"]
|
||||
if element["servers"]["count"] > 0
|
||||
]
|
||||
|
||||
|
||||
@dataclass
|
||||
class Host:
|
||||
ip: str
|
||||
port: str
|
||||
signature: str
|
||||
|
||||
|
||||
host_data: list[Host] = [
|
||||
Host(
|
||||
ip=element["address"]["primary"]["host"],
|
||||
port=element["address"]["primary"]["port"],
|
||||
signature=element["signature"] if "signature" in element else "",
|
||||
)
|
||||
for host in hosts
|
||||
for element in host
|
||||
]
|
||||
GET_ACCESS_PROXY_URL: Final[str] = (
|
||||
"https://api-pro.ducunt.com/rest/v1/security/tokens/accs-proxy"
|
||||
)
|
||||
|
||||
with Path("proxies").open("w", encoding="utf-8") as proxy_file:
|
||||
for host in host_data:
|
||||
|
||||
get_access_proxy_token_payload: dict[str, str | dict[str, str]] = {
|
||||
"clientApp": {"name": "URBAN_VPN_BROWSER_EXTENSION"},
|
||||
"signature": next(
|
||||
(host.signature for host in host_data if len(host.signature) > 0), ""
|
||||
),
|
||||
"type": "accs",
|
||||
}
|
||||
|
||||
with requests.post(
|
||||
GET_ACCESS_PROXY_URL,
|
||||
json=get_access_proxy_token_payload,
|
||||
headers={"Authorization": f"Bearer {authentication_token}"},
|
||||
) as request:
|
||||
response: Any = request.json()
|
||||
time.sleep(0.25)
|
||||
|
||||
proxy_file.write(f"http://{response['value']}:1@{host.ip}:{host.port}\n")
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
requests==2.32.3
|
Loading…
Reference in New Issue
Block a user