composio-autoreg: browser-driven WorkOS AuthKit farm for ck_ consumer keys
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
bank/
|
||||||
|
*.log
|
||||||
|
chrome_prof/
|
||||||
|
venv/
|
||||||
|
__pycache__/
|
||||||
|
*.json
|
||||||
|
!requirements.txt
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
# composio-autoreg
|
||||||
|
|
||||||
|
Autoreg for [Composio](https://composio.dev) accounts and `ck_...` consumer API keys.
|
||||||
|
|
||||||
|
Free tier: **$0, no card**, $2 credits one-time, up to 3 members, **10,000 tool calls/month**, all 1,700+ toolkits connectable.
|
||||||
|
Instant tools (Exa, Apollo, Higgsfield, ...) run on the $2 credit with 0% markup.
|
||||||
|
|
||||||
|
## Why a real browser
|
||||||
|
|
||||||
|
Composio runs on **WorkOS AuthKit hosted** (`login.composio.dev`, deployment `hosted-authkit-2f3c943e...`).
|
||||||
|
Pure HTTP replay dies in three places:
|
||||||
|
|
||||||
|
1. **Server-action IDs are per-deploy** and live in the RSC flight payload as `{"id":"<42 hex>","bound":null}`.
|
||||||
|
Random 40–42 hex tokens that appear "rare" in the HTML are fragments of `signalsToken`
|
||||||
|
(`Fe26.2*2*...`); POSTing them returns `404` + `x-nextjs-action-not-found: 1`.
|
||||||
|
2. **`/passkey/enroll` interstitial.** The skip control is `<button name="intent" value="skip">` inside a
|
||||||
|
client component; the form's action ID is not present in the HTML (it lives in a page chunk that
|
||||||
|
Next.js does not ship in the document). `createPasskeyChallenge` (`40bb2612...`) is *not* the submit
|
||||||
|
action — using it returns `500`.
|
||||||
|
3. **`/radar-challenge`** (WorkOS Radar) may appear as an email OTP step.
|
||||||
|
|
||||||
|
A real Chrome (headless=False) walks through all three by itself. `wave.py` only fills fields,
|
||||||
|
types the OTP and clicks the skip button.
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
|
| file | purpose |
|
||||||
|
|------|---------|
|
||||||
|
| `wave.py` | farm N accounts: signup -> OTP -> passkey skip -> key -> bank |
|
||||||
|
| `login_one.py` | single existing account: login -> skip -> key (debug/recovery) |
|
||||||
|
| `verify_key.py` | check keys against `https://connect.composio.dev/mcp` |
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -m venv venv
|
||||||
|
venv/Scripts/pip install -r requirements.txt # playwright, requests
|
||||||
|
```
|
||||||
|
|
||||||
|
Chrome must be installed (`C:/Program Files/Google/Chrome/Application/chrome.exe`, overridable via
|
||||||
|
`CHROME_PATH`). Playwright's bundled Chromium is not used — the flow needs a real browser build.
|
||||||
|
|
||||||
|
## Pool format
|
||||||
|
|
||||||
|
`email:imap_password`, one per line (t-online IMAP is used to read the OTP):
|
||||||
|
|
||||||
|
```
|
||||||
|
user001@t-online.de:mailpassword
|
||||||
|
user002@t-online.de:mailpassword
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# farm 5 accounts starting at pool index 10
|
||||||
|
venv/Scripts/python wave.py --pool pool.txt --start 10 --count 5
|
||||||
|
|
||||||
|
# one existing account (login path)
|
||||||
|
venv/Scripts/python login_one.py user@t-online.de 'AccountPassword' 'MailboxPassword'
|
||||||
|
```
|
||||||
|
|
||||||
|
Every attempt appends one JSON line to the bank (`--bank`, default `bank/accounts.jsonl`):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"email":"...","imap_pass":"...","password":"...","ok":true,"api_key":"ck_...","workspace":"..._workspace","ts":1794416500}
|
||||||
|
```
|
||||||
|
|
||||||
|
`wave.py` re-uses the password stored in the bank for an address it has already touched, so a failed
|
||||||
|
run can be retried without losing the account.
|
||||||
|
|
||||||
|
## Using the key
|
||||||
|
|
||||||
|
The `ck_` key is a **consumer** key and is only valid as `x-consumer-api-key` on the MCP endpoint:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST https://connect.composio.dev/mcp \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-H 'accept: application/json, text/event-stream' \
|
||||||
|
-H "x-consumer-api-key: $KEY" \
|
||||||
|
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"cli","version":"1"}}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
`tools/list` returns 12 meta-tools:
|
||||||
|
|
||||||
|
```
|
||||||
|
COMPOSIO_SEARCH_TOOLS COMPOSIO_GET_TOOL_SCHEMAS COMPOSIO_MULTI_EXECUTE_TOOL
|
||||||
|
COMPOSIO_PROXY_EXECUTE COMPOSIO_REMOTE_BASH_TOOL COMPOSIO_REMOTE_WORKBENCH
|
||||||
|
COMPOSIO_MANAGE_CONNECTIONS COMPOSIO_WAIT_FOR_CONNECTIONS
|
||||||
|
COMPOSIO_SEARCH_SKILLS COMPOSIO_USE_SKILL COMPOSIO_MANAGE_SKILL
|
||||||
|
COMPOSIO_SUBMIT_FEEDBACK
|
||||||
|
```
|
||||||
|
|
||||||
|
Typical call:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST https://connect.composio.dev/mcp \
|
||||||
|
-H 'content-type: application/json' -H 'accept: application/json, text/event-stream' \
|
||||||
|
-H "x-consumer-api-key: $KEY" \
|
||||||
|
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"COMPOSIO_SEARCH_TOOLS","arguments":{"query":"gmail send email"}}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Limits and quotas
|
||||||
|
|
||||||
|
- Free plan: **10,000 tool calls/month**, $2 credits (one-time), 3 members, no card.
|
||||||
|
- Standard: $18 / seat / month, each seat adds 10,000 tool calls + $18 credits to the shared pool.
|
||||||
|
- `backend.composio.dev/api/v3/*` requires a **project** API key or dashboard JWT; the `ck_` consumer key
|
||||||
|
gets `401 Auth_NoAuthProvided`. Use MCP, not REST.
|
||||||
|
- `/api/trpc/consumer.*` on the dashboard works only inside the authenticated browser session —
|
||||||
|
replayed fetches return `401 UNAUTHORIZED` because tRPC needs the app's own headers.
|
||||||
|
|
||||||
|
## Pitfalls
|
||||||
|
|
||||||
|
- The agent signup lane (`POST https://agents.composio.dev/api/signup`) is `DEPLOYMENT_PAUSED`.
|
||||||
|
- A fresh address must go through `/sign-up` (click the "Регистрация / Sign up" link); the entry URL
|
||||||
|
`dashboard.composio.dev/f/~/connect/clients` lands on the **login** form, which for an unregistered
|
||||||
|
email just bounces back with "invalid email or password".
|
||||||
|
- After the signup form is submitted the app moves to `/sign-up/password` — do not try to fill the email
|
||||||
|
field there, it is not rendered.
|
||||||
|
- One account hammered with wrong passwords enters a WorkOS velocity lock (500 on the password step).
|
||||||
|
Wait 10–15 minutes or use a fresh account.
|
||||||
|
- OTP mails come from `noreply@login.composio.dev`; filter by `Date >= run start`, otherwise the
|
||||||
|
signup-verification code from an earlier attempt is picked up.
|
||||||
|
- The API key is fetched by intercepting the tRPC `consumer.getToken` response
|
||||||
|
(`ck_[A-Za-z0-9_-]{16,}`) or by clicking `Copy` and reading the clipboard
|
||||||
|
(needs `permissions=["clipboard-read","clipboard-write"]`).
|
||||||
|
|
||||||
|
## Legal
|
||||||
|
|
||||||
|
For research on your own accounts. You are responsible for complying with the target's terms of service.
|
||||||
+223
@@ -0,0 +1,223 @@
|
|||||||
|
"""Composio: browser login -> skip passkey -> cliKey -> project api key."""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
|
EMAIL = sys.argv[1] if len(sys.argv) > 1 else "0618455607-001@t-online.de"
|
||||||
|
PASSWORD = sys.argv[2] if len(sys.argv) > 2 else "pUX@e6ykq3YE"
|
||||||
|
IMAP_PASS = sys.argv[3] if len(sys.argv) > 3 else "nurmir11051943"
|
||||||
|
PROFILE = "C:/Users/User/tmp/composio/chrome_prof"
|
||||||
|
CHROME = "C:/Program Files/Google/Chrome/Application/chrome.exe"
|
||||||
|
if not os.path.exists(CHROME):
|
||||||
|
CHROME = os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe")
|
||||||
|
OUT = "C:/Users/User/tmp/composio"
|
||||||
|
DASH = "https://dashboard.composio.dev"
|
||||||
|
LOGIN = "https://login.composio.dev"
|
||||||
|
|
||||||
|
|
||||||
|
def log(*a):
|
||||||
|
print(*a, flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
def shot(pg, name):
|
||||||
|
try:
|
||||||
|
pg.screenshot(path=f"{OUT}/bshot_{name}.png", full_page=False)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def dump(pg, name):
|
||||||
|
try:
|
||||||
|
open(f"{OUT}/bhtml_{name}.html", "w", encoding="utf-8").write(pg.content())
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def wait_any(pg, sels, timeout=45):
|
||||||
|
end = time.time() + timeout
|
||||||
|
while time.time() < end:
|
||||||
|
for s in sels:
|
||||||
|
try:
|
||||||
|
if pg.locator(s).count() > 0 and pg.locator(s).first.is_visible():
|
||||||
|
return s
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
pg.wait_for_timeout(700)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def imap_code(mail, pw, since_ts=None, tries=18, delay=8):
|
||||||
|
import imaplib, email as emod, re as r2
|
||||||
|
from email.utils import parsedate_to_datetime
|
||||||
|
for _ in range(tries):
|
||||||
|
best = None
|
||||||
|
try:
|
||||||
|
M = imaplib.IMAP4_SSL("secureimap.t-online.de")
|
||||||
|
M.login(mail, pw)
|
||||||
|
M.select("INBOX")
|
||||||
|
typ, data = M.search(None, '(FROM "login.composio.dev")')
|
||||||
|
ids = data[0].split()
|
||||||
|
for i in reversed(ids[-5:]):
|
||||||
|
typ, msgd = M.fetch(i, "(RFC822)")
|
||||||
|
item = msgd[0]
|
||||||
|
raw = item[1] if isinstance(item, tuple) else None
|
||||||
|
if not raw:
|
||||||
|
continue
|
||||||
|
m = emod.message_from_bytes(raw)
|
||||||
|
try:
|
||||||
|
dts = parsedate_to_datetime(m["Date"]).timestamp()
|
||||||
|
except Exception:
|
||||||
|
dts = 0
|
||||||
|
if since_ts and dts < since_ts - 180:
|
||||||
|
continue
|
||||||
|
body = b""
|
||||||
|
if m.is_multipart():
|
||||||
|
for part in m.walk():
|
||||||
|
if part.get_content_type() == "text/plain":
|
||||||
|
body = part.get_payload(decode=True) or b""
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
body = m.get_payload(decode=True) or b""
|
||||||
|
txt = (body or b"").decode("utf-8", "ignore")
|
||||||
|
codes = r2.findall(r"(\d{6})", txt)
|
||||||
|
if codes:
|
||||||
|
log(" imap mail date:", m["Date"], "code:", codes[-1])
|
||||||
|
M.logout()
|
||||||
|
return codes[-1]
|
||||||
|
except Exception as e:
|
||||||
|
log(" imap err:", e)
|
||||||
|
try:
|
||||||
|
M.logout()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
time.sleep(delay)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
T0 = time.time()
|
||||||
|
with sync_playwright() as p:
|
||||||
|
ctx = p.chromium.launch_persistent_context(
|
||||||
|
PROFILE, executable_path=CHROME, headless=False, viewport={"width": 1280, "height": 900},
|
||||||
|
args=["--disable-blink-features=AutomationControlled", "--no-first-run"],
|
||||||
|
)
|
||||||
|
pg = ctx.pages[0] if ctx.pages else ctx.new_page()
|
||||||
|
pg.set_default_timeout(30000)
|
||||||
|
log("[1] goto entry")
|
||||||
|
pg.goto(DASH + "/f/~/connect/clients", wait_until="domcontentloaded")
|
||||||
|
pg.wait_for_timeout(4000)
|
||||||
|
log(" url:", pg.url)
|
||||||
|
dump(pg, "1_entry")
|
||||||
|
# email step
|
||||||
|
sel = wait_any(pg, ['input[name="email"]', 'input[type="email"]'])
|
||||||
|
if not sel:
|
||||||
|
log("no email field; url:", pg.url)
|
||||||
|
shot(pg, "no_email")
|
||||||
|
ctx.close()
|
||||||
|
sys.exit(2)
|
||||||
|
log("[2] fill email")
|
||||||
|
pg.fill('input[name="email"]', EMAIL)
|
||||||
|
pg.wait_for_timeout(400)
|
||||||
|
btn = wait_any(pg, ['button[type="submit"]'], 10)
|
||||||
|
if btn:
|
||||||
|
try:
|
||||||
|
pg.locator('button[type="submit"]').first.click()
|
||||||
|
except Exception:
|
||||||
|
pg.keyboard.press("Enter")
|
||||||
|
else:
|
||||||
|
pg.keyboard.press("Enter")
|
||||||
|
pg.wait_for_timeout(5000)
|
||||||
|
log(" url:", pg.url)
|
||||||
|
dump(pg, "2_after_email")
|
||||||
|
# password step
|
||||||
|
sel = wait_any(pg, ['input[name="password"]', 'input[type="password"]'], 25)
|
||||||
|
if sel:
|
||||||
|
log("[3] fill password")
|
||||||
|
pg.fill(sel, PASSWORD)
|
||||||
|
pg.wait_for_timeout(300)
|
||||||
|
try:
|
||||||
|
pg.locator('button[type="submit"]').first.click()
|
||||||
|
except Exception:
|
||||||
|
pg.keyboard.press("Enter")
|
||||||
|
pg.wait_for_timeout(6000)
|
||||||
|
log(" url:", pg.url)
|
||||||
|
dump(pg, "3_after_pw")
|
||||||
|
# OTP radar challenge
|
||||||
|
if "radar-challenge" in pg.url or pg.locator('input[autocomplete="one-time-code"]').count() > 0:
|
||||||
|
log("[3b] otp challenge")
|
||||||
|
dump(pg, "3b_otp")
|
||||||
|
code = imap_code(EMAIL, IMAP_PASS, T0)
|
||||||
|
if not code:
|
||||||
|
log(" no otp code")
|
||||||
|
ctx.close()
|
||||||
|
sys.exit(3)
|
||||||
|
box = pg.locator('[data-test="otp-input"]')
|
||||||
|
if box.count() == 0:
|
||||||
|
box = pg.locator('input[name="code"]')
|
||||||
|
log(" otp inputs:", box.count())
|
||||||
|
box.first.click(force=True)
|
||||||
|
pg.keyboard.type(code, delay=140)
|
||||||
|
pg.wait_for_timeout(7000)
|
||||||
|
log(" url:", pg.url)
|
||||||
|
dump(pg, "3b_after_otp")
|
||||||
|
# passkey interstitial
|
||||||
|
if "passkey" in pg.url or pg.locator('button[name="intent"][value="skip"]').count() > 0:
|
||||||
|
log("[4] passkey page, clicking skip")
|
||||||
|
dump(pg, "4_passkey")
|
||||||
|
try:
|
||||||
|
pg.locator('button[name="intent"][value="skip"]').first.click()
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
pg.get_by_text("Vorerst überspringen").click()
|
||||||
|
except Exception as e:
|
||||||
|
log(" skip click failed:", e)
|
||||||
|
pg.wait_for_timeout(7000)
|
||||||
|
log(" url:", pg.url)
|
||||||
|
dump(pg, "4_after_skip")
|
||||||
|
# wait for dashboard
|
||||||
|
for i in range(20):
|
||||||
|
if "dashboard.composio.dev" in pg.url and "login" not in pg.url:
|
||||||
|
break
|
||||||
|
pg.wait_for_timeout(1500)
|
||||||
|
log("[5] url now:", pg.url)
|
||||||
|
dump(pg, "5_final")
|
||||||
|
shot(pg, "5_final")
|
||||||
|
cookies = ctx.cookies()
|
||||||
|
open(f"{OUT}/bctx_cookies.json", "w", encoding="utf-8").write(json.dumps(cookies, indent=1))
|
||||||
|
log(" cookies:", len(cookies), [c["name"] for c in cookies][:8])
|
||||||
|
# cliKey flow on dashboard origin
|
||||||
|
if "dashboard.composio.dev" not in pg.url:
|
||||||
|
pg.goto(DASH + "/", wait_until="domcontentloaded")
|
||||||
|
pg.wait_for_timeout(3000)
|
||||||
|
log("[6] dashboard url:", pg.url)
|
||||||
|
r = pg.evaluate(
|
||||||
|
"""async () => {
|
||||||
|
const res = await fetch('/api/v3.1/cli/create-session', {
|
||||||
|
method: 'POST', headers: {'content-type': 'application/json'},
|
||||||
|
body: JSON.stringify({scope: 'project'}), credentials: 'include'});
|
||||||
|
return res.status + ' ' + (await res.text()).slice(0, 300);
|
||||||
|
}"""
|
||||||
|
)
|
||||||
|
log("[6] create-session:", r)
|
||||||
|
m = re.search(r'"id"\s*:\s*"([^"]+)"', r) or re.search(r'\{"id":"([^"]+)"\}', r)
|
||||||
|
sid = m.group(1) if m else None
|
||||||
|
if not sid:
|
||||||
|
m2 = re.search(r'[0-9a-f]{20,40}', r)
|
||||||
|
sid = m2.group(0) if m2 else None
|
||||||
|
log(" session id:", sid)
|
||||||
|
if sid:
|
||||||
|
pg.goto(f"{DASH}/?cliKey={sid}", wait_until="domcontentloaded")
|
||||||
|
pg.wait_for_timeout(4000)
|
||||||
|
dump(pg, "6_approve")
|
||||||
|
r2 = pg.evaluate(
|
||||||
|
"""async (sid) => {
|
||||||
|
const res = await fetch('/api/v3.1/cli/get-session?id=' + encodeURIComponent(sid),
|
||||||
|
{credentials: 'include'});
|
||||||
|
return res.status + ' ' + (await res.text()).slice(0, 800);
|
||||||
|
}""", sid)
|
||||||
|
log("[7] get-session:", r2)
|
||||||
|
open(f"{OUT}/bsession_keys.txt", "w", encoding="utf-8").write(r2)
|
||||||
|
ctx.close()
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
playwright>=1.40
|
||||||
|
requests>=2.31
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Verify a Composio consumer key (ck_...) against the MCP endpoint.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python verify_key.py ck_xxxx
|
||||||
|
python verify_key.py --bank bank/accounts.jsonl # verify every account
|
||||||
|
|
||||||
|
Exit code 0 when at least one key answered with a valid MCP initialize.
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
MCP_URL = "https://connect.composio.dev/mcp"
|
||||||
|
INIT = {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"method": "initialize",
|
||||||
|
"params": {
|
||||||
|
"protocolVersion": "2024-11-05",
|
||||||
|
"capabilities": {},
|
||||||
|
"clientInfo": {"name": "verify", "version": "1"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def check(key, timeout=30):
|
||||||
|
h = {
|
||||||
|
"content-type": "application/json",
|
||||||
|
"accept": "application/json, text/event-stream",
|
||||||
|
"x-consumer-api-key": key,
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
r = requests.post(MCP_URL, json=INIT, headers=h, timeout=timeout)
|
||||||
|
except Exception as e:
|
||||||
|
return False, f"err {e}"
|
||||||
|
body = r.text or ""
|
||||||
|
if r.status_code == 200 and "serverInfo" in body:
|
||||||
|
m = re.search(r'"name":"([^"]+)"', body)
|
||||||
|
return True, f"200 {m.group(1) if m else 'ok'}"
|
||||||
|
return False, f"{r.status_code} {body[:120]}"
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
ap = argparse.ArgumentParser()
|
||||||
|
ap.add_argument("key", nargs="?")
|
||||||
|
ap.add_argument("--bank")
|
||||||
|
a = ap.parse_args()
|
||||||
|
keys = []
|
||||||
|
if a.key:
|
||||||
|
keys.append((None, a.key))
|
||||||
|
if a.bank:
|
||||||
|
for line in open(a.bank, encoding="utf-8"):
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
rec = json.loads(line)
|
||||||
|
if rec.get("api_key"):
|
||||||
|
keys.append((rec.get("email"), rec["api_key"]))
|
||||||
|
if not keys:
|
||||||
|
ap.error("pass a key or --bank")
|
||||||
|
alive = 0
|
||||||
|
for mail, key in keys:
|
||||||
|
ok, info = check(key)
|
||||||
|
alive += 1 if ok else 0
|
||||||
|
print(("OK " if ok else "DEAD "), (mail or "")[:40], key[:10] + "..." + key[-4:], info)
|
||||||
|
print(f"alive {alive}/{len(keys)}")
|
||||||
|
sys.exit(0 if alive else 1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
"""Composio farm wave: signup (or login) -> OTP -> passkey skip -> ck_ key -> bank.
|
||||||
|
|
||||||
|
Usage: python wave.py --pool pool.txt --start 7 --count 5 [--bank bank/accounts.jsonl]
|
||||||
|
Each line of pool: email:imap_password
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import imaplib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
import string
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from email.utils import parsedate_to_datetime
|
||||||
|
|
||||||
|
import email as emod
|
||||||
|
from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
|
CHROME = "C:/Program Files/Google/Chrome/Application/chrome.exe"
|
||||||
|
if not os.path.exists(CHROME):
|
||||||
|
CHROME = os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe")
|
||||||
|
DASH = "https://dashboard.composio.dev"
|
||||||
|
ENTRY = DASH + "/f/~/connect/clients"
|
||||||
|
OUT = "C:/Users/User/tmp/composio"
|
||||||
|
IMAP_HOST = "secureimap.t-online.de"
|
||||||
|
|
||||||
|
|
||||||
|
def log(*a):
|
||||||
|
print(*a, flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
def gen_password():
|
||||||
|
sym = "@#$%*!?"
|
||||||
|
body = "".join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
|
||||||
|
return body[:3] + random.choice(sym) + body[3:] + random.choice(sym) + str(random.randint(10, 99))
|
||||||
|
|
||||||
|
|
||||||
|
def imap_code(mail, pw, since_ts, tries=20, delay=9):
|
||||||
|
for _ in range(tries):
|
||||||
|
M = None
|
||||||
|
try:
|
||||||
|
M = imaplib.IMAP4_SSL(IMAP_HOST)
|
||||||
|
M.login(mail, pw)
|
||||||
|
M.select("INBOX")
|
||||||
|
typ, data = M.search(None, '(FROM "login.composio.dev")')
|
||||||
|
for i in reversed(data[0].split()[-5:]):
|
||||||
|
typ, msgd = M.fetch(i, "(RFC822)")
|
||||||
|
item = msgd[0]
|
||||||
|
raw = item[1] if isinstance(item, tuple) else None
|
||||||
|
if not raw:
|
||||||
|
continue
|
||||||
|
m = emod.message_from_bytes(raw)
|
||||||
|
try:
|
||||||
|
ts = parsedate_to_datetime(m["Date"]).timestamp()
|
||||||
|
except Exception:
|
||||||
|
ts = 0
|
||||||
|
if ts < since_ts - 180:
|
||||||
|
continue
|
||||||
|
body = b""
|
||||||
|
if m.is_multipart():
|
||||||
|
for part in m.walk():
|
||||||
|
if part.get_content_type() == "text/plain":
|
||||||
|
body = part.get_payload(decode=True) or b""
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
body = m.get_payload(decode=True) or b""
|
||||||
|
codes = re.findall(r"\b(\d{6})\b", (body or b"").decode("utf-8", "ignore"))
|
||||||
|
if codes:
|
||||||
|
M.logout()
|
||||||
|
return codes[-1]
|
||||||
|
except Exception as e:
|
||||||
|
log(" imap:", str(e)[:70])
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
if M:
|
||||||
|
M.logout()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
time.sleep(delay)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def first_name_from(mail):
|
||||||
|
base = mail.split("@")[0]
|
||||||
|
return base[:12] or "User"
|
||||||
|
|
||||||
|
|
||||||
|
def run_one(br, mail, imap_pass, bank_path):
|
||||||
|
t0 = time.time()
|
||||||
|
password = gen_password()
|
||||||
|
try:
|
||||||
|
for line in open(bank_path, encoding="utf-8"):
|
||||||
|
rec = json.loads(line)
|
||||||
|
if rec.get("email", "").lower() == mail.lower() and rec.get("password"):
|
||||||
|
password = rec["password"]
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
ctx = br.new_context(viewport={"width": 1280, "height": 900}, locale="de-DE")
|
||||||
|
pg = ctx.new_page()
|
||||||
|
pg.set_default_timeout(25000)
|
||||||
|
res = {"email": mail, "imap_pass": imap_pass, "password": password, "ok": False, "stage": "start"}
|
||||||
|
try:
|
||||||
|
pg.goto(ENTRY, wait_until="domcontentloaded")
|
||||||
|
pg.wait_for_timeout(3500)
|
||||||
|
# switch to signup route when login form shown
|
||||||
|
if pg.locator('input[name="first_name"]').count() == 0 and pg.locator('a[href*="/sign-up"]').count() > 0:
|
||||||
|
log(" [0] opening /sign-up")
|
||||||
|
try:
|
||||||
|
pg.locator('a[href*="/sign-up"]').first.click()
|
||||||
|
pg.wait_for_timeout(4000)
|
||||||
|
except Exception as e:
|
||||||
|
log(" signup link err:", str(e)[:60])
|
||||||
|
log(" ->", pg.url[:90])
|
||||||
|
# signup form?
|
||||||
|
if pg.locator('input[name="first_name"]').count() > 0:
|
||||||
|
log(" [1] signup form")
|
||||||
|
pg.fill('input[name="first_name"]', first_name_from(mail))
|
||||||
|
if pg.locator('input[name="last_name"]').count():
|
||||||
|
pg.fill('input[name="last_name"]', "Schulz")
|
||||||
|
pg.fill('input[name="email"]', mail)
|
||||||
|
if pg.locator('input[name="password"]').count():
|
||||||
|
pg.fill('input[name="password"]', password)
|
||||||
|
pg.wait_for_timeout(300)
|
||||||
|
try:
|
||||||
|
pg.locator('button[type="submit"]').first.click()
|
||||||
|
except Exception:
|
||||||
|
pg.keyboard.press("Enter")
|
||||||
|
pg.wait_for_timeout(5000)
|
||||||
|
log(" ->", pg.url[:90])
|
||||||
|
# email step (skip when already on password step)
|
||||||
|
if (pg.locator('input[name="email"]').count() > 0 and "otp" not in pg.url
|
||||||
|
and "password" not in pg.url):
|
||||||
|
log(" [2] email step")
|
||||||
|
pg.fill('input[name="email"]', mail)
|
||||||
|
pg.wait_for_timeout(300)
|
||||||
|
try:
|
||||||
|
pg.locator('button[type="submit"]').first.click()
|
||||||
|
except Exception:
|
||||||
|
pg.keyboard.press("Enter")
|
||||||
|
pg.wait_for_timeout(4500)
|
||||||
|
log(" ->", pg.url[:90])
|
||||||
|
# password step
|
||||||
|
if pg.locator('input[name="password"]').count() > 0:
|
||||||
|
log(" [3] password step")
|
||||||
|
pg.fill('input[name="password"]', password)
|
||||||
|
pg.wait_for_timeout(300)
|
||||||
|
try:
|
||||||
|
pg.locator('button[type="submit"]').first.click()
|
||||||
|
except Exception:
|
||||||
|
pg.keyboard.press("Enter")
|
||||||
|
pg.wait_for_timeout(5500)
|
||||||
|
log(" ->", pg.url[:90])
|
||||||
|
# otp / verify
|
||||||
|
if pg.locator('[data-test="otp-input"]').count() > 0 or "radar-challenge" in pg.url or "verify" in pg.url:
|
||||||
|
log(" [4] otp step")
|
||||||
|
code = imap_code(mail, imap_pass, t0)
|
||||||
|
if not code:
|
||||||
|
res.update(stage="imap", err="no code")
|
||||||
|
log(" FAIL no code")
|
||||||
|
return res
|
||||||
|
box = pg.locator('[data-test="otp-input"]').first
|
||||||
|
box.click(force=True)
|
||||||
|
pg.keyboard.type(code, delay=140)
|
||||||
|
pg.wait_for_timeout(6500)
|
||||||
|
log(" ->", pg.url[:90], "code:", code)
|
||||||
|
# passkey skip
|
||||||
|
if "passkey" in pg.url or pg.locator('button[name="intent"][value="skip"]').count() > 0:
|
||||||
|
log(" [5] passkey skip")
|
||||||
|
try:
|
||||||
|
pg.locator('button[name="intent"][value="skip"]').first.click(timeout=8000)
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
pg.get_by_text("Vorerst überspringen").click(timeout=5000)
|
||||||
|
except Exception:
|
||||||
|
pg.get_by_text("Skip").first.click(timeout=5000)
|
||||||
|
pg.wait_for_timeout(6500)
|
||||||
|
log(" ->", pg.url[:90])
|
||||||
|
for _ in range(14):
|
||||||
|
if "dashboard.composio.dev" in pg.url and "login." not in pg.url and "passkey" not in pg.url:
|
||||||
|
break
|
||||||
|
pg.wait_for_timeout(1500)
|
||||||
|
if "dashboard.composio.dev" not in pg.url:
|
||||||
|
res.update(stage="login", err=pg.url[:120])
|
||||||
|
log(" FAIL not in dashboard:", pg.url[:90])
|
||||||
|
return res
|
||||||
|
# key
|
||||||
|
ws = re.match(r"https://dashboard\.composio\.dev/([^/]+)/", pg.url + "/")
|
||||||
|
ws_name = ws.group(1) if ws else ""
|
||||||
|
tok = {"v": None}
|
||||||
|
|
||||||
|
def on_resp(r):
|
||||||
|
if "consumer.getToken" in r.url:
|
||||||
|
try:
|
||||||
|
b = r.text()
|
||||||
|
m = re.findall(r"ck_[A-Za-z0-9_\-]{16,}", b)
|
||||||
|
if m:
|
||||||
|
tok["v"] = m[0]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
pg.on("response", on_resp)
|
||||||
|
pg.goto(f"{DASH}/{ws_name}/~/connect/settings/sessions", wait_until="domcontentloaded")
|
||||||
|
pg.wait_for_timeout(6000)
|
||||||
|
if not tok["v"]:
|
||||||
|
try:
|
||||||
|
pg.locator('button:has-text("Copy")').first.click(timeout=6000)
|
||||||
|
pg.wait_for_timeout(900)
|
||||||
|
clip = pg.evaluate("() => navigator.clipboard.readText()")
|
||||||
|
if clip and clip.strip().startswith("ck_"):
|
||||||
|
tok["v"] = clip.strip()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if not tok["v"]:
|
||||||
|
res.update(stage="key", err="no ck_ token")
|
||||||
|
log(" FAIL no key")
|
||||||
|
return res
|
||||||
|
res.update(ok=True, stage="done", api_key=tok["v"], workspace=ws_name,
|
||||||
|
elapsed=round(time.time() - t0, 1), ts=int(time.time()))
|
||||||
|
log(" OK key:", tok["v"][:10] + "..." + tok["v"][-4:], "ws:", ws_name)
|
||||||
|
except Exception as e:
|
||||||
|
res.update(stage="exc", err=str(e)[:160])
|
||||||
|
log(" EXC:", str(e)[:120])
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
ctx.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
with open(bank_path, "a", encoding="utf-8") as f:
|
||||||
|
f.write(json.dumps(res, ensure_ascii=False) + "\n")
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
ap = argparse.ArgumentParser()
|
||||||
|
ap.add_argument("--pool", default=OUT + "/pool_tonline.txt")
|
||||||
|
ap.add_argument("--start", type=int, default=0)
|
||||||
|
ap.add_argument("--count", type=int, default=3)
|
||||||
|
ap.add_argument("--bank", default=OUT + "/bank/accounts.jsonl")
|
||||||
|
ap.add_argument("--pause", type=int, default=20)
|
||||||
|
a = ap.parse_args()
|
||||||
|
lines = [l.strip() for l in open(a.pool, encoding="utf-8", errors="ignore") if ":" in l]
|
||||||
|
todo = lines[a.start:a.start + a.count]
|
||||||
|
log("wave:", len(todo), "accounts from idx", a.start)
|
||||||
|
ok = 0
|
||||||
|
with sync_playwright() as p:
|
||||||
|
br = p.chromium.launch(executable_path=CHROME, headless=False,
|
||||||
|
args=["--disable-blink-features=AutomationControlled", "--no-first-run"])
|
||||||
|
for n, line in enumerate(todo):
|
||||||
|
mail, imap_pass = line.split(":", 1)
|
||||||
|
log(f"--- [{a.start + n}] {mail}")
|
||||||
|
r = run_one(br, mail, imap_pass, a.bank)
|
||||||
|
if r.get("ok"):
|
||||||
|
ok += 1
|
||||||
|
time.sleep(a.pause)
|
||||||
|
br.close()
|
||||||
|
log("WAVE DONE ok=%d/%d" % (ok, len(todo)))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user