Files
live-hub-py/docs/虎牙纯Python全自动登录-总结与交接.md
T

70 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 虎牙纯Python全自动登录 — 总结与交接(2026-08-25
## 一、已达成 ✅(全部实测验证)
### 核心链路(可信账号,零设备零手动)
```
账号+密码
→ SHA1
→ build_password_login_wup() 组TAF包 (servant=huyaudbwebui, func=hypasswordLogin)
→ POST https://wup.huya.com [body=原始TAF字节, CT=application/multipart-formdata]
→ HTTP 200 → 解析响应bean → 新鲜cred(114B, 0a开头, 每次登录轮换)
→ cert_forge.build_p1(fingerprint + 新nonce + cred) → forge_cert(key_idx=0x20)
→ 扫码绑定流 getQrId→scanQrPicNotify→bindQrLoginUser→tryQrLogin
→ POST /web/cookie/verify {"appId":5002} ← 关键最后一步!
→ 全套网页Cookie: udb_cred/yyuid/udb_uid/udb_passport/username/udb_biztoken...
```
### 一键工具
| 命令 | 功能 |
|---|---|
| `.venv/bin/python tools/full_web_cookie.py <账号> <密码>` | 密码→全套网页Cookie(写 evidence/web_cookies_full.txt|
| `.venv/bin/python tools/full_auto_test.py <账号> <密码>` | 密码→cred→铸证→bind 全链路自测 |
## 二、关键知识(踩坑实录)
1. **wupData信封有服务端TTL**bind用的一次性wupData(session/nonce)过期即40020
CERT_BIZERR_CREATE_ERROR——与cred无关!刷新方法:设备跑 scripts/hook_cert_keycap.py
(Java桥自动触发getQUrlData,无需人工)。
2. **cred每次登录轮换**,第二字节是代次计数器(0x10/0x20/.../0x80循环);旧cred短期仍有效。
3. **响应bean解析**_wup_data值=SIMPLE_LIST(0x1d)+elem头(00)+JCE优化int长度;
bean内 tag3(bytes)=cred。虎牙TAF类型表: STR1=6/STR4=7/MAP=8/LIST=9/
STRUCT_BEGIN=10(0xa)/STRUCT_END=11(0xb)/ZERO=12/SIMPLE_LIST=13。
4. **udb消息载荷=JSON命名键**(非二进制JCE)msgId: LoginPassport=0x1001,
Response=0x2001; wire双体系: 0x0Bxxxxxx业务推送族 vs udb裸id。
5. **证书算法**=标准AES-128-ECBP1=[01 04]["5008"][u16le20+20B nonce][u16le40+40B指纹][u16le114+cred]
cert=b64([0x0C][key_idx][AES128(key16,zeropad(P1))]);钥表@rodata 0x1bc810(AESkeyMgr注册)。
6. **存储侧**: cred0文件=AES-128-ECB("HuyaUdb192837465")加密的JSON
cred路径 /loginHistory[0]/apploginData/cred。
## 三、新账号风控(safe_auth)——当前唯一待完成项
### 定性(已实锤)
- App渠道(WUP)对新/异地账号返回 `aq.huya.com/p/safe_auth/pt_auth.html?param=xxx`
- 页面走 **udbrtt.huya.com 滑块**(主chunk含slideBlock*字段)
- **与 core/huya/verification/solver.py 已实现的 udbrtt get3→verify3 闭环同源**
- web渠道(5002)才是qr_auth扫码型;App渠道=滑块=可自动
### 下会话开工清单
1. 抓 pt_auth 页初始化 udbrtt 的请求(param如何传入get3)
页面JS chunk: https://a.msstatic.com/huya/hd/h5/udb/js/safe_auth-pt_auth.1a35e28a.js
2. 用 HuyaVerificationSolver 解滑块→verify3 提交(带param上下文)
3. 重发 WUP 登录 → cred 直出 → 新账号也全自动
4. 备选: 对比真机App解滑块时的请求(hook udbrtt 流量)加速逆向
## 四、多账号运营模型
```
新账号首次: 手机App正常登录一次(建设备信任, 若遇滑块人工滑一下)
之后永久: 密码 → full_web_cookie.py → 全套cookie 自动出
```
## 五、资产清单
- 组包: tools/huya_wup_encoder.py (build_password_login_wup, 自检对金样本)
- 铸证: tools/cert_forge.py (build_p1/forge_cert/parse_p1)
- 绑定: scripts/probe_forge_cert_bind.py (QrRole四步流+cert替换)
- 网页登录: core/huya/login.py (含滑块solver集成, web渠道)
- 滑块: core/huya/verification/{solver,track}.py + core/geetest/v3_slide
- 设备指纹: core/huya/device_fingerprint.py (get_huya_sdid)
- 证据: evidence/* (金样本wup_passwordlogin_taf.bin等)
- 协议细节全记录: docs/虎牙hyCred签发-侦察笔记.md (按Round追加)