Skip to content

fix: use new CN APIManager keyset for app version 6.4.0+ - #3

Merged
MetaMikuAI merged 1 commit into
mainfrom
fix/cn-640-api-keyset
Nov 11, 2026
Merged

MetaMikuAI merged 1 commit into
mainfrom
fix/cn-640-api-keyset

Conversation

@MetaMikuAI

@MetaMikuAI MetaMikuAI commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #2

问题

国服服务端会根据请求头 X-App-Version 选择 API 的 AES keyset。客户端版本为 6.4.0 及以上时,响应用的是一组新的 key/IV。sssekai 仍用旧 keyset 解密,结果是空数据,于是 msgpack 报 Unpack failed: incomplete input。

对 GET /api/system 的实测结果:

X-App-Version 旧 keyset 新 keyset
1.0.0 ~ 6.3.5 ✅ —
6.4.0 / 6.5.0 / 9.9.9 ❌ ✅

新 key/IV 来自国服 6.4.0 APK 的 global-metadata.dat:

  • key P**************O
  • iv r**************O

改动

  • crypto/APIManager.py:cn 换成新 keyset,旧 keyset 改名为 cn-legacy;新增 get_keyset(region, app_version),国服版本低于 6.4.0 时用 legacy keyset
  • abcache:请求加密和响应解密都改用 get_keyset
  • apidecrypt:--region 新增 cn-legacy,用于解密旧版本的抓包数据

测试

  • 通过 AbCache._update_system_data() 实际请求国服:6.4.0 用新 keyset 解密成功;6.3.0 和 5.4.0 用 legacy keyset 解密成功
  • ⚠️ 登录接口(POST user auth)以及 6.4.0 之后的 AssetBundleInfo 还没验证。

🤖 Generated with Claude Code

The CN server now selects the API AES keyset by the X-App-Version header.
Clients reporting 6.4.0 or later receive responses encrypted with a new
key/IV (extracted from the 6.4.0 global-metadata), so decrypting them with
the old keyset yielded empty data and msgpack failed with
'Unpack failed: incomplete input'.

- Add get_keyset(region, app_version) that falls back to the legacy keyset
  for CN versions below 6.4.0
- Use it for request encryption / response decryption in AbCache
- Add 'cn-legacy' region to apidecrypt for old dumps

Fixes #2
@MetaMikuAI
MetaMikuAI merged commit 6300970 into main Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

国服无法使用 abserve

1 participant