| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- """Probe 996box server list with different hosts, methods, and headers.
- Tests:
- 1. GET api.996hezi.com with User-Agent + Referer (still 996SDK v2 sign)
- 2. GET list-box.dhsf.xqhuyu.com/box_serverlist/206923.txt (modlist host, srvlist sign)
- 3. GET list-box.dhsf.xqhuyu.com/box_serverlist/206923.txt (no sign, raw)
- """
- import asyncio
- import os
- import sys
- import time
- import hashlib
- import hmac
- sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, "src"))
- from cq2_sdk.env_loader import load_env
- load_env()
- import httpx
- def srvlist_sign(path: str, key: str, ts: int) -> str:
- """MD5("data=" + path + "&key=" + key + "&time=" + ts) per cq2-01 sec 3.2."""
- s = f"data={path}&key={key}&time={ts}"
- return hashlib.md5(s.encode()).hexdigest()
- async def probe():
- signkey = os.environ.get("CQ2_SIGNKEY", "")
- print("=== Test 1: GET api.996hezi.com with User-Agent + Referer (996SDK v2 sign) ===")
- ts = int(time.time())
- params = {
- "gameid": "206923",
- "channel": "110585",
- "sdkChannel": "996box_pc",
- "isBoxLogin": "1",
- "time": str(ts),
- }
- sorted_keys = sorted(params.keys())
- canon = "\n".join(f"{k}={params[k]}" for k in sorted_keys)
- sign = hmac.new(signkey.encode(), canon.encode(), hashlib.sha1).hexdigest()
- params["sign"] = sign
- async with httpx.AsyncClient(timeout=15) as c:
- r = await c.get(
- "https://api.996hezi.com/userApi/v1/Server/list",
- params=params,
- headers={
- "User-Agent": "996Box/5.1.1.9007",
- "Referer": "https://api.996hezi.com/",
- },
- )
- print(f" status: {r.status_code}")
- try:
- data = r.json()
- print(f" code: {data.get('code')}, msg: {data.get('msg')}")
- except Exception:
- print(f" text: {r.text[:200]}")
- print()
- print("=== Test 2: list-box.dhsf.xqhuyu.com srvlist (modlist key) ===")
- modlist_key = "shPUZw4ncV5oJ3Hu"
- path = "/box_serverlist/206923.txt"
- ts = int(time.time())
- sign = srvlist_sign(path, modlist_key, ts)
- async with httpx.AsyncClient(timeout=15) as c:
- r = await c.get(
- f"https://list-box.dhsf.xqhuyu.com{path}",
- params={"time": str(ts), "sign": sign},
- headers={"User-Agent": "996Box/5.1.1.9007"},
- )
- print(f" status: {r.status_code}")
- print(f" content-type: {r.headers.get('content-type')}")
- print(f" text[:300]: {r.text[:300]}")
- print()
- print("=== Test 3: box_serverlist/206923.txt raw (no sign) ===")
- async with httpx.AsyncClient(timeout=15) as c:
- r = await c.get(
- "https://list-box.dhsf.xqhuyu.com/box_serverlist/206923.txt",
- headers={"User-Agent": "996Box/5.1.1.9007"},
- )
- print(f" status: {r.status_code}")
- print(f" text[:500]: {r.text[:500]}")
- asyncio.run(probe())
|