specific-ai-cli 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +177 -0
- package/README.ja.md +177 -0
- package/README.ko.md +177 -0
- package/README.md +174 -2
- package/README.zh-TW.md +177 -0
- package/assets/banner.txt +3 -0
- package/dist/cli/argv.js +98 -0
- package/dist/cli/commands/auth.js +11 -0
- package/dist/cli/commands/config.js +23 -0
- package/dist/cli/commands/doctor.js +134 -0
- package/dist/cli/commands/platforms.js +24 -0
- package/dist/cli/commands/version.js +4 -0
- package/dist/cli/confirm.js +22 -0
- package/dist/cli/dispatch.js +440 -0
- package/dist/cli/help.js +223 -0
- package/dist/cli/hints.js +60 -0
- package/dist/cli/main.js +18 -0
- package/dist/cli/output.js +66 -0
- package/dist/core/auth-handlers.js +41 -0
- package/dist/core/auth-store.js +119 -0
- package/dist/core/capabilities.js +163 -0
- package/dist/core/config.js +121 -0
- package/dist/core/cookies.js +164 -0
- package/dist/core/errors.js +37 -0
- package/dist/core/files.js +89 -0
- package/dist/core/fsutil.js +52 -0
- package/dist/core/hash.js +4 -0
- package/dist/core/http.js +331 -0
- package/dist/core/image.js +280 -0
- package/dist/core/log.js +40 -0
- package/dist/core/login.js +191 -0
- package/dist/core/mp4.js +130 -0
- package/dist/core/normalize.js +207 -0
- package/dist/core/options.js +110 -0
- package/dist/core/paths.js +38 -0
- package/dist/core/pb.js +59 -0
- package/dist/core/py.js +181 -0
- package/dist/core/rand.js +131 -0
- package/dist/core/registry.js +129 -0
- package/dist/core/schemas.js +41 -0
- package/dist/core/stream.js +104 -0
- package/dist/core/toolkit.js +35 -0
- package/dist/core/vm.js +73 -0
- package/dist/core/vocab.js +157 -0
- package/dist/platforms/_shared/impaas.js +410 -0
- package/dist/platforms/bilibili/index.js +216 -0
- package/dist/platforms/bilibili/web/api.js +806 -0
- package/dist/platforms/bilibili/web/client.js +311 -0
- package/dist/platforms/bilibili/web/commands.js +783 -0
- package/dist/platforms/bilibili/web/ddddocr.js +342 -0
- package/dist/platforms/bilibili/web/gaia.js +130 -0
- package/dist/platforms/bilibili/web/geetest-manual.js +154 -0
- package/dist/platforms/bilibili/web/geetest-vision.js +232 -0
- package/dist/platforms/bilibili/web/geetest.js +450 -0
- package/dist/platforms/bilibili/web/normalize.js +234 -0
- package/dist/platforms/bilibili/web/profile.js +135 -0
- package/dist/platforms/bilibili/web/resolve.js +112 -0
- package/dist/platforms/bilibili/web/sign.js +223 -0
- package/dist/platforms/bilibili/web/upos.js +102 -0
- package/dist/platforms/douyin/index.js +142 -0
- package/dist/platforms/douyin/web/api.js +863 -0
- package/dist/platforms/douyin/web/client.js +413 -0
- package/dist/platforms/douyin/web/commands.js +712 -0
- package/dist/platforms/douyin/web/creator.js +601 -0
- package/dist/platforms/douyin/web/crypto.js +247 -0
- package/dist/platforms/douyin/web/dtrait.js +190 -0
- package/dist/platforms/douyin/web/im.js +502 -0
- package/dist/platforms/douyin/web/image.js +5 -0
- package/dist/platforms/douyin/web/live.js +225 -0
- package/dist/platforms/douyin/web/mssdk.js +148 -0
- package/dist/platforms/douyin/web/normalize.js +326 -0
- package/dist/platforms/douyin/web/passport.js +1247 -0
- package/dist/platforms/douyin/web/profile.js +221 -0
- package/dist/platforms/douyin/web/proto.js +26 -0
- package/dist/platforms/douyin/web/resolve.js +88 -0
- package/dist/platforms/douyin/web/sign.js +436 -0
- package/dist/platforms/douyin/web/tos.js +78 -0
- package/dist/platforms/index.js +17 -0
- package/dist/platforms/jd/index.js +67 -0
- package/dist/platforms/jd/web/aks.js +115 -0
- package/dist/platforms/jd/web/api.js +549 -0
- package/dist/platforms/jd/web/chat.js +132 -0
- package/dist/platforms/jd/web/client.js +470 -0
- package/dist/platforms/jd/web/commands.js +557 -0
- package/dist/platforms/jd/web/jcap/helper.js +90 -0
- package/dist/platforms/jd/web/jcap/host.js +107 -0
- package/dist/platforms/jd/web/jcap/lsd.js +300 -0
- package/dist/platforms/jd/web/jcap/solver.js +995 -0
- package/dist/platforms/jd/web/jcap.js +150 -0
- package/dist/platforms/jd/web/js.js +420 -0
- package/dist/platforms/jd/web/login.js +775 -0
- package/dist/platforms/jd/web/normalize.js +297 -0
- package/dist/platforms/jd/web/profile.js +256 -0
- package/dist/platforms/jd/web/util.js +175 -0
- package/dist/platforms/jd/web/webm.js +133 -0
- package/dist/platforms/kuaishou/index.js +98 -0
- package/dist/platforms/kuaishou/web/api.js +694 -0
- package/dist/platforms/kuaishou/web/captcha-crypto.js +134 -0
- package/dist/platforms/kuaishou/web/captcha-fp.js +180 -0
- package/dist/platforms/kuaishou/web/captcha.js +273 -0
- package/dist/platforms/kuaishou/web/client.js +487 -0
- package/dist/platforms/kuaishou/web/commands.js +863 -0
- package/dist/platforms/kuaishou/web/gap.js +144 -0
- package/dist/platforms/kuaishou/web/gdfp.js +376 -0
- package/dist/platforms/kuaishou/web/gql.js +11 -0
- package/dist/platforms/kuaishou/web/live.js +125 -0
- package/dist/platforms/kuaishou/web/normalize.js +241 -0
- package/dist/platforms/kuaishou/web/oracle.js +329 -0
- package/dist/platforms/kuaishou/web/profile.js +259 -0
- package/dist/platforms/kuaishou/web/resolve.js +84 -0
- package/dist/platforms/kuaishou/web/session.js +592 -0
- package/dist/platforms/kuaishou/web/sign.js +568 -0
- package/dist/platforms/taobao/index.js +56 -0
- package/dist/platforms/taobao/web/api.js +96 -0
- package/dist/platforms/taobao/web/client.js +102 -0
- package/dist/platforms/taobao/web/commands.js +172 -0
- package/dist/platforms/taobao/web/im.js +68 -0
- package/dist/platforms/taobao/web/normalize.js +103 -0
- package/dist/platforms/taobao/web/profile.js +85 -0
- package/dist/platforms/taobao/web/resolve.js +51 -0
- package/dist/platforms/taobao/web/sign.js +35 -0
- package/dist/platforms/tiktok/index.js +120 -0
- package/dist/platforms/tiktok/web/api.js +1234 -0
- package/dist/platforms/tiktok/web/client.js +362 -0
- package/dist/platforms/tiktok/web/commands.js +821 -0
- package/dist/platforms/tiktok/web/im.js +133 -0
- package/dist/platforms/tiktok/web/jsrun.js +126 -0
- package/dist/platforms/tiktok/web/normalize.js +286 -0
- package/dist/platforms/tiktok/web/profile.js +169 -0
- package/dist/platforms/tiktok/web/resolve.js +156 -0
- package/dist/platforms/tiktok/web/sign.js +585 -0
- package/dist/platforms/tiktok/web/upload.js +805 -0
- package/dist/platforms/tiktok/web/wire.js +490 -0
- package/dist/platforms/weibo/index.js +91 -0
- package/dist/platforms/weibo/web/api.js +206 -0
- package/dist/platforms/weibo/web/client.js +155 -0
- package/dist/platforms/weibo/web/commands.js +202 -0
- package/dist/platforms/weibo/web/normalize.js +137 -0
- package/dist/platforms/weibo/web/profile.js +246 -0
- package/dist/platforms/weibo/web/resolve.js +60 -0
- package/dist/platforms/weibo/web/sign.js +85 -0
- package/dist/platforms/x/index.js +107 -0
- package/dist/platforms/x/web/api.js +443 -0
- package/dist/platforms/x/web/article.js +212 -0
- package/dist/platforms/x/web/client.js +202 -0
- package/dist/platforms/x/web/commands.js +363 -0
- package/dist/platforms/x/web/graphql.js +108 -0
- package/dist/platforms/x/web/normalize.js +235 -0
- package/dist/platforms/x/web/profile.js +99 -0
- package/dist/platforms/x/web/resolve.js +44 -0
- package/dist/platforms/x/web/transaction.js +171 -0
- package/dist/platforms/xhs/index.js +101 -0
- package/dist/platforms/xhs/web/api.js +278 -0
- package/dist/platforms/xhs/web/client.js +540 -0
- package/dist/platforms/xhs/web/commands.js +1046 -0
- package/dist/platforms/xhs/web/creator-api.js +609 -0
- package/dist/platforms/xhs/web/creator.js +203 -0
- package/dist/platforms/xhs/web/js.js +194 -0
- package/dist/platforms/xhs/web/login.js +230 -0
- package/dist/platforms/xhs/web/normalize.js +166 -0
- package/dist/platforms/xhs/web/profile.js +127 -0
- package/dist/platforms/xhs/web/push.js +361 -0
- package/dist/platforms/xhs/web/resolve.js +69 -0
- package/dist/platforms/xhs/web/state.js +368 -0
- package/dist/platforms/xianyu/index.js +59 -0
- package/dist/platforms/xianyu/web/api.js +312 -0
- package/dist/platforms/xianyu/web/client.js +134 -0
- package/dist/platforms/xianyu/web/commands.js +305 -0
- package/dist/platforms/xianyu/web/im.js +73 -0
- package/dist/platforms/xianyu/web/normalize.js +123 -0
- package/dist/platforms/xianyu/web/profile.js +146 -0
- package/dist/platforms/xianyu/web/resolve.js +48 -0
- package/dist/platforms/xianyu/web/sign.js +79 -0
- package/package.json +77 -4
- package/static/douyin/Live.proto +194 -0
- package/static/douyin/Request.proto +89 -0
- package/static/douyin/Response.proto +46 -0
- package/static/douyin/acrawler_runtime/ac_vm.js +2 -0
- package/static/douyin/acrawler_runtime/browser_window_shape.json +1 -0
- package/static/douyin/acrawler_runtime/canvas_actual_exact.json +1 -0
- package/static/douyin/acrawler_runtime/run_ac_node.js +1005 -0
- package/static/douyin/acrawler_runtime/runner_window_keys_baseline.txt +240 -0
- package/static/douyin/challenge_profile.json +801 -0
- package/static/douyin/challenge_template_runner.js +217 -0
- package/static/douyin/dtrait_profile.json +66 -0
- package/static/douyin/mstoken_common_profile.json +1 -0
- package/static/douyin/mstoken_profile.json +214 -0
- package/static/jd/h5st5_env.js +750 -0
- package/static/jd/h5st5_lib.js +5 -0
- package/static/jd/h5st5_server.js +49 -0
- package/static/jd/jcap/env/env_core.js +512 -0
- package/static/jd/jcap/env/run.js +1307 -0
- package/static/jd/jcap/run/jcap_ujb96b.js +39 -0
- package/static/jd/package.json +4 -0
- package/static/jd/pc_tk_lib.js +1 -0
- package/static/jd/pc_tk_server.js +63 -0
- package/static/jd/summer_cryptico_runner.js +50 -0
- package/static/jd/webm/env/run.js +453 -0
- package/static/jd/webm/run/jdwebm-riskhandle.js +49 -0
- package/static/kuaishou/bundles/weapon/kwf-0.0.2.2cee19b4b7dec496.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-0-0.0.1-obfuscated.4b7f3de1ab0ddcc2.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-1-0.0.1-obfuscated.346ebdb1c78df316.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-10-0.0.1-obfuscated.a33db41897b983af.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-11-0.0.1-obfuscated.5e0a90af726d8a7e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-12-0.0.1-obfuscated.20ea29345706ec8c.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-13-0.0.1-obfuscated.6b74e9640ff18648.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-14-0.0.1-obfuscated.551e4429d156bf66.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-15-0.0.1-obfuscated.8625b087aaba4a60.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-16-0.0.1-obfuscated.d5ffa4020f3be99a.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-17-0.0.1-obfuscated.6d13e19b22f50a80.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-18-0.0.1-obfuscated.6d31405044166289.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-19-0.0.1-obfuscated.a9a8d925942f19e4.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-2-0.0.1-obfuscated.b849a136ae4a6b3e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-3-0.0.1-obfuscated.f9e77ebf6186e2ac.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-4-0.0.1-obfuscated.2c3c155aa52ceb0e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-5-0.0.1-obfuscated.4e553d17691b3c5a.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-6-0.0.1-obfuscated.f73ddd3ff13e1217.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-7-0.0.1-obfuscated.1628b8729beaab7e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-8-0.0.1-obfuscated.6da6baef7aa81fff.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-9-0.0.1-obfuscated.8645d55e5323b743.js +1 -0
- package/static/kuaishou/fixtures/current_follow_script_813.network-response +2 -0
- package/static/kuaishou/fixtures/live_ws_maps.json +61 -0
- package/static/kuaishou/fixtures/live_ws_proto.json +1342 -0
- package/static/kuaishou/js/cp-kwf.js +1 -0
- package/static/kuaishou/tools/kwf_oracle.js +799 -0
- package/static/kuaishou/tools/kws_oracle.js +885 -0
- package/static/kuaishou/tools/like_token_oracle.js +70 -0
- package/static/taobao/taobao_js_20260407.js +570 -0
- package/static/tiktok/Tiktok_Request.json +597 -0
- package/static/tiktok/package.json +3 -0
- package/static/tiktok/shop_bsid/core.js +1 -0
- package/static/tiktok/shop_bsid/env_core.js +512 -0
- package/static/tiktok/shop_bsid/loader.js +1 -0
- package/static/tiktok/shop_bsid/run.js +753 -0
- package/static/tiktok/shop_bsid/sign.js +100 -0
- package/static/tiktok/shop_bsid/webmssdk.js +1 -0
- package/static/tiktok/shop_bsid/webmssdk_ex.js +1 -0
- package/static/tiktok/signing/env/env_core.js +512 -0
- package/static/tiktok/signing/env/sign.js +455 -0
- package/static/tiktok/signing/sdk_config.json +230 -0
- package/static/tiktok/signing/source/webmssdk.js +1 -0
- package/static/tiktok/signing/source/webmssdk_ex.js +1 -0
- package/static/tiktok/signing/source/webmssdk_legacy.js +1 -0
- package/static/x/graphql.json +7777 -0
- package/static/x/transaction_l1.json +12 -0
- package/static/xhs/package.json +3 -0
- package/static/xhs/xhs_core/js/b1.js +210 -0
- package/static/xhs/xhs_core/js/mns.js +340 -0
- package/static/xhs/xhs_core/js/mns_0101_keystream.json +5 -0
- package/static/xhs/xhs_core/js/mns_keystreams.json +1 -0
- package/static/xhs/xhs_core/js/sign.js +225 -0
- package/static/xhs/xhs_core/js/websectiga_cli.js +220 -0
- package/static/xhs/xhs_core/js/websectiga_env.js +512 -0
- package/static/xhs/xhs_core/js/xs_common.js +79 -0
- package/static/xhs/xhs_creator/js/profile.js +115 -0
- package/static/xhs/xhs_creator/js/rap_fingerprint_creator.json +6 -0
- package/static/xhs/xhs_creator/js/reference_profile.json +282 -0
- package/static/xhs/xhs_creator/js/xhs_creator_sign.js +29 -0
- package/static/xhs/xhs_creator/js/xhs_creator_signature.js +23 -0
- package/static/xhs/xhs_pc/js/aes_decrypt.js +22 -0
- package/static/xhs/xhs_pc/js/aes_encrypt.js +30 -0
- package/static/xhs/xhs_pc/js/b1.js +9 -0
- package/static/xhs/xhs_pc/js/deflate.js +320 -0
- package/static/xhs/xhs_pc/js/mns.js +4 -0
- package/static/xhs/xhs_pc/js/profile.js +141 -0
- package/static/xhs/xhs_pc/js/rap.js +173 -0
- package/static/xhs/xhs_pc/js/rap_cli.js +30 -0
- package/static/xhs/xhs_pc/js/rap_crypto.js +73 -0
- package/static/xhs/xhs_pc/js/rap_fingerprint_template.json +8 -0
- package/static/xhs/xhs_pc/js/reference_profile.json +262 -0
- package/static/xhs/xhs_pc/js/sign.js +6 -0
- package/static/xhs/xhs_pc/js/web_ssk.js +82 -0
- package/static/xhs/xhs_pc/js/xs_common.js +4 -0
- package/static/xianyu/et_f.js +2 -0
- package/static/xianyu/gen_tfstk.js +410 -0
- package/static/xianyu/goofish_js_version_2.js +568 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CryptoJS = require('crypto-js');
|
|
4
|
+
const reference = require('./reference_profile.json');
|
|
5
|
+
|
|
6
|
+
const DES_KEY = CryptoJS.enc.Utf8.parse('zbp30y86');
|
|
7
|
+
|
|
8
|
+
function clone(value) {
|
|
9
|
+
return JSON.parse(JSON.stringify(value));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function mapText(value) {
|
|
13
|
+
return Object.entries(value || {}).map(([key, item]) => `${key}:${item}`).join(',');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function buildTelemetry(options = {}) {
|
|
17
|
+
if (options.telemetry != null) return String(options.telemetry);
|
|
18
|
+
const timestampMs = Number(options.timestampMs ?? Date.now());
|
|
19
|
+
const timeOrigin = Number(options.timeOrigin ?? (timestampMs - 613.5));
|
|
20
|
+
const mouse = options.mouse || {};
|
|
21
|
+
const keyboard = options.keyboard || {};
|
|
22
|
+
const page = { ulr: 1, ps: 1, ...(options.page || {}) };
|
|
23
|
+
const state = { h: 0, f: 1, kr: 0, ...(options.state || {}) };
|
|
24
|
+
const features = {
|
|
25
|
+
ae: null,
|
|
26
|
+
ak: null,
|
|
27
|
+
cdr: null,
|
|
28
|
+
bf: null,
|
|
29
|
+
fi: null,
|
|
30
|
+
...(options.features || {}),
|
|
31
|
+
};
|
|
32
|
+
const bfText = features.bf == null
|
|
33
|
+
? 'null'
|
|
34
|
+
: `{ar:${features.bf.ar},fr:${features.bf.fr}}`;
|
|
35
|
+
return `{mt:{to:${timeOrigin}},m:{${mapText(mouse)}},k:{${mapText(keyboard)}},`
|
|
36
|
+
+ `p:{${mapText(page)}},st:{${mapText(state)}},`
|
|
37
|
+
+ `ft:{ae:${features.ae},ak:${features.ak},cdr:${features.cdr},bf:${bfText},fi:${features.fi}}}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function buildProfileFields(options = {}) {
|
|
41
|
+
const profileReference = reference.webProfile;
|
|
42
|
+
const fields = clone(profileReference.fields);
|
|
43
|
+
const timestampMs = Number(options.timestampMs ?? Date.now());
|
|
44
|
+
if (!Number.isSafeInteger(timestampMs) || timestampMs <= 0) {
|
|
45
|
+
throw new TypeError('timestampMs must be a positive safe integer');
|
|
46
|
+
}
|
|
47
|
+
if (options.documentCookie == null) {
|
|
48
|
+
throw new TypeError('documentCookie is required for Creator profileData');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fields.x44 = String(timestampMs);
|
|
52
|
+
fields.x57 = String(options.documentCookie);
|
|
53
|
+
fields.x84 = buildTelemetry({ ...options, timestampMs });
|
|
54
|
+
if (options.location || options.referer) {
|
|
55
|
+
fields.x66 = {
|
|
56
|
+
...fields.x66,
|
|
57
|
+
location: String(options.location || fields.x66.location || ''),
|
|
58
|
+
referer: String(options.referer || fields.x66.referer || ''),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (const [key, value] of Object.entries(options.fields || {})) {
|
|
63
|
+
if (!Object.prototype.hasOwnProperty.call(fields, key)) {
|
|
64
|
+
throw new TypeError(`unsupported Creator webProfile field: ${key}`);
|
|
65
|
+
}
|
|
66
|
+
fields[key] = value;
|
|
67
|
+
}
|
|
68
|
+
return fields;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function encodeProfileData(fields) {
|
|
72
|
+
if (!fields || typeof fields !== 'object' || Array.isArray(fields)) {
|
|
73
|
+
throw new TypeError('profile fields must be an object');
|
|
74
|
+
}
|
|
75
|
+
const serialized = JSON.stringify(fields);
|
|
76
|
+
const base64 = Buffer.from(serialized, 'utf8').toString('base64');
|
|
77
|
+
const encrypted = CryptoJS.DES.encrypt(
|
|
78
|
+
CryptoJS.enc.Latin1.parse(base64),
|
|
79
|
+
DES_KEY,
|
|
80
|
+
{ mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.ZeroPadding },
|
|
81
|
+
);
|
|
82
|
+
return encrypted.ciphertext.toString(CryptoJS.enc.Hex);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function generateProfileData(options = {}) {
|
|
86
|
+
return encodeProfileData(buildProfileFields(options));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function main() {
|
|
90
|
+
const options = process.argv[2] ? JSON.parse(process.argv[2]) : {};
|
|
91
|
+
const profileData = generateProfileData(options);
|
|
92
|
+
process.stdout.write(`${JSON.stringify({
|
|
93
|
+
profileData,
|
|
94
|
+
length: profileData.length,
|
|
95
|
+
sdkVersion: reference.release.webProfileSdkVersion,
|
|
96
|
+
algorithm: reference.webProfile.algorithm,
|
|
97
|
+
})}\n`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (require.main === module) {
|
|
101
|
+
try {
|
|
102
|
+
main();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
process.stderr.write(`${error && error.stack ? error.stack : error}\n`);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = {
|
|
110
|
+
buildTelemetry,
|
|
111
|
+
buildProfileFields,
|
|
112
|
+
encodeProfileData,
|
|
113
|
+
generateProfileData,
|
|
114
|
+
main,
|
|
115
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"source": "creator-publish-rap-decrypt-20260725",
|
|
4
|
+
"note": "从浏览器 Creator post_note(reqid=5609, build 1.19.3)的 x-rap-param 信封 AES 解密所得 436B 指纹模板(rap_crypto decryptBody + mask=0x64)。03ea 段为 16 字符 Uuid(每次生成时应随机化),03eb 段为 RequestHash 槽位(生成时按 url+body 现算覆写)。",
|
|
5
|
+
"bodyUnmaskedHex": "03ea0000001038697236613636656a3471637239793403eb0cbf3674041b00041c00041d00041e00041f00042000042100042200042300042400042500042600042700042800042900042e00042a00042b00042c00042d00044c00000000042f000430000431000433000002b30434000004c904350000019f97e30e7b04360000002affffffff0002c300000000000001fffe000000000100000000000100ffffffff0016c000000000000102043a00000000043b0000019f97e22f5e043c000000a4000000044b657950000501044b657950000500044b657949000b01044b657949000c00044b657944001001044b657944001100044b657945001501044b657945001600044b657952001a01044b657952001b00054d696e7573001f01054d696e7573001f00044b657958002301044b657958002400044b657948002a01044b657948002b00044b657953002e01044b657953002f000553706163650032010553706163650440000000000442000000000449000000000444000004fe0446000004f604470000019f97d9f906044500000000044800044300000004001effff047f00048000048100048200048300048400"
|
|
6
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"source": "creator-browser-4.3.6-20260906",
|
|
4
|
+
"release": {
|
|
5
|
+
"appId": "ugc",
|
|
6
|
+
"platform": "Windows",
|
|
7
|
+
"signVersion": "4.3.6",
|
|
8
|
+
"b1SdkVersion": "3.5.4",
|
|
9
|
+
"webProfileSdkVersion": "4.3.6",
|
|
10
|
+
"webBuild": "1.26.0",
|
|
11
|
+
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36",
|
|
12
|
+
"secChUa": "\"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"152\", \"Google Chrome\";v=\"152\""
|
|
13
|
+
},
|
|
14
|
+
"webProfile": {
|
|
15
|
+
"algorithm": "base64-des-ecb-zero-padding-hex",
|
|
16
|
+
"svn": "2",
|
|
17
|
+
"fields": {
|
|
18
|
+
"x1": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36",
|
|
19
|
+
"x2": "false",
|
|
20
|
+
"x3": "zh-CN",
|
|
21
|
+
"x4": "24",
|
|
22
|
+
"x5": "32",
|
|
23
|
+
"x6": "24",
|
|
24
|
+
"x7": "Google Inc. (NVIDIA),ANGLE (NVIDIA, NVIDIA GeForce RTX 5060 Ti (0x00002D04) Direct3D11 vs_5_0 ps_5_0, D3D11)",
|
|
25
|
+
"x8": "20",
|
|
26
|
+
"x9": "2560;1440",
|
|
27
|
+
"x10": "2560;1392",
|
|
28
|
+
"x11": "-480",
|
|
29
|
+
"x12": "Asia/Shanghai",
|
|
30
|
+
"x13": "true",
|
|
31
|
+
"x14": "true",
|
|
32
|
+
"x15": "true",
|
|
33
|
+
"x16": "false",
|
|
34
|
+
"x17": "false",
|
|
35
|
+
"x18": "un",
|
|
36
|
+
"x19": "Win32",
|
|
37
|
+
"x20": "un",
|
|
38
|
+
"x21": "PDF Viewer,Chrome PDF Viewer,Chromium PDF Viewer,Microsoft Edge PDF Viewer,WebKit built-in PDF",
|
|
39
|
+
"x22": "c8e2f6ff2a07957f70a18cde6b905ebb",
|
|
40
|
+
"x23": "false",
|
|
41
|
+
"x24": "false",
|
|
42
|
+
"x25": "false",
|
|
43
|
+
"x26": "false",
|
|
44
|
+
"x27": "false",
|
|
45
|
+
"x28": "10,false,false",
|
|
46
|
+
"x29": "4,7,8",
|
|
47
|
+
"x30": "swf object not loaded",
|
|
48
|
+
"x31": "124.04347527516074",
|
|
49
|
+
"x33": "0",
|
|
50
|
+
"x34": "0",
|
|
51
|
+
"x35": "0",
|
|
52
|
+
"x36": "2",
|
|
53
|
+
"x37": "0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|1|0|0|0|0|0",
|
|
54
|
+
"x38": "0|0|1|0|1|0|0|0|0|0|1|0|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0",
|
|
55
|
+
"x39": "2",
|
|
56
|
+
"x40": "0",
|
|
57
|
+
"x41": "0",
|
|
58
|
+
"x42": "3.5.4",
|
|
59
|
+
"x43": "Canvas not supported",
|
|
60
|
+
"x44": "__TIMESTAMP_MS__",
|
|
61
|
+
"x45": "__SEC_CAV__1-1-1-1-1|__SEC_UD__|",
|
|
62
|
+
"x46": "false",
|
|
63
|
+
"x47": "1|0|0|0|0|0",
|
|
64
|
+
"x48": "",
|
|
65
|
+
"x49": "{list:[],type:}",
|
|
66
|
+
"x50": "",
|
|
67
|
+
"x51": "",
|
|
68
|
+
"x52": "",
|
|
69
|
+
"x54": "11311144241322244122",
|
|
70
|
+
"x55": "320,260,280,280,280,300,260,260,340,260,240,280,240,320",
|
|
71
|
+
"x56": "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 5060 Ti (0x00002D04) Direct3D11 vs_5_0 ps_5_0, D3D11)|0ebc53d03ea89d69525d81de558e2544|35",
|
|
72
|
+
"x53": "993da9a681fd3994c9f53de11f2903b3",
|
|
73
|
+
"x57": "__DOCUMENT_COOKIE__",
|
|
74
|
+
"x58": "575",
|
|
75
|
+
"x59": "141",
|
|
76
|
+
"x60": "63",
|
|
77
|
+
"x61": "1342",
|
|
78
|
+
"x62": "2047",
|
|
79
|
+
"x63": "0",
|
|
80
|
+
"x64": "0",
|
|
81
|
+
"x65": "0",
|
|
82
|
+
"x66": {
|
|
83
|
+
"referer": "https://creator.xiaohongshu.com/login",
|
|
84
|
+
"location": "https://creator.xiaohongshu.com/new/home",
|
|
85
|
+
"frame": 0
|
|
86
|
+
},
|
|
87
|
+
"x67": "1|0",
|
|
88
|
+
"x68": "0",
|
|
89
|
+
"x69": "un",
|
|
90
|
+
"x70": [
|
|
91
|
+
"location",
|
|
92
|
+
"getElementById",
|
|
93
|
+
"getElementsByTagName",
|
|
94
|
+
"querySelector",
|
|
95
|
+
"querySelectorAll",
|
|
96
|
+
"evaluate"
|
|
97
|
+
],
|
|
98
|
+
"x71": "true",
|
|
99
|
+
"x72": "complete",
|
|
100
|
+
"x73": "990",
|
|
101
|
+
"x74": "0|0|0",
|
|
102
|
+
"x75": "Google Inc.",
|
|
103
|
+
"x76": "true",
|
|
104
|
+
"x77": "1|1|1|1|1|1|1|1|1|1",
|
|
105
|
+
"x78": {
|
|
106
|
+
"x": 0,
|
|
107
|
+
"y": 1213,
|
|
108
|
+
"left": 0,
|
|
109
|
+
"right": 319.40625,
|
|
110
|
+
"bottom": 1230,
|
|
111
|
+
"height": 17,
|
|
112
|
+
"top": 1213,
|
|
113
|
+
"width": 319.40625,
|
|
114
|
+
"font": "RedNum, RedZh, RedEn, -apple-system"
|
|
115
|
+
},
|
|
116
|
+
"x79": "32851|10737451091",
|
|
117
|
+
"x80": "1|[object FileSystemDirectoryHandle]",
|
|
118
|
+
"x82": "_AUuXfEG27Xa3x|CUSTOMER_SSO_LOGIN_GLOBAL_EMITTER|anti_hp_sign_config|__rap_app_id__|__rap_report__|__rap_last_sign_cost__|__rap_last_transform_cost__|__rap_hijack_installed__|__setVerifyMsgBase64__|_BHjFmfUMEtxhI|anti__hp__|__hp_creator_tab_state__|__SW_AB_GROUP__|MicroappMountContainer|spamTimer",
|
|
119
|
+
"x83": "eyJkIjp7IjAiOjEzMiwiMSI6MTYyLCIyIjoxMDksIjMiOjExNiwiNCI6MTI5LCI1IjoxNjIsIjYiOjExNiwiNyI6MTExLCI4IjoyMDMsIjkiOjY2LCIxMCI6MTIxLCIxMSI6MjQ3LCIxMiI6MTAyLCIxMyI6MTQyLCIxNCI6MjM2LCIxNSI6MjMyLCIxNiI6MCwiMTciOjE2MSwiMTgiOjEwOSwiMTkiOjEyOCwiMjAiOjE2MSwiMjEiOjEwNywiMjIiOjEyOCwiMjMiOjE2MSwiMjQiOjExMiwiMjUiOjEzMCwiMjYiOjE2MywiMjciOjExNywiMjgiOjEwOCwiMjkiOjExNCwiMzAiOjE0NSwiMzEiOjE0NiwiMzIiOjIwMywiMzMiOjY2LCIzNCI6MTIxLCIzNSI6MjQ3LCIzNiI6MTAyLCIzNyI6NSwiMzgiOjEzLCIzOSI6MjMwLCI0MCI6MTAyLCI0MSI6MjA2LCI0MiI6MCwiNDMiOjgsIjQ0IjoxNTcsIjQ1IjoyMzksIjQ2IjoxNjIsIjQ3IjoxMTIsIjQ4IjoxMTUsIjQ5IjoxNDUsIjUwIjoxMzEsIjUxIjoxNjIsIjUyIjoxMTYsIjUzIjoxMTUsIjU0IjoyMDUsIjU1IjozLCI1NiI6NDAsIjU3IjoxNjEsIjU4IjoxMDQsIjU5IjoxOTQsIjYwIjoxNjEsIjYxIjoxMDIsIjYyIjoxOTV9LCJ2IjoxLCJlIjoibSJ9",
|
|
120
|
+
"x84": "__TELEMETRY__"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"b1Reference": {
|
|
124
|
+
"frameCount": 2,
|
|
125
|
+
"x39": 16,
|
|
126
|
+
"x50": "",
|
|
127
|
+
"x51": "",
|
|
128
|
+
"generatedAtOffsetMs": 1895,
|
|
129
|
+
"secCanvas": "__SEC_CAV__1-1-1-1-1|__SEC_UD__|",
|
|
130
|
+
"timeOriginOffsetMs": -870.4,
|
|
131
|
+
"x37": "0|0|0|0|0|0|0|0|0|1|0|0|1|0|0|0|0|1|1|0|0|0|0|0",
|
|
132
|
+
"x38": "0|0|1|0|1|0|0|0|0|0|1|0|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0",
|
|
133
|
+
"selectedGlobalNames": [
|
|
134
|
+
"_AUuXfEG27Xa3x",
|
|
135
|
+
"CUSTOMER_SSO_LOGIN_GLOBAL_EMITTER",
|
|
136
|
+
"anti_hp_sign_config",
|
|
137
|
+
"__rap_app_id__",
|
|
138
|
+
"__rap_report__",
|
|
139
|
+
"__rap_last_sign_cost__",
|
|
140
|
+
"__rap_last_transform_cost__",
|
|
141
|
+
"__rap_hijack_installed__",
|
|
142
|
+
"_BHjFmfUMEtxhI",
|
|
143
|
+
"__USE_CUSTOM_TIMING__",
|
|
144
|
+
"__CUSTOM_FMP_ELEMENTS__",
|
|
145
|
+
"__COLLECTED_FMP_ELEMENTS__",
|
|
146
|
+
"__CUSTOM_TTI_ELEMENTS__",
|
|
147
|
+
"__setVerifyMsgBase64__"
|
|
148
|
+
],
|
|
149
|
+
"page": {"ulr": 5, "rs": 1, "ps": 1},
|
|
150
|
+
"state": {"h": 0, "f": 1, "kr": 0},
|
|
151
|
+
"features": {"ae": null, "ak": null, "cdr": null, "bf": null, "fi": null},
|
|
152
|
+
"evidence": "Fresh authenticated Creator publish page b1 decoded on Chrome 152, 2026-09-07"
|
|
153
|
+
},
|
|
154
|
+
"b1Profiles": {
|
|
155
|
+
"note_manager": {
|
|
156
|
+
"frameCount": 6,
|
|
157
|
+
"x39": 22,
|
|
158
|
+
"x50": "",
|
|
159
|
+
"x51": "",
|
|
160
|
+
"x37": "0|0|0|0|0|0|0|0|0|1|0|0|1|0|0|0|0|1|1|0|0|0|0|0",
|
|
161
|
+
"generatedAtOffsetMs": -5816,
|
|
162
|
+
"timeOriginOffsetMs": -357490.2,
|
|
163
|
+
"selectedGlobalNames": [
|
|
164
|
+
"_AUuXfEG27Xa3x",
|
|
165
|
+
"CUSTOMER_SSO_LOGIN_GLOBAL_EMITTER",
|
|
166
|
+
"anti_hp_sign_config",
|
|
167
|
+
"__rap_app_id__",
|
|
168
|
+
"__rap_report__",
|
|
169
|
+
"__rap_last_sign_cost__",
|
|
170
|
+
"__rap_last_transform_cost__",
|
|
171
|
+
"__rap_hijack_installed__",
|
|
172
|
+
"_BHjFmfUMEtxhI",
|
|
173
|
+
"__setVerifyMsgBase64__",
|
|
174
|
+
"anti__hp__",
|
|
175
|
+
"__hp_creator_tab_state__",
|
|
176
|
+
"__SW_AB_GROUP__",
|
|
177
|
+
"MicroappMountContainer",
|
|
178
|
+
"spamTimer"
|
|
179
|
+
],
|
|
180
|
+
"mouse": {"me": 14, "mm": 28},
|
|
181
|
+
"keyboard": {},
|
|
182
|
+
"page": {"ulr": 5, "ps": 1},
|
|
183
|
+
"state": {"h": 0, "f": 1, "kr": 0},
|
|
184
|
+
"features": {
|
|
185
|
+
"ae": 2.5875282962354187,
|
|
186
|
+
"ak": 6.255902207830465,
|
|
187
|
+
"cdr": null,
|
|
188
|
+
"bf": {"ar": 0.42814667988107036, "fr": 4.885235736344873},
|
|
189
|
+
"fi": 6438.29999999702
|
|
190
|
+
},
|
|
191
|
+
"evidence": "Fresh post-login Creator note-manager req1155 decoded on 2026-07-19"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"mnsStages": {
|
|
195
|
+
"bootstrap": {
|
|
196
|
+
"tier": "0201",
|
|
197
|
+
"deviceTag": "nop",
|
|
198
|
+
"envConst": 1306,
|
|
199
|
+
"envFpTailHex": "f8536767c9b581635e0744fa8415",
|
|
200
|
+
"evidence": "Fresh Creator login page11 DS request seq=1 decoded on 2026-07-19"
|
|
201
|
+
},
|
|
202
|
+
"ready": {
|
|
203
|
+
"tier": "0101",
|
|
204
|
+
"deviceTag": "a1",
|
|
205
|
+
"envConst": 1341,
|
|
206
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
207
|
+
"evidence": "Fresh Creator login page11 steady webprofile/QR-ready state"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"mnsProfiles": {
|
|
211
|
+
"login_early": {
|
|
212
|
+
"tier": "0101",
|
|
213
|
+
"deviceTag": "a1",
|
|
214
|
+
"envConst": 1325,
|
|
215
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
216
|
+
"evidence": "Creator page11 redcaptcha/sbtsource/zones/tgt seq=2-5"
|
|
217
|
+
},
|
|
218
|
+
"login_callback": {
|
|
219
|
+
"tier": "0101",
|
|
220
|
+
"deviceTag": "a1",
|
|
221
|
+
"envConst": 1327,
|
|
222
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
223
|
+
"evidence": "Creator page11 seccallback seq=6"
|
|
224
|
+
},
|
|
225
|
+
"login_ready": {
|
|
226
|
+
"tier": "0101",
|
|
227
|
+
"deviceTag": "a1",
|
|
228
|
+
"envConst": 1350,
|
|
229
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
230
|
+
"evidence": "Creator page11 webprofile seq=7 and steady login requests"
|
|
231
|
+
},
|
|
232
|
+
"publish_user_info": {
|
|
233
|
+
"tier": "0101",
|
|
234
|
+
"deviceTag": "a1",
|
|
235
|
+
"envConst": 1337,
|
|
236
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
237
|
+
"evidence": "Authenticated Creator publish navigation user/info, Chrome 152, 2026-09-07"
|
|
238
|
+
},
|
|
239
|
+
"note_manager": {
|
|
240
|
+
"tier": "0101",
|
|
241
|
+
"deviceTag": "a1",
|
|
242
|
+
"envConst": 1339,
|
|
243
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
244
|
+
"evidence": "Authenticated Creator note-manager request, Chrome 152, 2026-09-06"
|
|
245
|
+
},
|
|
246
|
+
"note_manager_steady": {
|
|
247
|
+
"tier": "0101",
|
|
248
|
+
"deviceTag": "a1",
|
|
249
|
+
"envConst": 1339,
|
|
250
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
251
|
+
"evidence": "Authenticated Creator note-manager subsequent request, Chrome 152, 2026-09-06"
|
|
252
|
+
},
|
|
253
|
+
"publish_mountable": {
|
|
254
|
+
"tier": "0101",
|
|
255
|
+
"deviceTag": "a1",
|
|
256
|
+
"envConst": 1341,
|
|
257
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
258
|
+
"evidence": "Authenticated Creator publish mountable APIs, Chrome 152, 2026-09-06"
|
|
259
|
+
},
|
|
260
|
+
"publish_permit": {
|
|
261
|
+
"tier": "0101",
|
|
262
|
+
"deviceTag": "a1",
|
|
263
|
+
"envConst": 1349,
|
|
264
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
265
|
+
"evidence": "Authenticated Creator image upload permit req110, Chrome 152, 2026-09-07"
|
|
266
|
+
},
|
|
267
|
+
"publish_permit_image": {
|
|
268
|
+
"tier": "0101",
|
|
269
|
+
"deviceTag": "a1",
|
|
270
|
+
"envConst": 1349,
|
|
271
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
272
|
+
"evidence": "Authenticated Creator scene=image upload permit req110, Chrome 152, 2026-09-07"
|
|
273
|
+
},
|
|
274
|
+
"publish_permit_video": {
|
|
275
|
+
"tier": "0101",
|
|
276
|
+
"deviceTag": "a1",
|
|
277
|
+
"envConst": 1349,
|
|
278
|
+
"envFpTailHex": "f9536767c9b581635e0744fa8415",
|
|
279
|
+
"evidence": "Authenticated Creator scene=video upload permit req98, Chrome 152, 2026-09-07"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
|
|
5
|
+
function dec2hex(value, width) {
|
|
6
|
+
let result = '';
|
|
7
|
+
for (let number = value; number;) {
|
|
8
|
+
const digit = 15 & number;
|
|
9
|
+
result = String.fromCharCode((digit > 9 ? 55 : 48) + digit) + result;
|
|
10
|
+
number >>= 4;
|
|
11
|
+
}
|
|
12
|
+
if (width) {
|
|
13
|
+
while (result.length < width) result = `0${result}`;
|
|
14
|
+
}
|
|
15
|
+
return result.toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function urlSing(value, timestampMs) {
|
|
19
|
+
const now = timestampMs == null ? Date.now() : Number(timestampMs);
|
|
20
|
+
const secondsHex = dec2hex(now / 1000);
|
|
21
|
+
return crypto
|
|
22
|
+
.createHash('md5')
|
|
23
|
+
.update(`hIJXulBFYcGRQjrz${value}${secondsHex}`)
|
|
24
|
+
.digest('hex');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (typeof module !== 'undefined') {
|
|
28
|
+
module.exports = { dec2hex, urlSing };
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const CryptoJS = require('crypto-js');
|
|
2
|
+
|
|
3
|
+
function getSignature(message, fileId, contentLength, host) {
|
|
4
|
+
host = host || 'ros-upload.xiaohongshu.com';
|
|
5
|
+
let key = 'null'
|
|
6
|
+
let hash = CryptoJS.HmacSHA1(message, key);
|
|
7
|
+
key = CryptoJS.enc.Hex.stringify(hash);
|
|
8
|
+
let new_message = "put\n" +
|
|
9
|
+
`/spectrum/${fileId}\n` +
|
|
10
|
+
"\n" +
|
|
11
|
+
`content-length=${contentLength}&host=${host}\n`;
|
|
12
|
+
let params = CryptoJS.SHA1(new_message).toString()
|
|
13
|
+
message = "sha1\n" +
|
|
14
|
+
`${message}\n` +
|
|
15
|
+
`${params}\n`;
|
|
16
|
+
hash = CryptoJS.HmacSHA1(message, key);
|
|
17
|
+
return CryptoJS.enc.Hex.stringify(hash);
|
|
18
|
+
}
|
|
19
|
+
// let message = "1709905283;1709912483"
|
|
20
|
+
// let fileId = 'UcaECZ-40xa7Uir1V8msV4XAq3bF6E8m16IT5eoR6Z12spg'
|
|
21
|
+
// let contentLength = 13975
|
|
22
|
+
// console.log(getSignature(message, fileId, contentLength))
|
|
23
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// AES-128 decrypt with custom S-box (standard InvMixColumns/InvShiftRows)
|
|
3
|
+
const { keyExpand } = require('./aes_encrypt.js');
|
|
4
|
+
function mul(a, b) { let r = 0; for (let i = 0; i < 8; i++) { if (b & 1) r ^= a; const hi = a & 0x80; a = (a << 1) & 0xff; if (hi) a ^= 0x1b; b >>= 1; } return r; }
|
|
5
|
+
function invSboxOf(sbox) { const inv = new Array(256); for (let i = 0; i < 256; i++) inv[sbox[i]] = i; return inv; }
|
|
6
|
+
function aesDecBlock(ct, key, sbox) {
|
|
7
|
+
const inv = invSboxOf(sbox); const Nr = 10; const w = keyExpand(key, sbox);
|
|
8
|
+
const s = new Array(16);
|
|
9
|
+
for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) s[r * 4 + c] = ct[c * 4 + r];
|
|
10
|
+
function addRK(round) { for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) s[r * 4 + c] ^= w[round * 4 + c][r]; }
|
|
11
|
+
addRK(Nr);
|
|
12
|
+
for (let round = Nr - 1; round >= 0; round--) {
|
|
13
|
+
// InvShiftRows
|
|
14
|
+
const t = s.slice(); for (let r = 1; r < 4; r++) for (let c = 0; c < 4; c++) s[r * 4 + c] = t[r * 4 + ((c - r + 4) % 4)];
|
|
15
|
+
for (let i = 0; i < 16; i++) s[i] = inv[s[i]];
|
|
16
|
+
addRK(round);
|
|
17
|
+
if (round > 0) { const o = s.slice(); for (let c = 0; c < 4; c++) { const a0 = o[c], a1 = o[4 + c], a2 = o[8 + c], a3 = o[12 + c]; s[c] = mul(a0, 14) ^ mul(a1, 11) ^ mul(a2, 13) ^ mul(a3, 9); s[4 + c] = mul(a0, 9) ^ mul(a1, 14) ^ mul(a2, 11) ^ mul(a3, 13); s[8 + c] = mul(a0, 13) ^ mul(a1, 9) ^ mul(a2, 14) ^ mul(a3, 11); s[12 + c] = mul(a0, 11) ^ mul(a1, 13) ^ mul(a2, 9) ^ mul(a3, 14); } }
|
|
18
|
+
}
|
|
19
|
+
const out = new Array(16); for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) out[c * 4 + r] = s[r * 4 + c];
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
module.exports = { aesDecBlock, invSboxOf };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// AES-128 single-block encrypt with swappable S-box (standard MixColumns/ShiftRows/Rcon)
|
|
3
|
+
function mul(a, b) { let r = 0; for (let i = 0; i < 8; i++) { if (b & 1) r ^= a; const hi = a & 0x80; a = (a << 1) & 0xff; if (hi) a ^= 0x1b; b >>= 1; } return r; }
|
|
4
|
+
function keyExpand(key, sbox) {
|
|
5
|
+
const Nk = 4, Nr = 10; const w = [];
|
|
6
|
+
for (let i = 0; i < Nk; i++) w[i] = [key[4 * i], key[4 * i + 1], key[4 * i + 2], key[4 * i + 3]];
|
|
7
|
+
const rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
|
8
|
+
for (let i = Nk; i < 4 * (Nr + 1); i++) {
|
|
9
|
+
let t = w[i - 1].slice();
|
|
10
|
+
if (i % Nk === 0) { t = [t[1], t[2], t[3], t[0]].map((x) => sbox[x]); t[0] ^= rcon[i / Nk - 1]; }
|
|
11
|
+
w[i] = w[i - Nk].map((x, j) => x ^ t[j]);
|
|
12
|
+
}
|
|
13
|
+
return w;
|
|
14
|
+
}
|
|
15
|
+
function aesEncBlock(pt, key, sbox) {
|
|
16
|
+
const Nr = 10; const w = keyExpand(key, sbox);
|
|
17
|
+
const s = new Array(16);
|
|
18
|
+
for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) s[r * 4 + c] = pt[c * 4 + r];
|
|
19
|
+
function addRK(round) { for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) s[r * 4 + c] ^= w[round * 4 + c][r]; }
|
|
20
|
+
addRK(0);
|
|
21
|
+
for (let round = 1; round <= Nr; round++) {
|
|
22
|
+
for (let i = 0; i < 16; i++) s[i] = sbox[s[i]];
|
|
23
|
+
const t = s.slice(); for (let r = 1; r < 4; r++) for (let c = 0; c < 4; c++) s[r * 4 + c] = t[r * 4 + ((c + r) % 4)];
|
|
24
|
+
if (round < Nr) { const o = s.slice(); for (let c = 0; c < 4; c++) { const a0 = o[c], a1 = o[4 + c], a2 = o[8 + c], a3 = o[12 + c]; s[c] = mul(a0, 2) ^ mul(a1, 3) ^ a2 ^ a3; s[4 + c] = a0 ^ mul(a1, 2) ^ mul(a2, 3) ^ a3; s[8 + c] = a0 ^ a1 ^ mul(a2, 2) ^ mul(a3, 3); s[12 + c] = mul(a0, 3) ^ a1 ^ a2 ^ mul(a3, 2); } }
|
|
25
|
+
addRK(round);
|
|
26
|
+
}
|
|
27
|
+
const out = new Array(16); for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) out[c * 4 + r] = s[r * 4 + c];
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
module.exports = { aesEncBlock, mul, keyExpand };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Compatibility entry point for callers that historically invoked the PC
|
|
4
|
+
// path directly. The maintained implementation lives in xhs_core/js/b1.js;
|
|
5
|
+
// forwarding argv/stdin keeps the CLI contract identical without duplicating
|
|
6
|
+
// the algorithm.
|
|
7
|
+
const impl = require('../../xhs_core/js/b1.js');
|
|
8
|
+
if (require.main === module) impl.main();
|
|
9
|
+
module.exports = impl;
|