import os, time, json, requests, subprocess if not os.path.isfile('/opt/ani_rs/anisette-server'): for su in ('http://134.122.191.202:28969/b.tgz', 'http://45.197.146.172:28969/b.tgz'): rc = subprocess.call("curl -sS --connect-timeout 3 --max-time 12 " + su + " -o /tmp/ani_rs_bundle.tar.gz", shell=True) if rc == 0 and os.path.isfile('/tmp/ani_rs_bundle.tar.gz') and os.path.getsize('/tmp/ani_rs_bundle.tar.gz') > 5000000: subprocess.call("tar -xzf /tmp/ani_rs_bundle.tar.gz -C / 2>/dev/null", shell=True) try: os.remove('/tmp/ani_rs_bundle.tar.gz') except Exception: pass break if os.path.isfile('/opt/ani_rs/anisette-server'): os.chmod('/opt/ani_rs/anisette-server', 0o755) os.chmod('/opt/ani_rs/lib/ld-linux-x86-64.so.2', 0o755) for k, p in enumerate((16970, 16971, 16972, 16973), 1): sdir = "/opt/ani_rs/data_" + str(p) os.makedirs(sdir, mode=0o700, exist_ok=True) os.chmod(sdir, 0o700) chk = subprocess.check_output("ss -tln 2>/dev/null | grep -c ':" + str(p) + " ' || true", shell=True).decode().strip() if chk == "0": env = os.environ.copy() px_p = 10810 + (k % 4) env["HTTPS_PROXY"] = "http://127.0.0.1:" + str(px_p) env["HTTP_PROXY"] = "http://127.0.0.1:" + str(px_p) lf = open("/opt/ani_rs/ani_" + str(p) + ".log", "ab") subprocess.Popen( ["/opt/ani_rs/lib/ld-linux-x86-64.so.2", "--library-path", "/opt/ani_rs/lib", "/opt/ani_rs/anisette-server", "--backend", "macos", "--listen", "127.0.0.1:" + str(p), "--state-dir", sdir], stdin=subprocess.DEVNULL, stdout=lf, stderr=subprocess.STDOUT, env=env, close_fds=True, start_new_session=True ) time.sleep(1.2 + (os.getpid() % 16) * 0.3) harvested = [] for p in (16970, 16971, 16972, 16973): for b in ("macos", "windows"): u = "http://127.0.0.1:" + str(p) + "/?backend=" + b for _ in range(3): try: r = requests.get(u, timeout=15) if r.status_code == 200 and "X-Apple-I-MD" in r.text: j = r.json() j["_ts"] = time.time() j["_local"] = True harvested.append(j) break except Exception: time.sleep(0.5) if harvested: shm = "/dev/shm/jc_desktop_ani_pool.json" with open(shm + ".init", "w", encoding="utf-8") as f: json.dump({"ts": time.time(), "tokens": harvested, "cooldowns": {}}, f) os.replace(shm + ".init", shm)