feat(huya): 分身 CK 支持 cred0 解密补全,WSS 帧改为 JCE WebSocketCommand

- scripts/huya_clone_ck.py: root 读取小X分身/真身 WebView Cookie,默认
  用 AES-128-ECB(UDB 主密钥前 16B) 解 cred0 注入 udb_cred,新增
  --anon-device 补匿名设备字段、--no-cred0 退回旧行为
- core/huya/wss_client.py: 帧层改用浏览器 HUYA.WebSocketCommand(JCE)
  结构,vData 直接放 Wup 原包,按 WUP iRequestId 匹配响应,初始化顺序
  对齐 RegisterGroup→wsLaunch→VerifyCookie→getConfig→UpdateUserExps
- tests: 帧级断言改为新结构,假 WS 按 requestId 兑现
- docs: 新增分身 CK 提取、HAR 提取 CK 与积分中心说明

实测:四个分身 cred0 解出 udb_cred(39/43 字段),WSS
PlayMallUI.queryAllocation 返回 code=200、18 个商品;tests -k huya 394 passed
This commit is contained in:
yml2213
2026-10-26 11:23:29 +08:00
parent 6fc453017c
commit 03bc0818dd
9 changed files with 1188 additions and 156 deletions
+31 -2
View File
@@ -795,6 +795,7 @@ def points_center_blob(
product_id: str = "hy-1001",
points: int = 200,
stock: int = 39,
remaining: int | None = None,
category: str = "礼包",
) -> bytes:
"""构造 queryAllocation 的 ``tag5`` 最小商品列表(TAF LIST)。"""
@@ -817,6 +818,13 @@ def points_center_blob(
os.write_string(5, "")
os.write_int64(9, points * 10)
os.write_int64(13, stock)
if remaining is not None:
os.write_int64(14, remaining)
os.write_head(17, TafType.LIST)
os.write_int32(0, 1)
os.write_head(0, TafType.STRUCT_BEGIN)
os.write_int64(3, remaining)
os.write_struct_end()
# 积分 tag75.tag0.tag2
os.write_head(75, TafType.STRUCT_BEGIN)
os.write_head(0, TafType.STRUCT_BEGIN)
@@ -1295,8 +1303,9 @@ class TestCollabCkPreview(TestCollabBase):
"product_id": "hy-1001",
"name": "不朽伊人大礼包",
"price": 200,
"remain_text": "剩39",
"remain_text": "39",
"stock": 39,
"claimed": 39,
"score": 200,
"category_name": "礼包",
"icon": "",
@@ -1392,8 +1401,9 @@ class TestCollabGifts(TestCollabBase):
"product_id": "hy-1001",
"name": "不朽伊人大礼包",
"price": 200,
"remain_text": "剩39",
"remain_text": "39",
"stock": 39,
"claimed": 39,
"score": 200,
"category_name": "礼包",
"icon": "",
@@ -1440,6 +1450,25 @@ class TestCollabGifts(TestCollabBase):
assert gifts[0]["score"] == 888
assert gifts[0]["stock"] == 7
def test_points_center_parser_prefers_remaining_stock(self):
"""2026-10-25 抓包:tag13 是累计兑换,tag14 才是剩余库存。"""
from core.huya.shop_structs import parse_points_center_gifts
gifts = parse_points_center_gifts(
{
"tag2": [
{
"tag5": points_center_blob(
points=600, stock=43194, remaining=5054
)
}
]
}
)
assert gifts[0]["claimed"] == 43194
assert gifts[0]["stock"] == 5054
assert gifts[0]["remain_text"] == "5054"
def test_resolve_gifts_sid_prefers_workbench_config(self):
self.db.add(HuyaConfig(sid="2277"))
self.db.commit()