| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- """CS 2001 with FULLY corrected body per decrypted Lua sources.
- Corrections vs all previous attempts (from LoginOtpPassWordProxy.lua):
- - otpType = "1" (getCheckType() hardcoded, appended RAW)
- - otpCode = "0" (getOtpCode() default 0, appended RAW — NO Encode6BitBuf)
- - account = uid (AuthProxy:GetUID())
- - password = env.json token (AuthProxy:GetToken()), Encode6BitBuf'd
- - channelID, Encode6BitBuf'd
- Body format (LoginProxy.lua line 395):
- account / Encode6BitBuf(password) / Encode6BitBuf(channelID) / 1 / 0
- (literal string "1") (literal 0)
- """
- 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")
- # *** THE FIX: literal "1" and "0", NOT encoded ***
- body = f"{uid}/{pwd_enc}/{ch_enc}/1/0"
- main_sid = 14414736
- server_port = 8021
- param1 = random.randint(100_000_000, 2_100_000_000) & 0xFFFF00FF
- frame = struct.pack("<6i", 2001, 900000, param1, main_sid, server_port, len(body.encode())) + body.encode()
- print(f"body = {body}")
- print(f" (tail check: must end with literal '/1/0' -> ...{body[-8:]!r})")
- print(f"frame: {len(frame)}B msg=2001 recog=900000 p1={param1} p2={main_sid} p3={server_port}")
- print()
- async def send_and_read():
- print("connecting gfgame:12000 ...")
- r, w = await asyncio.wait_for(asyncio.open_connection("gfgame.dhsf.xqhuyu.com", 12000), timeout=6)
- try:
- w.write(frame)
- await w.drain()
- print("sent.")
- # read in exact chunks; server replies 6B zeros per earlier capture
- total = b""
- import time
- t0 = time.time()
- while time.time() - t0 < 8:
- try:
- chunk = await asyncio.wait_for(r.readexactly(6), timeout=2)
- total += chunk
- print(f" +6B: {chunk.hex()}")
- if len(total) >= 24:
- # could be a 24B frame header
- mid, recog, p1, p2, p3, blen = struct.unpack("<6i", total[:24])
- print(f" *** 24B frame: msg_id={mid} recog={recog} p2={p2} p3={p3} body_len={blen}")
- if blen > 0 and blen < 4096:
- rest = await asyncio.wait_for(r.readexactly(blen), timeout=3)
- print(f" body: {rest!r}")
- return
- except asyncio.IncompleteReadError as e:
- print(f" closed after {len(total)}B total; partial={e.partial.hex() if e.partial else ''}")
- break
- except (asyncio.TimeoutError, TimeoutError):
- if total:
- break
- if total and len(total) < 24:
- mid = struct.unpack("<i", total[:4])[0] if len(total) >= 4 else None
- print(f" total {len(total)}B hex={total.hex()} msg_id_guess={mid}")
- finally:
- w.close()
- try:
- await w.wait_closed()
- except Exception:
- pass
- asyncio.run(send_and_read())
|