Files

232 lines
9.1 KiB
Markdown

---
name: chatgpt-autoreg
description: Mass auto-registration of ChatGPT accounts using aBaiAutoplus toolkit — protocol executor, IMAP pool, captcha auto-solver. Covers server lifecycle, task submission, monitoring, and pitfall recovery.
triggers:
- "авторег gpt"
- "регистрация chatgpt аккаунтов"
- "массовый авторег"
- "зарегать аккаунты"
- user asks about aBaiAutoplus or oai-register
---
# ChatGPT Auto-Registration (aBaiAutoplus)
## Quick Start
```bash
# 1. Start server
cd "C:/Users/User/Desktop/GPT-AUTOREG/aBaiAutoplus"
python -u main.py
# Server listens on port 8000. Web UI at http://localhost:8000
# No venv activation needed — uses system Python 3.11
# 2. Verify health
curl -s http://localhost:8000/api/health
# → {"ok":true,"service":"account-manager-v2"}
# 3. Check accounts
curl -s "http://localhost:8000/api/accounts?limit=3"
# Returns total count + account list
# 4. Register N accounts (protocol executor — fastest)
curl -s -X POST http://localhost:8000/api/tasks/register \
-H "Content-Type: application/json" \
-d '{"count":10,"concurrency":2,"executor_type":"protocol","captcha_solver":"auto","extra":{"mail_provider":"imap_pool","identity_provider":"mailbox"}}'
# Returns task_id. Monitor with step 5.
# 5. Monitor task
curl -s http://localhost:8000/api/tasks/<task_id>
# Fields: status, progress, success, error_count, errors[]
```
## Project Layout
```
GPT-AUTOREG/aBaiAutoplus/
├── main.py # FastAPI entry point, port 8000
├── gateway.py # Go gateway (port 8001) — optional, not needed for reg
├── platforms/chatgpt/
│ ├── protocol_register.py # Protocol registration worker (curl_cffi impersonation)
│ ├── browser_register.py # Headed browser registration (Camoufox)
│ └── constants.py # OpenAI auth endpoints, Sentinel config
├── providers/mailbox/
│ └── imap_pool.py # GenericImapMailboxPool — t-online.de IMAP
├── api/
│ ├── task_commands.py # RegisterTaskRequest model
│ ├── provider_settings.py # Provider settings CRUD
│ └── health.py
├── application/
│ └── task_commands.py # TaskCommandsService
├── services/
│ └── task_runtime.py # TaskRuntime (max_parallel_tasks=3)
├── data/
│ └── .imap_mailbox_pool_state.json # IMAP pool state — reset to {} on reconfig
├── account_manager.db # SQLite DB with all registered accounts
├── requirements.txt
└── docker-compose.yml
```
## Email Pool
- **Active file:** `C:/Users/User/Desktop/GPT-AUTOREG/emails.txt` (t-online.de accounts, format `email:password`)
- **Provider:** IMAP pool (id=2, provider_type=mailbox, provider_name=imap_pool)
- **Config path in DB:** stored in `provider_settings` table; update via SQLite if needed:
```sql
UPDATE provider_settings SET value = 'C:/Users/User/Desktop/GPT-AUTOREG/emails.txt' WHERE key = 'imap_pool_file';
```
- **To change email file:** update the path in DB, reset pool state (`echo "{}" > data/.imap_mailbox_pool_state.json`), restart server
- **Blocked domains:** t-online.de mostly burned — ~80% return `account_deactivated`. Consider rambler.ru for fresh pool.
## Captcha
- **Provider:** RuCaptcha (id=1, provider_key=rucaptcha_api)
- **Enabled:** true, is_default: true
- **Solver mode:** `captcha_solver=auto` — system selects automatically
- **Check config:** `curl -s "http://localhost:8000/api/provider-settings?provider_type=captcha"`
## Concurrency & Performance
- **max_parallel_tasks=3** (hardcoded in task_runtime.py)
- **Recommended concurrency=2** — stable. Concurrency=3 causes server crashes under heavy IMAP load.
- **Protocol executor** uses curl_cffi impersonation (firefox144) + Sentinel PoW
- **Performance:** ~1 success per minute with concurrency=2
## Common Pitfalls
### Server crashes
Server is unstable at concurrency=3. Restart with:
```bash
cd "C:/Users/User/Desktop/GPT-AUTOREG/aBaiAutoplus" && python -u main.py
```
Database survives crashes. Incomplete tasks may produce partial results.
**Note:** server often exits with code 1 on task completion — this is normal; just restart if you need more tasks.
### `account_deactivated`
OpenAI rejects email: "You do not have an account because it has been deleted or deactivated."
→ Email was previously used and banned. Move to next email. Large portion of t-online.de pool is burned.
### IMAP timeout (180s)
Worker waits for verification code from IMAP. If email doesn't arrive within 180s, task errors out.
→ Affected emails likely have slow IMAP delivery or inbox is full.
### `邮箱池为空` (empty mailbox pool)
IMAP pool config file missing or empty.
→ Verify `C:/Users/User/Desktop/GPT-AUTOREG/emails.txt` exists and has entries.
→ Reset pool state: `echo "{}" > data/.imap_mailbox_pool_state.json`
### Provider settings API blocked
Only DELETE is allowed for individual settings. No PUT/PATCH.
→ Workaround: update path directly in SQLite `provider_settings` table, then restart server.
### Stale tasks stuck at N/X
Worker waiting for IMAP — can take up to 180s. Wait or check server logs.
### Token lifetime — hours, not days
Session cookies (`__Secure-next-auth.session-token`) expire in ~1-3 hours after registration.
Extract tokens IMMEDIATELY after task completion. Do not rely on accounts staying valid overnight.
See `references/token-extraction.md` for the extraction workflow.
### "Unusual activity" on /backend-api/conversation
New accounts (<24h old) get HTTP 403 `"Unusual activity has been detected from your device"`
when hitting `/backend-api/conversation`. The `/backend-api/me` endpoint works (read-only).
→ Accounts need time to «warm up» (24-48h) before API usage.
→ The only working transport is Camoufox browser — plain httpx/requests are blocked by Cloudflare.
## Full Toolkit Archive
When user asks to gather all autoreg files, consolidate from these sources:
| Source | Contents |
|---|---|
| `_PROJECTS/oai-register/aBaiAutoplus/` | Main toolkit (exclude .venv, node_modules, frontend) |
| `Downloads/Telegram Desktop/working_mails.txt` | 17,893 t-online.de accounts |
| `Downloads/Telegram Desktop/*Good*Mail*` | 32 mail:pass lists |
| `SESSION-BASE/autoreg.md` | Reference document |
| `Desktop/conol_github/*autoreg*` | Conol scripts |
| `Desktop/velokey_autoreg/` | Velokey autoreg |
| `Desktop/sepa_autoreg.py` + `~/sepa_autoreg.py` | SEPA autoreg |
| `~/gorouter_autoreg.py` | Gorouter autoreg |
| `~/Desktop/baaaai_autoreg.py` | Baia autoreg |
| `tmp/gmail_autoreg.py` | Gmail autoreg |
| `tmp/autoreg_v*.py` | 44 iterative versions |
| `_PROJECTS/grok_proxy_pool.py` + `grok_cli_proxy.py` | Proxy scripts |
**Archive command:** `tar czf GPT-AUTOREG-FULL.tar.gz GPT-AUTOREG-FULL/`
(Use tar, not zip/7z — only tar+gzip available in Git Bash on this Windows host)
## Account Validity Check
Accounts are auto-checked by LifecycleManager. Statuses:
- `registered` — just created, not yet verified
- `valid` — token works, account active
- `invalid` — token expired or account banned
Check latest account state: `curl -s "http://localhost:8000/api/accounts?limit=3"`
## Token Extraction & API Usage
After successful registration, extract tokens from the SQLite DB for API use:
```python
# Query valid accounts with tokens
import sqlite3, json
db = sqlite3.connect("C:/Users/User/Desktop/GPT-AUTOREG/aBaiAutoplus/account_manager.db")
rows = db.execute("""
SELECT ao.account_id, ao.remote_email, ac.key, ac.value
FROM account_overviews ao
JOIN account_credentials ac ON ao.account_id = ac.account_id
WHERE ao.validity_status = 'valid' AND ac.credential_type IN ('token','cookie')
""").fetchall()
```
### accounts_tokens.json format
The image API server (`image_api_server.py` in `GPT-AUTOREG/`) expects:
```json
{
"accounts": [
{
"email": "[REDACTED-EMAIL]",
"tokens": {
"session_token": "eyJhbG...",
"access_token": "eyJhbG...",
"legacy_token": "eyJhbG...",
"csrf_token": "abc123%7Cdef456",
"cookies": "{'__Secure-next-auth.session-token': '...', ...}"
}
}
]
}
```
### image_api_server.py
FastAPI server on port 8400. Uses Camoufox browser to bypass Cloudflare and call
`chatgpt.com/backend-api/conversation` for DALL-E image generation.
```bash
cd "C:/Users/User/Desktop/GPT-AUTOREG" && python -u image_api_server.py
# Endpoints: GET /health, GET /accounts, POST /generate
```
**Known limitation:** accounts <24h old return 403 "Unusual activity".
The `/me` endpoint works; conversation endpoint needs aged accounts.
### Camoufox transport
Only Camoufox (Firefox-based anti-detection browser) bypasses Cloudflare for `chatgpt.com`.
Playwright Chromium and httpx both get blocked with 403 challenge pages.
```python
from camoufox.async_api import AsyncCamoufox
async with AsyncCamoufox(headless=True, locale="en-US", block_webrtc=True) as browser:
page = await browser.new_page()
await page.goto("https://chatgpt.com/")
await page.context.add_cookies(cookies_list)
# Now fetch() from page.evaluate() inherits cookies + TLS fingerprint
```
See `references/token-extraction.md` for full workflow.