| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- """Systematic CS 2001 with ALL corrections:
- Fix matrix vs previous attempts:
- 1. otp tail = literal "1/0" (from LoginOtpPassWordProxy.lua)
- 2. param2 = main_serverid = the server's OWN sid (from getTodayOpen:
- 霸业12服 sid=14414738 has main_serverid=14414738 — NOT 14414736)
- 3. param3 = that server's port from srvlist
- 4. Connect to each DNS IP explicitly (proxy rotation may differ per IP)
- Also verifies our encode6bit against the real Lua Encode6BitBuf if found.
- """
- import asyncio
- import base64
- import json
- import random
- import struct
- import sys
- from pathlib import Path
- sys.path.insert(0, "src")
- from cq2_sdk.utils.encoding import encode6bit
- raw = Path(r"D:\ProgramFiles\996box\GameBoxDownload\1\env.json").read_bytes()
- text = raw.decode("utf-8", errors="replace")
- idx = text.find("eyJ")
- b64 = text[idx:].rstrip()
- padded = b64 + "=" * ((-len(b64)) % 4)
- env = json.loads(base64.urlsafe_b64decode(padded).decode("utf-8", errors="replace"))
- uid = str(env["uid"])
- token = env["token"]
- channel = env.get("channel", "110585")
- pwd_enc = encode6bit(token.encode()).decode("ascii")
- ch_enc = encode6bit(channel.encode()).decode("ascii")
- IPS = ["47.118.169.147", "47.118.169.153", "47.118.172.233"]
- # (sid, port, label) — from cached srvlist (state=1 open servers)
- TARGETS = [
- (14414738, 8021, "霸业12服 main=self"),
- (14414739, 8061, "霸业13服 main=self"),
- (14414741, 8061, "霸业15服(user env sid)"),
- ]
- async def attempt(ip: str, sid: int, port: int, label: str) -> None:
- body = f"{uid}/{pwd_enc}/{ch_enc}/1/0"
- p1 = random.randint(100_000_000, 2_100_000_000) & 0xFFFF00FF
- frame = struct.pack("<6i", 2001, 900000, p1, sid, port, len(body)) + body.encode()
- try:
- r, w = await asyncio.wait_for(asyncio.open_connection(ip, 12000), timeout=5)
- except Exception as e:
- print(f" {ip} {label}: connect {type(e).__name__}")
- return
- try:
- w.write(frame)
- await w.drain()
- total = b""
- import time
- t0 = time.time()
- while time.time() - t0 < 5:
- try:
- chunk = await asyncio.wait_for(r.readexactly(6), timeout=1.5)
- total += chunk
- if len(total) >= 24:
- mid, recog, p1r, p2r, p3r, blen = struct.unpack("<6i", total[:24])
- print(f" {ip} {label}: *** FRAME msg_id={mid} recog={recog} p2={p2r} blen={blen} ***")
- if 0 < blen < 4096:
- try:
- rest = await asyncio.wait_for(r.readexactly(blen), timeout=3)
- print(f" body: {rest[:200]!r}")
- except Exception:
- pass
- return
- except asyncio.IncompleteReadError:
- break
- except (asyncio.TimeoutError, TimeoutError):
- if total:
- break
- if total:
- print(f" {ip} {label}: {len(total)}B hex={total.hex()}")
- else:
- print(f" {ip} {label}: closed 0B")
- finally:
- w.close()
- try:
- await w.wait_closed()
- except Exception:
- pass
- async def main():
- print(f"uid={uid} channel={channel} tail=/1/0 p2=sid(self) p3=port")
- print()
- for sid, port, label in TARGETS:
- for ip in IPS[:2]: # try 2 IPs per target to limit time
- await attempt(ip, sid, port, label)
- await asyncio.sleep(0.4)
- print()
- asyncio.run(main())
|