fix(ncm): weapi挂死根因修复 (agent-207, 6缺陷叠加) — ①超时改CLOCK_MONOTONIC(墙钟NTP回拨致poll超长阻塞) ②响应头解析隔行跳行漏Content-Length ③请求头缓冲1KB→8KB ④cookie值截断192B致MUSIC_U不完整被当游客(改ptr+len不截断+按名去重) ⑤split处NUL覆盖body首字节 ⑥Content-Length:0直接DONE; status_check硬上限6s; 803后worker线程取uid/nick落盘(修uid恒空)
ncm→bf6d2a79 已部署; 真机1次验证(风控合规): status_check 721ms rc=0 uid=408996274; user_playlist 2.5s rc=0 count=64
This commit is contained in:
1 parent
4ff8c8baa3
commit
a651df0e9b
19 files changed
+466
-71
No files matched your search
@@ -0,0 +1,44 @@
|
||||
/* host_fullcookie.c — 用完整原始 cookie 直发 weapi account/get,验证服务器是否识别会话。
|
||||
* 绕过 ncm_req_build 的 ck_parse 截断:手写 Cookie 头 + 只用 ncm_crypto_weapi 生成 body。
|
||||
* 用法: ./host_fullcookie '<完整cookie>' [cacert]
|
||||
*/
|
||||
#include "ncm.h"
|
||||
#include "ncm_crypto.h"
|
||||
#include "ncm_http.h"
|
||||
#include "ncm_common.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 2) { fprintf(stderr, "usage: %s '<cookie>'\n", argv[0]); return 1; }
|
||||
const char *cookie = argv[1];
|
||||
ncm_http_set_verify_default(1, argc > 2 ? argv[2] : NULL);
|
||||
|
||||
char params[1024], encsk[300];
|
||||
int rc = ncm_crypto_weapi("{\"csrf_token\":\"\"}", params, sizeof params, encsk, sizeof encsk);
|
||||
if (rc != NCM_OK) { printf("weapi crypto rc=%d\n", rc); return 1; }
|
||||
char p_enc[1100];
|
||||
if (ncm_url_encode(params, p_enc, sizeof p_enc) < 0) { printf("urlencode fail\n"); return 1; }
|
||||
char body[1400];
|
||||
snprintf(body, sizeof body, "params=%s&encSecKey=%s", p_enc, encsk);
|
||||
|
||||
char hdrs[2048];
|
||||
snprintf(hdrs, sizeof hdrs,
|
||||
"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0\r\n"
|
||||
"Content-Type: application/x-www-form-urlencoded\r\n"
|
||||
"Cookie: %s\r\n"
|
||||
"Referer: https://music.163.com", cookie);
|
||||
|
||||
ncm_http_req_t req; memset(&req, 0, sizeof req);
|
||||
req.url = "https://music.163.com/weapi/w/nuser/account/get";
|
||||
req.method = "POST"; req.body = body; req.body_len = strlen(body);
|
||||
req.extra_hdrs = hdrs; req.verify_ca = NCM_HTTP_VERIFY_DEFAULT; req.timeout_ms = 20000;
|
||||
char respbuf[65536]; ncm_http_resp_t resp;
|
||||
long t0 = (long)ncm_now_ms();
|
||||
rc = ncm_http_request(&req, respbuf, sizeof respbuf, &resp);
|
||||
long dt = (long)ncm_now_ms() - t0;
|
||||
printf("rc=%d elapsed_ms=%ld status=%d cl=%zu chunked=%d body_len=%zu\n",
|
||||
rc, dt, resp.status, resp.content_length, resp.chunked, resp.body_len);
|
||||
if (resp.body_len) printf("body:\n%.*s\n", (int)resp.body_len, resp.body);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user