From bdeac44425347db41d250301f74abf2b3448b2f5 Mon Sep 17 00:00:00 2001 From: reform Date: Sun, 15 Nov 2026 11:06:22 +0200 Subject: [PATCH] pool shim (key rotation, empty-200 retry, crow- prefix fix), proxy relays, wave dispatcher, sync; README: uncensored matrix + proxy notes --- .gitignore | 4 + README.md | 47 +++++++++ crowllm_sync.py | 55 ++++++++++ relay2.py | 96 +++++++++++++++++ shim.py | 267 ++++++++++++++++++++++++++++++++++++++++++++++++ wave_all.py | 133 ++++++++++++++++++++++++ 6 files changed, 602 insertions(+) create mode 100644 crowllm_sync.py create mode 100644 relay2.py create mode 100644 shim.py create mode 100644 wave_all.py diff --git a/.gitignore b/.gitignore index ff04f7d..9852aec 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ fail.jsonl accounts.jsonl prof_*/ *.session +keys*.jsonl +relays.json +*.jpg +*.png diff --git a/README.md b/README.md index 2c782a7..bfbe166 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,53 @@ curl -s -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ https://crowllm.com/v1/chat/completions ``` +## Pool mode (many keys behind one OpenAI endpoint) + +`shim.py` — stdlib-only OpenAI-compatible front that rotates the key pool: + +```bash +CROWL_KEYS=/opt/crowl-shim/keys.jsonl CROWL_PORT=48974 python3 shim.py +curl -s http://127.0.0.1:48974/healthz # {"ok":true,"keys":49,"dead":0} +curl -s -X POST http://127.0.0.1:48974/admin/reload # after a key sync +``` + +- `keys.jsonl` lines: `{"key": "...", "email": "...", "uid": 1, "status": "active"}` +- retries the next key on 429 / 5xx, parks a key on 401/403, appends `status: dead` back to the file +- **retries on an empty 200** — the "uncensored" models frequently answer 200 with an empty body, and a naive proxy returns that to the client +- model aliases: `crow-` → `:free`; `crow-kimi-k3` → `runpod/kimi-k3`; `crow-uncensored` / `crow-limitless` are crowllm's own ids and must **not** be prefix-stripped (otherwise `uncensored:free` → 503 `No available channel`) +- browser `User-Agent` is mandatory — plain urllib gets Cloudflare 403 on `/v1/*` and the whole pool dies silently + +`crowllm_sync.py` — dedupe the local bank and push it to the shim (`scp` + `/admin/reload`). Run it from cron; empty output means nothing changed. + +## Uncensored models — what actually works + +crowllm advertises `crow-uncensored`, `crow-limitless`, `deepseek-v4.1-flash-uncensored`, `qwen3.8-27b-uncensored`. Tested on an authorised red-team prompt (SSH brute-force script / reverse shell): + +| model | result | +|---|---| +| `deepseek-v4.1-flash-uncensored:free` | 200, 8.5 KB of working `ssh_brute.py` (paramiko + ThreadPool), ~35-70 s | +| `crow-limitless:free` | 200, python reverse shell with pty, ~6 s | +| `crow-uncensored:free` | 200, paramiko brute-force, ~9 s (flaky: first call may fail provider-side — retry) | +| `qwen3.8-27b-uncensored:free` | refuses ("Не могу предоставить рабочий скрипт…") | + +So three of four are genuinely uncensored on offensive-security prompts, and they answer *without* any jailbreak wrapper. + +## Proxies + +Cloudflare + Google see the IP, crowllm bans the **mailbox domain** (not the IP): a burned domain returns `/sign-in` for every signup even from a fresh residential IP. Still, proxies lift the success rate on a *fresh* domain (6 keys vs 1 in our runs). + +`relay2.py` turns auth-protected HTTP proxies into local no-auth CONNECT relays Chrome can use: + +```bash +python relay2.py decodo_pool.json 9431 # [{host, port, user, pass}, ...] +# relays.json: [{"local":"127.0.0.1:9431","up":"dc.decodo.com:10000","user":"..."}] +CROWL_PROXY=http://127.0.0.1:9431 python crowllm_reg.py example.com worker1 +``` + +Chrome cannot take `user:pass@host` in `--proxy-server`, and Playwright's socks5 support breaks on the first navigation — an HTTP CONNECT relay is the working path. + +`wave_all.py` — dispatcher: walks the account bank domain by domain, 6 workers with proxy rotation, two zero-key rounds on a domain → move to the next. + ## Pitfalls hit while building this - OAuth button needs the mouse event (see step 4) — this is the single biggest time sink. diff --git a/crowllm_sync.py b/crowllm_sync.py new file mode 100644 index 0000000..fa2e90f --- /dev/null +++ b/crowllm_sync.py @@ -0,0 +1,55 @@ +"""Sync local crowllm bank -> prod crowl-shim keys + reload. Safe to run repeatedly.""" +import json, os, subprocess, sys, time + +LOCAL = "C:/Users/User/tmp/crowllm/crowllm_bank.jsonl" +TMP = "C:/Users/User/tmp/crowllm/keys.jsonl" +KEY = "C:/Users/User/.ssh/id_ed25519" +HOST = "root@2.27.98.196" +SSH = ["ssh", "-o", "StrictHostKeyChecking=no", "-o", "ConnectTimeout=20", "-i", KEY, HOST] + + +def log(*a): + print(" ".join(str(x) for x in a), flush=True) + + +def main(): + if not os.path.exists(LOCAL): + log("no bank") + return 0 + rows, seen = [], set() + for line in open(LOCAL, encoding="utf-8"): + line = line.strip() + if not line: + continue + try: + j = json.loads(line) + except Exception: + continue + k = j.get("key") + if isinstance(k, dict): + k = k.get("key") + if not k or k in seen: + continue + seen.add(k) + rows.append({"key": k, "email": j.get("email"), "uid": j.get("uid"), "status": "active"}) + if not rows: + log("empty bank") + return 0 + with open(TMP, "w", encoding="utf-8") as f: + for r in rows: + f.write(json.dumps(r, ensure_ascii=False) + "\n") + p = subprocess.run(["scp", "-o", "StrictHostKeyChecking=no", "-i", KEY, TMP, + HOST + ":/opt/crowl-shim/keys.jsonl"], capture_output=True, text=True) + if p.returncode != 0: + log("scp failed", p.stderr[:200]) + return 1 + p = subprocess.run(SSH + ["curl -s -X POST --max-time 15 http://127.0.0.1:48974/admin/reload; echo; " + "curl -s --max-time 10 http://127.0.0.1:48974/healthz"], + capture_output=True, text=True) + log("remote:", (p.stdout or "").strip().replace("\n", " | ")[:200]) + log("synced keys:", len(rows)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file diff --git a/relay2.py b/relay2.py new file mode 100644 index 0000000..604e65b --- /dev/null +++ b/relay2.py @@ -0,0 +1,96 @@ +"""Local HTTP CONNECT relays with upstream Basic auth, for Chrome --proxy-server. + +Usage: python relay2.py decodo_pool.json [base_port] +Writes relays.json: [{local: "127.0.0.1:9431", up: "host:port", user: "..."}] +""" +import base64, json, socket, sys, threading, time + + +def pipe(a, b): + try: + while True: + r, _, _ = select.select([a, b], [], [], 60) + if not r: + continue + for s in r: + d = s.recv(65536) + if not d: + return + (b if s is a else a).sendall(d) + except Exception: + pass + finally: + for s in (a, b): + try: + s.close() + except Exception: + pass + + +import select + + +def handle(cli, up_host, up_port, auth): + try: + data = b"" + while b"\r\n\r\n" not in data: + ch = cli.recv(4096) + if not ch: + cli.close(); return + data += ch + if len(data) > 65536: break + line = data.split(b"\r\n")[0].decode("latin1") + method, target, _ = line.split(" ") + up = socket.create_connection((up_host, up_port), 20) + if method.upper() == "CONNECT": + hdr = "CONNECT %s HTTP/1.1\r\nHost: %s\r\n" % (target, target) + if auth: + hdr += "Proxy-Authorization: Basic %s\r\n" % auth + up.sendall((hdr + "\r\n").encode()) + resp = b"" + while b"\r\n\r\n" not in resp: + c = up.recv(4096) + if not c: break + resp += c + if b" 200" not in resp.split(b"\r\n")[0]: + cli.sendall(b"HTTP/1.1 502 Bad Gateway\r\n\r\n") + cli.close(); up.close(); return + cli.sendall(b"HTTP/1.1 200 Connection Established\r\n\r\n") + pipe(cli, up) + else: + rest = data.replace(b"Proxy-Connection:", b"X-Drop:") + if auth: + rest = rest.replace(b"\r\n\r\n", b"\r\nProxy-Authorization: Basic " + auth.encode() + b"\r\n\r\n", 1) + up.sendall(rest) + pipe(cli, up) + except Exception: + try: cli.close() + except Exception: pass + + +def serve(port, host, uport, auth): + srv = socket.socket() + srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + srv.bind(("127.0.0.1", port)) + srv.listen(64) + while True: + c, _ = srv.accept() + threading.Thread(target=handle, args=(c, host, uport, auth), daemon=True).start() + + +if __name__ == "__main__": + pool = json.load(open(sys.argv[1], encoding="utf-8")) + base = int(sys.argv[2]) if len(sys.argv) > 2 else 9431 + info, i = [], 0 + for p in pool: + host, port = p["host"], int(p["port"]) + auth = None + if p.get("user") and p.get("pass"): + auth = base64.b64encode(("%s:%s" % (p["user"], p["pass"])).encode()).decode() + threading.Thread(target=serve, args=(base + i, host, port, auth), daemon=True).start() + info.append({"local": "127.0.0.1:%d" % (base + i), "up": "%s:%s" % (host, port), "user": p.get("user")}) + i += 1 + json.dump(info, open("relays.json", "w"), indent=1) + print("relays up:", json.dumps(info), flush=True) + while True: + time.sleep(3600) \ No newline at end of file diff --git a/shim.py b/shim.py new file mode 100644 index 0000000..81cb113 --- /dev/null +++ b/shim.py @@ -0,0 +1,267 @@ +#!/usr/bin/env python3 +"""crowl-shim: OpenAI-compatible pool front for crowllm.com free-tier keys. + +Rotates keys round-robin, retries the next key on 429/5xx, parks keys on 401/403. +stdlib only (no fastapi on prod). +""" +import json, os, sys, time, threading, urllib.request, urllib.error +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer + +UPSTREAM = os.environ.get("CROWL_UPSTREAM", "https://crowllm.com/v1") +KEYS_FILE = os.environ.get("CROWL_KEYS", "/opt/crowl-shim/keys.jsonl") +PORT = int(os.environ.get("CROWL_PORT", "48960")) +TIMEOUT = int(os.environ.get("CROWL_TIMEOUT", "120")) +UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36" + +_lock = threading.Lock() +STATE = {"keys": [], "idx": 0, "dead": set(), "loaded": 0} + + + +ALIAS = {"crow-kimi-k3": "runpod/kimi-k3"} +# crowllm's own ids already start with "crow-" - never strip that prefix +KEEP_PREFIX = {"crow-uncensored", "crow-limitless"} + + +def to_upstream(model): + """crow-* alias -> crowllm free id""" + if not model: + return model + if model in ALIAS: + return ALIAS[model] + if model in KEEP_PREFIX: + return model + ":free" + if model.startswith("crow-") and not model.endswith(":free"): + return model[5:] + ":free" + return model + +def load_keys(): + keys, dead = [], set() + try: + with open(KEYS_FILE, encoding="utf-8") as f: + for line in f: + line = line.strip() + if not line: + continue + try: + j = json.loads(line) + except Exception: + continue + k = j.get("key") or j.get("api_key") + if not k: + continue + if isinstance(k, dict): + k = k.get("key") + if not k: + continue + if j.get("status") in ("dead", "parked"): + dead.add(k) + keys.append(str(k)) + except FileNotFoundError: + pass + with _lock: + STATE["keys"] = keys + STATE["dead"] = dead + STATE["loaded"] = int(time.time()) + return len(keys) + + +def next_key(tried=None): + with _lock: + keys = STATE["keys"] + dead = STATE["dead"] + live = [k for k in keys if k not in dead] + if not live: + return None + for _ in range(len(live)): + k = live[STATE["idx"] % len(live)] + STATE["idx"] += 1 + if tried and k in tried: + continue + return k + return None + + +def mark_dead(key): + with _lock: + STATE["dead"].add(key) + try: + with open(KEYS_FILE, "a", encoding="utf-8") as f: + f.write(json.dumps({"key": key, "status": "dead", "ts": int(time.time())}) + "\n") + except Exception: + pass + + +def proxy(path, body=None, method="POST"): + tried = set() + last = (502, {"error": {"message": "no live keys"}}) + for _ in range(30): + key = next_key(tried) + if not key: + break + tried.add(key) + req = urllib.request.Request(UPSTREAM + path, data=body, method=method) + req.add_header("Authorization", "Bearer " + key) + req.add_header("Content-Type", "application/json") + req.add_header("Accept", "application/json") + req.add_header("User-Agent", UA) + t0 = time.time() + try: + with urllib.request.urlopen(req, timeout=TIMEOUT) as r: + out = r.read() + print("upstream ok", r.status, key[:6], round(time.time()-t0,1), len(out), flush=True) + return r.status, out + except urllib.error.HTTPError as e: + data = e.read() + print("upstream", e.code, key[:6], round(time.time()-t0,1), data[:120], flush=True) + if e.code in (401, 403): + mark_dead(key) + last = (e.code, data) + continue + if e.code in (429, 500, 502, 503, 504): + last = (e.code, data) + continue + return e.code, data + except Exception as ex: + print("upstream exc", type(ex).__name__, str(ex)[:120], key[:6], round(time.time()-t0,1), flush=True) + last = (502, json.dumps({"error": {"message": "upstream " + str(ex)[:120]}}).encode()) + continue + return last[0], last[1] + + +class H(BaseHTTPRequestHandler): + protocol_version = "HTTP/1.1" + + def log_message(self, fmt, *args): + return + + def _send(self, code, payload, ctype="application/json"): + if isinstance(payload, str): + payload = payload.encode() + self.send_response(code) + self.send_header("Content-Type", ctype) + self.send_header("Content-Length", str(len(payload))) + self.end_headers() + try: + self.wfile.write(payload) + except Exception: + pass + + def do_GET(self): + if self.path.startswith("/healthz"): + return self._send(200, json.dumps({"ok": True, "keys": len(STATE["keys"]), + "dead": len(STATE["dead"])})) + if self.path.startswith("/v1/models"): + code, data, _ = (200, b"", {}) + tried = set() + while True: + key = next_key(tried) + if not key: + return self._send(502, json.dumps({"error": {"message": "no live keys"}})) + tried.add(key) + req = urllib.request.Request(UPSTREAM + "/models") + req.add_header("Authorization", "Bearer " + key) + req.add_header("User-Agent", UA) + try: + with urllib.request.urlopen(req, timeout=30) as r: + return self._send(200, r.read()) + except urllib.error.HTTPError as e: + if e.code in (401, 403): + mark_dead(key) + continue + if e.code == 429: + continue + return self._send(e.code, e.read()) + except Exception as ex: + return self._send(502, json.dumps({"error": {"message": str(ex)[:120]}})) + return self._send(404, json.dumps({"error": {"message": "not found"}})) + + def do_POST(self): + ln = int(self.headers.get("Content-Length") or 0) + body = self.rfile.read(ln) if ln else b"" + if self.path.startswith("/admin/reload"): + n = load_keys() + return self._send(200, json.dumps({"reloaded": n})) + if self.path.startswith("/v1/chat/completions") or self.path.startswith("/chat/completions"): + try: + reqj = json.loads(body or b"{}") + except Exception: + return self._send(400, json.dumps({"error": {"message": "bad json"}})) + reqj["model"] = to_upstream(reqj.get("model")) + body = json.dumps(reqj).encode() + if reqj.get("stream"): + return self._stream(body) + code, data = proxy("/chat/completions", body) + # empty 200 (uncensored models do this) -> retry on another key + for _ in range(2): + if code != 200: + break + try: + jj = json.loads(data) + ch = jj.get("choices") or [] + txt = (ch[0].get("message") or {}).get("content") if ch else "" + except Exception: + break + if txt: + break + print("empty content, retrying", flush=True) + code, data = proxy("/chat/completions", body) + return self._send(code, data) + return self._send(404, json.dumps({"error": {"message": "not found"}})) + + def _stream(self, body): + tried = set() + for _ in range(10): + key = next_key(tried) + if not key: + return self._send(502, json.dumps({"error": {"message": "no live keys"}})) + tried.add(key) + req = urllib.request.Request(UPSTREAM + "/chat/completions", data=body, method="POST") + req.add_header("Authorization", "Bearer " + key) + req.add_header("Content-Type", "application/json") + req.add_header("Accept", "text/event-stream") + req.add_header("User-Agent", UA) + try: + r = urllib.request.urlopen(req, timeout=TIMEOUT) + status = r.status + except urllib.error.HTTPError as e: + if e.code in (401, 403): + mark_dead(key) + continue + if e.code in (429, 500, 502, 503, 504): + continue + return self._send(e.code, e.read()) + except Exception as ex: + continue + self.send_response(status) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + try: + while True: + chunk = r.read(1024) + if not chunk: + break + self.wfile.write(chunk) + self.wfile.flush() + except Exception: + pass + try: + r.close() + except Exception: + pass + return None + return self._send(502, json.dumps({"error": {"message": "all keys failed"}})) + + +def main(): + n = load_keys() + print("crowl-shim keys:", n, "port:", PORT, flush=True) + srv = ThreadingHTTPServer(("127.0.0.1", PORT), H) + srv.daemon_threads = True + srv.serve_forever() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/wave_all.py b/wave_all.py new file mode 100644 index 0000000..2d3d677 --- /dev/null +++ b/wave_all.py @@ -0,0 +1,133 @@ +"""Wave dispatcher: register crowllm accounts across bank domains with proxy rotation. + +Each round: pick a domain, run N workers in parallel (one proxy each), count keys. +Two consecutive rounds with zero keys on a domain -> move to the next domain. +""" +import json, os, subprocess, sys, time, collections + +BANK = "C:/Users/User/tmp/crowllm/crowllm_bank.jsonl" +GMAIL = "C:/Users/User/tmp/coarena/gmail_bank.jsonl" +FAIL = "C:/Users/User/tmp/crowllm/crowllm_fail.jsonl" +PY = "C:/Users/User/AppData/Local/Programs/Python/Python311/python.exe" +REG = "C:/Users/User/tmp/crowllm/crowllm_reg.py" +LOG = "C:/Users/User/tmp/crowllm/wave_all.log.txt" +PROXIES = ["http://127.0.0.1:9431", "http://127.0.0.1:9432", "http://127.0.0.1:9433", + "http://127.0.0.1:9434", "http://127.0.0.1:9435", "http://127.0.0.1:8899", ""] +SKIP = {"goldenrod.netflows.us", "educomb.us", "raziia.com"} +ROUNDS_PER_DOMAIN = 3 +MAX_MINUTES = 75 + +log = open(LOG, "a", encoding="utf-8") + + +def L(*a): + s = time.strftime("%H:%M:%S ") + " ".join(str(x) for x in a) + log.write(s + "\n"); log.flush() + print(s.encode("ascii", "replace").decode(), flush=True) + + +def used_emails(): + s = set() + for f in (BANK, FAIL): + try: + for line in open(f, encoding="utf-8"): + line = line.strip() + if line: + try: + s.add(json.loads(line).get("email")) + except Exception: + pass + except FileNotFoundError: + pass + return s + + +def free_by_domain(): + used = used_emails() + dom = collections.Counter() + for line in open(GMAIL, encoding="utf-8"): + line = line.strip() + if not line: + continue + try: + j = json.loads(line) + except Exception: + continue + e = j.get("email") + d = e.split("@")[-1] if e else None + if not e or e in used or d in SKIP: + continue + dom[d] += 1 + return dom + + +def key_count(): + try: + return sum(1 for line in open(BANK, encoding="utf-8") if line.strip()) + except FileNotFoundError: + return 0 + + +def run_round(domain, idx_base, workers=6): + procs = [] + for i in range(workers): + px = PROXIES[i % len(PROXIES)] + env = dict(os.environ) + env["PYTHONUNBUFFERED"] = "1" + env["PYTHONIOENCODING"] = "utf-8" + env.pop("PYTHONPATH", None) + if px: + env["CROWL_PROXY"] = px + else: + env.pop("CROWL_PROXY", None) + tag = "wv%s_%d" % (idx_base, i) + f = open("C:/Users/User/tmp/crowllm/%s.log" % tag, "w") + p = subprocess.Popen([PY, "-u", REG, domain, tag], stdout=f, stderr=subprocess.STDOUT, env=env) + procs.append((p, f, tag)) + time.sleep(2) + for p, f, tag in procs: + try: + p.wait(timeout=420) + except Exception: + p.kill() + f.close() + return len(procs) + + +def main(): + start = time.time() + budget = MAX_MINUTES * 60 + total_start = key_count() + L("=== wave start, keys:", total_start) + dom = free_by_domain() + order = [d for d, _ in dom.most_common()] + L("domains by free count:", dict(dom.most_common(10))) + idx = int(time.time()) % 10000 + for d in order: + if time.time() - start > budget: + L("budget exhausted"); break + if dom[d] < 3: + continue + zero = 0 + for rnd in range(ROUNDS_PER_DOMAIN): + if time.time() - start > budget: + break + before = key_count() + idx += 1 + run_round(d, idx) + after = key_count() + got = after - before + L(f"domain={d} round={rnd} +{got} (total {after})") + if got == 0: + zero += 1 + if zero >= 2: + L(f"domain={d} burned, next") + break + else: + zero = 0 + time.sleep(5) + L("=== wave done, keys:", key_count(), "delta:", key_count() - total_start) + + +if __name__ == "__main__": + main() \ No newline at end of file