theos farm: 5 grants per egress IP (1834 theos/6 IP), rotate_farm, farm_grant, bd_probe, checkin/ip probes, tool-use+roundtrip proof
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Проверка Bright Data как источника egress-IP для фарма Theos.
|
||||
|
||||
Читает token из C:/Users/User/tmp/bd_token.json, тянет пароли зон,
|
||||
проверяет каждый порт/зону через api.ipify.org. Печатает только IP (без кредов).
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
TOK = "C:/Users/User/tmp/bd_token.json"
|
||||
CUST = "hl_a6a307bf"
|
||||
|
||||
|
||||
def token():
|
||||
d = json.load(open(TOK, encoding="utf-8"))
|
||||
for k in ("token", "api_token", "access_token"):
|
||||
if d.get(k):
|
||||
return d[k]
|
||||
for v in d.values():
|
||||
if isinstance(v, str) and len(v) > 20:
|
||||
return v
|
||||
return ""
|
||||
|
||||
|
||||
def zone_pw(tok, zone):
|
||||
try:
|
||||
r = subprocess.run(["curl", "-s", "-m", "15", "-H", "Authorization: Bearer " + tok,
|
||||
"https://api.brightdata.com/zone/passwords?zone=" + zone],
|
||||
capture_output=True, text=True, timeout=25)
|
||||
d = json.loads(r.stdout or "{}")
|
||||
return d.get("passwords") or d.get("password") or []
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
|
||||
def ip_of(url):
|
||||
try:
|
||||
r = subprocess.run(["curl", "-s", "-m", "20", "-x", url, "https://api.ipify.org"],
|
||||
capture_output=True, text=True, timeout=30)
|
||||
ip = (r.stdout or "").strip()
|
||||
return ip if ip.count(".") == 3 else ""
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
|
||||
def main():
|
||||
tok = token()
|
||||
print("token_len", len(tok))
|
||||
good = []
|
||||
for zone in ("serp", "browser_api", "unlocker", "residential"):
|
||||
pws = zone_pw(tok, zone)
|
||||
if not pws:
|
||||
print(zone, "нет пароля")
|
||||
continue
|
||||
pw = pws[0]
|
||||
for port in ("33335", "22225"):
|
||||
url = "http://brd-customer-%s-zone-%s:%s@brd.superproxy.io:%s" % (CUST, zone, pw, port)
|
||||
ip = ip_of(url)
|
||||
print("%-12s :%s -> %s" % (zone, port, ip or "FAIL"), flush=True)
|
||||
if ip:
|
||||
good.append(url)
|
||||
open("px_bd.txt", "w", encoding="utf-8").write("\n".join(good) + "\n")
|
||||
print("good", len(good))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user