| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- """Look up sid 14403981 (the server the USER ACTUALLY selected in the SAZ
- capture — session 753 EnterGameClient body) in the cached srvlist, then
- send CS 2001 with THAT server's exact main_serverid/port.
- All previous probes used 霸业-series servers (14414736-41) from getTodayOpen,
- but the task target is 玖扬复古176 (group tag 1000514, main 14301060) —
- a completely different group!
- """
- 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"])
- pwd_enc = encode6bit(env["token"].encode()).decode("ascii")
- ch_enc = encode6bit(env.get("channel", "110585").encode()).decode("ascii")
- BODY = f"{uid}/{pwd_enc}/{ch_enc}/1/0"
- srv = json.loads(
- Path(r"D:\ProgramFiles\996box\GameBoxDownload\1\cq\cache_206923\ResServerlist.txt_206923").read_text(encoding="utf-8")
- )
- # 1. Find the user's actual server 14403981
- # serverData is a LIST of server dicts (fields d/p/s/u/m/n/t/g/w/c)
- target = None
- target_group = None
- groups = {g["tag"]: g["name"] for g in srv.get("serverGroup", [])}
- for s in srv.get("serverData", []):
- if str(s.get("d")) == "14403981":
- target = s
- target_group = groups.get(s.get("t"))
- break
- print("=== user's ACTUAL server from SAZ (14403981) ===")
- if target:
- print(f"group: {target_group} (tag={target.get('t')})")
- print(f"sid={target.get('d')} port={target.get('p')} proxyport={target.get('x')} state={target.get('s')}")
- print(f"host={target.get('i')}")
- print(f"all fields: {json.dumps(target, ensure_ascii=False)}")
- else:
- print("NOT FOUND in cached srvlist — trying live srvlist")
- # 2. Also list a few 玖扬 group servers (t=1000514) with state=1
- print()
- print("=== 玖扬复古176 (t=1000514) open servers (first 6) ===")
- jiuyang = [s for s in srv.get("serverData", []) if str(s.get("t")) == "1000514" and str(s.get("s")) == "1"]
- for s in jiuyang[:6]:
- print(f" sid={s.get('d')} port={s.get('p')} proxy={s.get('x','')} name={s.get('n','')}")
- # 3. Probe CS 2001 against the user's actual server + a couple 玖扬 servers
- IPS = ["47.118.169.147", "47.118.169.153", "47.118.172.233"]
- async def probe(sid: int, port: int, main_sid: int, label: str, ip: str = IPS[1]) -> None:
- p1 = random.randint(100_000_000, 2_100_000_000) & 0xFFFF00FF
- frame = (
- struct.pack("<6i", 2001, 900000, p1, main_sid, port, len(BODY.encode()))
- + BODY.encode()
- )
- try:
- r, w = await asyncio.wait_for(asyncio.open_connection(ip, 12000), timeout=5)
- except Exception as e:
- print(f" {label}: connect {type(e).__name__}")
- return
- try:
- w.write(frame)
- await w.drain()
- total = b""
- t0 = asyncio.get_event_loop().time()
- while asyncio.get_event_loop().time() - t0 < 4:
- try:
- chunk = await asyncio.wait_for(r.read(4096), timeout=1.5)
- if not chunk:
- break
- total += chunk
- if len(total) >= 6:
- break
- except asyncio.TimeoutError:
- if total:
- break
- if total:
- same = total == b"\x00" * 6
- note = "" if same else " *** DIFFERENT REPLY — PROGRESS! ***"
- print(f" {label}: {len(total)}B {total.hex()[:40]}{note}")
- else:
- print(f" {label}: no reply")
- finally:
- w.close()
- try:
- await w.wait_closed()
- except Exception:
- pass
- async def main():
- print()
- print("=== CS 2001 probes (corrected: user's real server + 玖扬 opens) ===")
- if target:
- main_sid = int(target.get("m") or target.get("d"))
- port = int(target.get("p"))
- await probe(int(target["d"]), port, main_sid, f"user-server 14403981 (main={main_sid}, port={port})")
- await asyncio.sleep(0.5)
- for s in jiuyang[:3]:
- sid = int(s["d"])
- main_sid = int(s.get("m") or sid)
- port = int(s["p"])
- await probe(sid, port, main_sid, f"玖扬 sid={sid} (main={main_sid}, port={port})")
- await asyncio.sleep(0.5)
- # also the group main 14301060
- await probe(14301060, int(next((x["p"] for x in srv["serverData"] if str(x.get("d")) == "14301060"), 8001)), 14301060, "玖扬战区 main=14301060")
- asyncio.run(main())
|