From b2f30a290751c1c2e3fd0506cca665002fe58bc0 Mon Sep 17 00:00:00 2001 From: src48597962 <48597962@qq.com> Date: Sun, 28 Jan 2024 11:26:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SrcJyAliPublic.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SrcJyAliPublic.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/SrcJyAliPublic.js b/SrcJyAliPublic.js index 4a644da..51de56e 100644 --- a/SrcJyAliPublic.js +++ b/SrcJyAliPublic.js @@ -431,4 +431,49 @@ function getOpenToken(authorization) { } } return open_access_token || ""; +} + +function test_aliecc() { + let headers = { + "content-type": "application/json;charset=UTF-8", + "origin": "https://www.aliyundrive.com", + "referer": "https://www.aliyundrive.com/", + "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41" + }; + let appId = "5dde4e1bdf9e4966b387ba58f4b3fdc3"; + let nonce = 0; + + // 生成私钥和公钥 + let private_key = BigInt.random(2 ** 256 - 1); + let ecc_pri = new ECDSA.ECDSA(private_key, "secp256k1"); + let ecc_pub = ecc_pri.getVerifyingKey(); + let public_key = "04" + ecc_pub.toString(); + + function r(appId, deviceId, userId, nonce) { + return `${appId}:${deviceId}:${userId}:${nonce}`; + } + + function sign(appId, deviceId, userId, nonce) { + let sign_dat = ecc_pri.sign( + r(appId, deviceId, userId, nonce).getBytes('utf-8'), + ECDSA.sha256 + ); + return sign_dat.toString() + "01"; + } + let signature = sign(appId, "3a9935208f4b4fce95a9655c7725d640", "3426ad8ebaa04e1ea9ee01bd998d06d4", nonce); + log(signature); + headers['x-signature'] = signature; + let data = { + "deviceName": "Edge浏览器", + "modelName": "Windows网页版", + "pubKey": public_key, + } + if (signature && public_key) { + let req = JSON.parse(request("https://api.aliyundrive.com/users/v1/users/device/create_session", { headers: headers, body: data, timeout: 3000 })); + log(req); + if (req.success) { + return { "signature": signature, "success": 1 } + } + } + return { "success": 0 } } \ No newline at end of file