51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Проверка IP-гипотезы: чекаем нулевые аккаунты через ДРУГОЙ egress (прокси).
|
|
|
|
python ip_probe.py <proxy_url> [n]
|
|
"""
|
|
import json
|
|
import sys
|
|
|
|
import dpcode as D
|
|
|
|
|
|
def rows(n):
|
|
recs = {}
|
|
for line in open(D.BANK, encoding="utf-8"):
|
|
line = line.strip()
|
|
if not line:
|
|
continue
|
|
r = json.loads(line)
|
|
if r.get("cookies"):
|
|
recs[r["email"]] = r
|
|
zero = [r for r in recs.values()
|
|
if float(((r.get("theos") or {}).get("granted")) or 0) == 0]
|
|
return zero[:n]
|
|
|
|
|
|
def main():
|
|
px = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8899"
|
|
n = int(sys.argv[2]) if len(sys.argv) > 2 else 4
|
|
proxies = {"http": px, "https": px}
|
|
for rec in rows(n):
|
|
email = rec["email"]
|
|
machine = rec.get("machine") or D.machine_header(salt=email)
|
|
s = D.session_from(rec)
|
|
s.proxies.update(proxies)
|
|
try:
|
|
st, d = D.theos(s, machine)
|
|
except Exception as e:
|
|
print("%-42s ERR %s" % (email, str(e)[:60]), flush=True)
|
|
continue
|
|
if isinstance(d, dict):
|
|
print("%-42s http=%s bal=%s granted=%s refresh=%s"
|
|
% (email, st, d.get("balance"), d.get("granted"), d.get("refresh_at")), flush=True)
|
|
if float(d.get("balance") or 0) > 0 or float(d.get("granted") or 0) > 0:
|
|
rec["theos"] = d
|
|
D.append_bank(rec)
|
|
else:
|
|
print("%-42s http=%s %s" % (email, st, str(d)[:80]), flush=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |