@ikenxuan/amagi 1.5.3 → 1.5.5
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/README.md +6 -3
- package/lib/business/douyin/getdata.js +15 -22
- package/lib/business/douyin/sign/a_bogus.d.ts +2 -0
- package/lib/business/douyin/sign/a_bogus.js +462 -0
- package/lib/business/douyin/sign/index.d.ts +1 -1
- package/lib/business/douyin/sign/index.js +3 -4
- package/lib/model/networks.js +5 -1
- package/lib/types/BilibiliAPIParams.d.ts +1 -1
- package/package.json +2 -2
- package/lib/business/douyin/sign/a_bougs.d.ts +0 -3
- package/lib/business/douyin/sign/a_bougs.js +0 -487
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 使用
|
|
8
8
|
```
|
|
9
|
-
|
|
9
|
+
pnpm add @ikenxuan/amagi
|
|
10
10
|
```
|
|
11
11
|
## 快速上手
|
|
12
12
|
```js
|
|
@@ -22,8 +22,8 @@ const client = await new amagi({
|
|
|
22
22
|
await StartClient(client, { port: 4567 })
|
|
23
23
|
```
|
|
24
24
|
## 开发构建
|
|
25
|
-
> Node.js
|
|
26
|
-
|
|
25
|
+
> Node.js版本 <= v18.20.4
|
|
26
|
+
|
|
27
27
|
* 克隆仓库
|
|
28
28
|
```
|
|
29
29
|
git clone git@github.com:ikenxuan/amagi.git
|
|
@@ -37,6 +37,9 @@ pnpm install
|
|
|
37
37
|
pnpm build
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
## License
|
|
41
|
+
[GPL-3.0](https://github.com/ikenxuan/amagi/blob/main/LICENSE)
|
|
42
|
+
|
|
40
43
|
## 声明
|
|
41
44
|
该项目代码从 [kkkkkk-10086](https://github.com/ikenxuan/kkkkkk-10086) 提取修改并发布
|
|
42
45
|
|
|
@@ -7,20 +7,12 @@ export default class DouyinData {
|
|
|
7
7
|
constructor(type, cookie) {
|
|
8
8
|
this.type = type;
|
|
9
9
|
this.headers = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Priority: 'u=1, i',
|
|
14
|
-
'Sec-Ch-Ua': '"Not/A)Brand";v="8", "Chromium";v="125", "Microsoft Edge";v="125"',
|
|
15
|
-
'Sec-Ch-Ua-Mobile': '?0',
|
|
16
|
-
'Sec-Ch-Ua-Platform': '"Windows"',
|
|
17
|
-
'Sec-Fetch-Dest': 'empty',
|
|
18
|
-
'Sec-Fetch-Mode': 'cors',
|
|
19
|
-
'Sec-Fetch-Site': 'same-site',
|
|
20
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
|
|
10
|
+
Referer: 'https://www.douyin.com/',
|
|
11
|
+
Cookie: cookie,
|
|
12
|
+
Accept: '*/*',
|
|
21
13
|
'Content-Type': 'application/json',
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
'Accpet-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
15
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0'
|
|
24
16
|
};
|
|
25
17
|
}
|
|
26
18
|
async GetData(data = {}) {
|
|
@@ -29,28 +21,29 @@ export default class DouyinData {
|
|
|
29
21
|
case 'NoteData':
|
|
30
22
|
this.URL = DouyinAPI.视频或图集({ aweme_id: data.aweme_id });
|
|
31
23
|
const VideoData = await this.GlobalGetData({
|
|
32
|
-
url: `${this.URL}&
|
|
24
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
25
|
+
method: 'GET',
|
|
33
26
|
headers: this.headers,
|
|
34
27
|
});
|
|
35
28
|
return VideoData;
|
|
36
29
|
case 'CommentData':
|
|
37
30
|
this.URL = DouyinAPI.评论({ aweme_id: data.aweme_id });
|
|
38
31
|
const CommentsData = await this.GlobalGetData({
|
|
39
|
-
url: `${this.URL}&
|
|
32
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
40
33
|
headers: this.headers,
|
|
41
34
|
});
|
|
42
35
|
return CommentsData;
|
|
43
36
|
case 'CommentReplyData':
|
|
44
37
|
this.URL = DouyinAPI.二级评论({ aweme_id: data.aweme_id, comment_id: data.comment_id });
|
|
45
38
|
const CommentReplyData = await this.GlobalGetData({
|
|
46
|
-
url: `${this.URL}&
|
|
39
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
47
40
|
headers: this.headers,
|
|
48
41
|
});
|
|
49
42
|
return CommentReplyData;
|
|
50
43
|
case 'UserInfoData':
|
|
51
44
|
this.URL = DouyinAPI.用户主页信息({ sec_uid: data.sec_uid });
|
|
52
45
|
const UserInfoData = await this.GlobalGetData({
|
|
53
|
-
url: `${this.URL}&
|
|
46
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
54
47
|
headers: {
|
|
55
48
|
...this.headers,
|
|
56
49
|
Referer: `https://www.douyin.com/user/${data.sec_uid}`,
|
|
@@ -67,7 +60,7 @@ export default class DouyinData {
|
|
|
67
60
|
case 'UserVideosListData':
|
|
68
61
|
this.URL = DouyinAPI.用户主页视频({ sec_uid: data.sec_uid });
|
|
69
62
|
const UserVideoListData = await this.GlobalGetData({
|
|
70
|
-
url: `${this.URL}&
|
|
63
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
71
64
|
headers: {
|
|
72
65
|
...this.headers,
|
|
73
66
|
Referer: `https://www.douyin.com/user/${data.sec_uid}`,
|
|
@@ -77,7 +70,7 @@ export default class DouyinData {
|
|
|
77
70
|
case 'SuggestWordsData':
|
|
78
71
|
this.URL = DouyinAPI.热点词({ query: data.query });
|
|
79
72
|
const SuggestWordsData = await this.GlobalGetData({
|
|
80
|
-
url: `${this.URL}&
|
|
73
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
81
74
|
headers: {
|
|
82
75
|
...this.headers,
|
|
83
76
|
Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`,
|
|
@@ -87,7 +80,7 @@ export default class DouyinData {
|
|
|
87
80
|
case 'SearchData':
|
|
88
81
|
this.URL = DouyinAPI.搜索({ query: data.query });
|
|
89
82
|
const SearchData = await this.GlobalGetData({
|
|
90
|
-
url: `${this.URL}&
|
|
83
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
91
84
|
headers: {
|
|
92
85
|
...this.headers,
|
|
93
86
|
Referer: `https://www.douyin.com/https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`,
|
|
@@ -97,14 +90,14 @@ export default class DouyinData {
|
|
|
97
90
|
case 'ExpressionPlusData':
|
|
98
91
|
this.URL = DouyinAPI.互动表情();
|
|
99
92
|
const ExpressionPlusData = await this.GlobalGetData({
|
|
100
|
-
url: `${this.URL}&
|
|
93
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
101
94
|
headers: this.headers,
|
|
102
95
|
});
|
|
103
96
|
return ExpressionPlusData;
|
|
104
97
|
case 'MusicData':
|
|
105
98
|
this.URL = DouyinAPI.背景音乐({ music_id: data.music_id });
|
|
106
99
|
const MusicData = await this.GlobalGetData({
|
|
107
|
-
url: `${this.URL}&
|
|
100
|
+
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
108
101
|
headers: this.headers,
|
|
109
102
|
});
|
|
110
103
|
return MusicData;
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
// All the content in this article is only for learning and communication use, not for any other purpose, strictly prohibited for commercial use and illegal use, otherwise all the consequences are irrelevant to the author!
|
|
2
|
+
class SM3 {
|
|
3
|
+
reg;
|
|
4
|
+
chunk;
|
|
5
|
+
size;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.reg = [];
|
|
8
|
+
this.chunk = [];
|
|
9
|
+
this.size = 0;
|
|
10
|
+
this.reset();
|
|
11
|
+
}
|
|
12
|
+
reset() {
|
|
13
|
+
this.reg[0] = 1937774191;
|
|
14
|
+
this.reg[1] = 1226093241;
|
|
15
|
+
this.reg[2] = 388252375;
|
|
16
|
+
this.reg[3] = 3666478592;
|
|
17
|
+
this.reg[4] = 2842636476;
|
|
18
|
+
this.reg[5] = 372324522;
|
|
19
|
+
this.reg[6] = 3817729613;
|
|
20
|
+
this.reg[7] = 2969243214;
|
|
21
|
+
this.chunk = [];
|
|
22
|
+
this.size = 0;
|
|
23
|
+
}
|
|
24
|
+
write(e) {
|
|
25
|
+
const a = typeof e === 'string' ? this.stringToBytes(e) : e;
|
|
26
|
+
this.size += a.length;
|
|
27
|
+
let f = 64 - this.chunk.length;
|
|
28
|
+
if (a.length < f) {
|
|
29
|
+
this.chunk = this.chunk.concat(a);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.chunk = this.chunk.concat(a.slice(0, f));
|
|
33
|
+
while (this.chunk.length >= 64) {
|
|
34
|
+
this._compress(this.chunk);
|
|
35
|
+
f < a.length ? this.chunk = a.slice(f, Math.min(f + 64, a.length)) : this.chunk = [];
|
|
36
|
+
f += 64;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
sum(e, t) {
|
|
41
|
+
if (e) {
|
|
42
|
+
this.reset();
|
|
43
|
+
this.write(e);
|
|
44
|
+
}
|
|
45
|
+
this._fill();
|
|
46
|
+
for (let f = 0; f < this.chunk.length; f += 64) {
|
|
47
|
+
this._compress(this.chunk.slice(f, f + 64));
|
|
48
|
+
}
|
|
49
|
+
let i = null;
|
|
50
|
+
if (t === 'hex') {
|
|
51
|
+
i = '';
|
|
52
|
+
for (let f = 0; f < 8; f++) {
|
|
53
|
+
i += this.padHex(this.reg[f].toString(16), 8);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
i = new Array(32);
|
|
58
|
+
for (let f = 0; f < 8; f++) {
|
|
59
|
+
let c = this.reg[f];
|
|
60
|
+
i[4 * f + 3] = (255 & c) >>> 0;
|
|
61
|
+
c >>>= 8;
|
|
62
|
+
i[4 * f + 2] = (255 & c) >>> 0;
|
|
63
|
+
c >>>= 8;
|
|
64
|
+
i[4 * f + 1] = (255 & c) >>> 0;
|
|
65
|
+
c >>>= 8;
|
|
66
|
+
i[4 * f] = (255 & c) >>> 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this.reset();
|
|
70
|
+
return i;
|
|
71
|
+
}
|
|
72
|
+
_compress(t) {
|
|
73
|
+
if (t.length < 64) {
|
|
74
|
+
console.error("compress error: not enough data");
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (var f = ((e) => {
|
|
78
|
+
for (var r = new Array(132), t = 0; t < 16; t++) {
|
|
79
|
+
(r[t] = e[4 * t] << 24), (r[t] |= e[4 * t + 1] << 16), (r[t] |= e[4 * t + 2] << 8), (r[t] |= e[4 * t + 3]), (r[t] >>>= 0);
|
|
80
|
+
}
|
|
81
|
+
for (var n = 16; n < 68; n++) {
|
|
82
|
+
let a = r[n - 16] ^ r[n - 9] ^ this.le(r[n - 3], 15);
|
|
83
|
+
(a = a ^ this.le(a, 15) ^ this.le(a, 23)), (r[n] = (a ^ this.le(r[n - 13], 7) ^ r[n - 6]) >>> 0);
|
|
84
|
+
}
|
|
85
|
+
for (n = 0; n < 64; n++)
|
|
86
|
+
r[n + 68] = (r[n] ^ r[n + 4]) >>> 0;
|
|
87
|
+
return r;
|
|
88
|
+
})(t), i = this.reg.slice(0), c = 0; c < 64; c++) {
|
|
89
|
+
let o = this.le(i[0], 12) + i[4] + this.le(this.de(c), c);
|
|
90
|
+
const s = ((o = this.le((o = (4294967295 & o) >>> 0), 7)) ^ this.le(i[0], 12)) >>> 0;
|
|
91
|
+
let u = this.pe(c, i[0], i[1], i[2]);
|
|
92
|
+
u = (4294967295 & (u = u + i[3] + s + f[c + 68])) >>> 0;
|
|
93
|
+
let b = this.he(c, i[4], i[5], i[6]);
|
|
94
|
+
(b = (4294967295 & (b = b + i[7] + o + f[c])) >>> 0),
|
|
95
|
+
(i[3] = i[2]),
|
|
96
|
+
(i[2] = this.le(i[1], 9)),
|
|
97
|
+
(i[1] = i[0]),
|
|
98
|
+
(i[0] = u),
|
|
99
|
+
(i[7] = i[6]),
|
|
100
|
+
(i[6] = this.le(i[5], 19)),
|
|
101
|
+
(i[5] = i[4]),
|
|
102
|
+
(i[4] = (b ^ this.le(b, 9) ^ this.le(b, 17)) >>> 0);
|
|
103
|
+
}
|
|
104
|
+
for (let l = 0; l < 8; l++)
|
|
105
|
+
this.reg[l] = (this.reg[l] ^ i[l]) >>> 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_fill() {
|
|
109
|
+
let a = 8 * this.size;
|
|
110
|
+
let f = this.chunk.push(128) % 64;
|
|
111
|
+
while (64 - f < 8) {
|
|
112
|
+
f -= 64;
|
|
113
|
+
}
|
|
114
|
+
while (f < 56) {
|
|
115
|
+
this.chunk.push(0);
|
|
116
|
+
f++;
|
|
117
|
+
}
|
|
118
|
+
for (let i = 0; i < 4; i++) {
|
|
119
|
+
const c = Math.floor(a / 0x100000000);
|
|
120
|
+
this.chunk.push((c >>> (8 * (3 - i))) & 255);
|
|
121
|
+
}
|
|
122
|
+
for (let i = 0; i < 4; i++) {
|
|
123
|
+
this.chunk.push((a >>> (8 * (3 - i))) & 255);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
de(e) {
|
|
127
|
+
return 0 <= e && e < 16 ? 2043430169 : 16 <= e && e < 64 ? 2055708042 : (console.error("invalid j for constant Tj"), 0);
|
|
128
|
+
}
|
|
129
|
+
pe(e, r, t, n) {
|
|
130
|
+
return 0 <= e && e < 16 ? (r ^ t ^ n) >>> 0 : 16 <= e && e < 64 ? (r & t | r & n | t & n) >>> 0 : (console.error('invalid j for bool function FF'), 0);
|
|
131
|
+
}
|
|
132
|
+
he(e, r, t, n) {
|
|
133
|
+
return 0 <= e && e < 16 ? (r ^ t ^ n) >>> 0 : 16 <= e && e < 64 ? (r & t | ~r & n) >>> 0 : (console.error('invalid j for bool function GG'), 0);
|
|
134
|
+
}
|
|
135
|
+
le(e, r) {
|
|
136
|
+
return (e << (r %= 32) | e >>> 32 - r) >>> 0;
|
|
137
|
+
}
|
|
138
|
+
stringToBytes(str) {
|
|
139
|
+
const n = encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, r) => String.fromCharCode(parseInt(r, 16)));
|
|
140
|
+
const a = new Array(n.length);
|
|
141
|
+
for (let i = 0; i < n.length; i++) {
|
|
142
|
+
a[i] = n.charCodeAt(i);
|
|
143
|
+
}
|
|
144
|
+
return a;
|
|
145
|
+
}
|
|
146
|
+
padHex(num, size) {
|
|
147
|
+
return num.padStart(size, '0');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function rc4_encrypt(plaintext, key) {
|
|
151
|
+
const s = [];
|
|
152
|
+
for (var i = 0; i < 256; i++) {
|
|
153
|
+
s[i] = i;
|
|
154
|
+
}
|
|
155
|
+
var j = 0;
|
|
156
|
+
for (var i = 0; i < 256; i++) {
|
|
157
|
+
j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;
|
|
158
|
+
var temp = s[i];
|
|
159
|
+
s[i] = s[j];
|
|
160
|
+
s[j] = temp;
|
|
161
|
+
}
|
|
162
|
+
var i = 0;
|
|
163
|
+
var j = 0;
|
|
164
|
+
const cipher = [];
|
|
165
|
+
for (let k = 0; k < plaintext.length; k++) {
|
|
166
|
+
i = (i + 1) % 256;
|
|
167
|
+
j = (j + s[i]) % 256;
|
|
168
|
+
var temp = s[i];
|
|
169
|
+
s[i] = s[j];
|
|
170
|
+
s[j] = temp;
|
|
171
|
+
const t = (s[i] + s[j]) % 256;
|
|
172
|
+
cipher.push(String.fromCharCode(s[t] ^ plaintext.charCodeAt(k)));
|
|
173
|
+
}
|
|
174
|
+
return cipher.join('');
|
|
175
|
+
}
|
|
176
|
+
function result_encrypt(long_str, num) {
|
|
177
|
+
const s_obj = {
|
|
178
|
+
s0: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
179
|
+
s1: 'Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=',
|
|
180
|
+
s2: 'Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=',
|
|
181
|
+
s3: 'ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe',
|
|
182
|
+
s4: 'Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe'
|
|
183
|
+
};
|
|
184
|
+
const constant = {
|
|
185
|
+
"0": 16515072,
|
|
186
|
+
"1": 258048,
|
|
187
|
+
"2": 4032,
|
|
188
|
+
"str": s_obj[num],
|
|
189
|
+
};
|
|
190
|
+
let result = "";
|
|
191
|
+
let lound = 0;
|
|
192
|
+
let long_int = get_long_int(lound, long_str);
|
|
193
|
+
for (let i = 0; i < long_str.length / 3 * 4; i++) {
|
|
194
|
+
if (Math.floor(i / 4) !== lound) {
|
|
195
|
+
lound += 1;
|
|
196
|
+
long_int = get_long_int(lound, long_str);
|
|
197
|
+
}
|
|
198
|
+
let key = i % 4;
|
|
199
|
+
let temp_int;
|
|
200
|
+
switch (key) {
|
|
201
|
+
case 0:
|
|
202
|
+
temp_int = (long_int & constant["0"]) >> 18;
|
|
203
|
+
result += constant["str"].charAt(temp_int);
|
|
204
|
+
break;
|
|
205
|
+
case 1:
|
|
206
|
+
temp_int = (long_int & constant["1"]) >> 12;
|
|
207
|
+
result += constant["str"].charAt(temp_int);
|
|
208
|
+
break;
|
|
209
|
+
case 2:
|
|
210
|
+
temp_int = (long_int & constant["2"]) >> 6;
|
|
211
|
+
result += constant["str"].charAt(temp_int);
|
|
212
|
+
break;
|
|
213
|
+
case 3:
|
|
214
|
+
temp_int = long_int & 63;
|
|
215
|
+
result += constant["str"].charAt(temp_int);
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
function get_long_int(round, long_str) {
|
|
224
|
+
round = round * 3;
|
|
225
|
+
return (long_str.charCodeAt(round) << 16) | (long_str.charCodeAt(round + 1) << 8) | long_str.charCodeAt(round + 2);
|
|
226
|
+
}
|
|
227
|
+
function gener_random(random, option) {
|
|
228
|
+
return [
|
|
229
|
+
(random & 255 & 170) | option[0] & 85, // 163
|
|
230
|
+
(random & 255 & 85) | option[0] & 170, //87
|
|
231
|
+
(random >> 8 & 255 & 170) | option[1] & 85, //37
|
|
232
|
+
(random >> 8 & 255 & 85) | option[1] & 170, //41
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
function generate_rc4_bb_str(url_search_params, user_agent, window_env_str, suffix = "cus", Arguments = [0, 1, 14]) {
|
|
236
|
+
let sm3 = new SM3();
|
|
237
|
+
let start_time = Date.now();
|
|
238
|
+
// url_search_params两次sm3之的结果
|
|
239
|
+
const url_search_params_list = sm3.sum(sm3.sum(url_search_params + suffix));
|
|
240
|
+
// 对后缀两次sm3之的结果
|
|
241
|
+
const cus = sm3.sum(sm3.sum(suffix));
|
|
242
|
+
// 对ua处理之后的结果
|
|
243
|
+
const ua = sm3.sum(result_encrypt(rc4_encrypt(user_agent, String.fromCharCode.apply(null, [0.00390625, 1, 14])), 's3'));
|
|
244
|
+
//
|
|
245
|
+
const end_time = Date.now();
|
|
246
|
+
// b object initialization
|
|
247
|
+
let b = {
|
|
248
|
+
8: 3, // 固定
|
|
249
|
+
10: end_time, // 3次加密结束时间
|
|
250
|
+
15: {
|
|
251
|
+
aid: 6383,
|
|
252
|
+
pageId: 6241,
|
|
253
|
+
boe: false,
|
|
254
|
+
ddrt: 7,
|
|
255
|
+
paths: {
|
|
256
|
+
include: [{}, {}, {}, {}, {}, {}, {}],
|
|
257
|
+
exclude: []
|
|
258
|
+
},
|
|
259
|
+
track: {
|
|
260
|
+
mode: 0,
|
|
261
|
+
delay: 300,
|
|
262
|
+
paths: []
|
|
263
|
+
},
|
|
264
|
+
dump: true,
|
|
265
|
+
rpU: ''
|
|
266
|
+
},
|
|
267
|
+
16: start_time, // 3次加密开始时间
|
|
268
|
+
18: 44, // 固定
|
|
269
|
+
19: [1, 0, 1, 5]
|
|
270
|
+
};
|
|
271
|
+
// 3次加密开始时间
|
|
272
|
+
b[20] = (b[16] >> 24) & 255;
|
|
273
|
+
b[21] = (b[16] >> 16) & 255;
|
|
274
|
+
b[22] = (b[16] >> 8) & 255;
|
|
275
|
+
b[23] = b[16] & 255;
|
|
276
|
+
b[24] = (b[16] / 256 / 256 / 256 / 256) >> 0;
|
|
277
|
+
b[25] = (b[16] / 256 / 256 / 256 / 256 / 256) >> 0;
|
|
278
|
+
// 参数Arguments [0, 1, 14, ...]
|
|
279
|
+
// let Arguments = [0, 1, 14]
|
|
280
|
+
b[26] = (Arguments[0] >> 24) & 255;
|
|
281
|
+
b[27] = (Arguments[0] >> 16) & 255;
|
|
282
|
+
b[28] = (Arguments[0] >> 8) & 255;
|
|
283
|
+
b[29] = Arguments[0] & 255;
|
|
284
|
+
b[30] = (Arguments[1] / 256) & 255;
|
|
285
|
+
b[31] = Arguments[1] % 256 & 255;
|
|
286
|
+
b[32] = (Arguments[1] >> 24) & 255;
|
|
287
|
+
b[33] = (Arguments[1] >> 16) & 255;
|
|
288
|
+
b[34] = (Arguments[2] >> 24) & 255;
|
|
289
|
+
b[35] = (Arguments[2] >> 16) & 255;
|
|
290
|
+
b[36] = (Arguments[2] >> 8) & 255;
|
|
291
|
+
b[37] = Arguments[2] & 255;
|
|
292
|
+
// (url_search_params + "cus") 两次sm3之的结果
|
|
293
|
+
/** let url_search_params_list = [
|
|
294
|
+
91, 186, 35, 86, 143, 253, 6, 76,
|
|
295
|
+
34, 21, 167, 148, 7, 42, 192, 219,
|
|
296
|
+
188, 20, 182, 85, 213, 74, 213, 147,
|
|
297
|
+
37, 155, 93, 139, 85, 118, 228, 213
|
|
298
|
+
] */
|
|
299
|
+
b[38] = url_search_params_list[21];
|
|
300
|
+
b[39] = url_search_params_list[22];
|
|
301
|
+
// ("cus") 对后缀两次sm3之的结果
|
|
302
|
+
/**
|
|
303
|
+
* let cus = [
|
|
304
|
+
136, 101, 114, 147, 58, 77, 207, 201,
|
|
305
|
+
215, 162, 154, 93, 248, 13, 142, 160,
|
|
306
|
+
105, 73, 215, 241, 83, 58, 51, 43,
|
|
307
|
+
255, 38, 168, 141, 216, 194, 35, 236
|
|
308
|
+
] */
|
|
309
|
+
b[40] = cus[21];
|
|
310
|
+
b[41] = cus[22];
|
|
311
|
+
// 对ua处理之后的结果
|
|
312
|
+
/**
|
|
313
|
+
* let ua = [
|
|
314
|
+
129, 190, 70, 186, 86, 196, 199, 53,
|
|
315
|
+
99, 38, 29, 209, 243, 17, 157, 69,
|
|
316
|
+
147, 104, 53, 23, 114, 126, 66, 228,
|
|
317
|
+
135, 30, 168, 185, 109, 156, 251, 88
|
|
318
|
+
] */
|
|
319
|
+
b[42] = ua[23];
|
|
320
|
+
b[43] = ua[24];
|
|
321
|
+
// 3次加密结束时间
|
|
322
|
+
b[44] = (b[10] >> 24) & 255;
|
|
323
|
+
b[45] = (b[10] >> 16) & 255;
|
|
324
|
+
b[46] = (b[10] >> 8) & 255;
|
|
325
|
+
b[47] = b[10] & 255;
|
|
326
|
+
b[48] = b[8];
|
|
327
|
+
b[49] = (b[10] / 256 / 256 / 256 / 256) >> 0;
|
|
328
|
+
b[50] = (b[10] / 256 / 256 / 256 / 256 / 256) >> 0;
|
|
329
|
+
// object配置项
|
|
330
|
+
b[51] = b[15].pageId;
|
|
331
|
+
b[52] = (b[15].pageId >> 24) & 255;
|
|
332
|
+
b[53] = (b[15].pageId >> 16) & 255;
|
|
333
|
+
b[54] = (b[15].pageId >> 8) & 255;
|
|
334
|
+
b[55] = b[15].pageId & 255;
|
|
335
|
+
b[56] = b[15].aid;
|
|
336
|
+
b[57] = b[15].aid & 255;
|
|
337
|
+
b[58] = (b[15].aid >> 8) & 255;
|
|
338
|
+
b[59] = (b[15].aid >> 16) & 255;
|
|
339
|
+
b[60] = (b[15].aid >> 24) & 255;
|
|
340
|
+
// 中间进行了环境检测
|
|
341
|
+
// 代码索引: 2496 索引值: 17 (索引64关键条件)
|
|
342
|
+
// '1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32'.charCodeAt()得到65位数组
|
|
343
|
+
/**
|
|
344
|
+
* let window_env_list = [49, 53, 51, 54, 124, 55, 52, 55, 124, 49, 53, 51, 54, 124, 56, 51, 52, 124, 48, 124, 51,
|
|
345
|
+
* 48, 124, 48, 124, 48, 124, 49, 53, 51, 54, 124, 56, 51, 52, 124, 49, 53, 51, 54, 124, 56,
|
|
346
|
+
* 54, 52, 124, 49, 53, 50, 53, 124, 55, 52, 55, 124, 50, 52, 124, 50, 52, 124, 87, 105, 110,
|
|
347
|
+
* 51, 50]
|
|
348
|
+
*/
|
|
349
|
+
const window_env_list = [];
|
|
350
|
+
for (let index = 0; index < window_env_str.length; index++) {
|
|
351
|
+
window_env_list.push(window_env_str.charCodeAt(index));
|
|
352
|
+
}
|
|
353
|
+
b[64] = window_env_list.length;
|
|
354
|
+
b[65] = b[64] & 255;
|
|
355
|
+
b[66] = (b[64] >> 8) & 255;
|
|
356
|
+
b[69] = [].length;
|
|
357
|
+
b[70] = b[69] & 255;
|
|
358
|
+
b[71] = (b[69] >> 8) & 255;
|
|
359
|
+
b[72] =
|
|
360
|
+
b[18] ^
|
|
361
|
+
b[20] ^
|
|
362
|
+
b[26] ^
|
|
363
|
+
b[30] ^
|
|
364
|
+
b[38] ^
|
|
365
|
+
b[40] ^
|
|
366
|
+
b[42] ^
|
|
367
|
+
b[21] ^
|
|
368
|
+
b[27] ^
|
|
369
|
+
b[31] ^
|
|
370
|
+
b[35] ^
|
|
371
|
+
b[39] ^
|
|
372
|
+
b[41] ^
|
|
373
|
+
b[43] ^
|
|
374
|
+
b[22] ^
|
|
375
|
+
b[28] ^
|
|
376
|
+
b[32] ^
|
|
377
|
+
b[36] ^
|
|
378
|
+
b[23] ^
|
|
379
|
+
b[29] ^
|
|
380
|
+
b[33] ^
|
|
381
|
+
b[37] ^
|
|
382
|
+
b[44] ^
|
|
383
|
+
b[45] ^
|
|
384
|
+
b[46] ^
|
|
385
|
+
b[47] ^
|
|
386
|
+
b[48] ^
|
|
387
|
+
b[49] ^
|
|
388
|
+
b[50] ^
|
|
389
|
+
b[24] ^
|
|
390
|
+
b[25] ^
|
|
391
|
+
b[52] ^
|
|
392
|
+
b[53] ^
|
|
393
|
+
b[54] ^
|
|
394
|
+
b[55] ^
|
|
395
|
+
b[57] ^
|
|
396
|
+
b[58] ^
|
|
397
|
+
b[59] ^
|
|
398
|
+
b[60] ^
|
|
399
|
+
b[65] ^
|
|
400
|
+
b[66] ^
|
|
401
|
+
b[70] ^
|
|
402
|
+
b[71];
|
|
403
|
+
let bb = [
|
|
404
|
+
b[18],
|
|
405
|
+
b[20],
|
|
406
|
+
b[52],
|
|
407
|
+
b[26],
|
|
408
|
+
b[30],
|
|
409
|
+
b[34],
|
|
410
|
+
b[58],
|
|
411
|
+
b[38],
|
|
412
|
+
b[40],
|
|
413
|
+
b[53],
|
|
414
|
+
b[42],
|
|
415
|
+
b[21],
|
|
416
|
+
b[27],
|
|
417
|
+
b[54],
|
|
418
|
+
b[55],
|
|
419
|
+
b[31],
|
|
420
|
+
b[35],
|
|
421
|
+
b[57],
|
|
422
|
+
b[39],
|
|
423
|
+
b[41],
|
|
424
|
+
b[43],
|
|
425
|
+
b[22],
|
|
426
|
+
b[28],
|
|
427
|
+
b[32],
|
|
428
|
+
b[60],
|
|
429
|
+
b[36],
|
|
430
|
+
b[23],
|
|
431
|
+
b[29],
|
|
432
|
+
b[33],
|
|
433
|
+
b[37],
|
|
434
|
+
b[44],
|
|
435
|
+
b[45],
|
|
436
|
+
b[59],
|
|
437
|
+
b[46],
|
|
438
|
+
b[47],
|
|
439
|
+
b[48],
|
|
440
|
+
b[49],
|
|
441
|
+
b[50],
|
|
442
|
+
b[24],
|
|
443
|
+
b[25],
|
|
444
|
+
b[65],
|
|
445
|
+
b[66],
|
|
446
|
+
b[70],
|
|
447
|
+
b[71]
|
|
448
|
+
];
|
|
449
|
+
bb = bb.concat(window_env_list).concat(b[72]);
|
|
450
|
+
return rc4_encrypt(String.fromCharCode.apply(null, bb), String.fromCharCode.apply(null, [121]));
|
|
451
|
+
}
|
|
452
|
+
function generate_random_str() {
|
|
453
|
+
let random_str_list = [];
|
|
454
|
+
random_str_list = random_str_list.concat(gener_random(Math.random() * 10000, [3, 45]));
|
|
455
|
+
random_str_list = random_str_list.concat(gener_random(Math.random() * 10000, [1, 0]));
|
|
456
|
+
random_str_list = random_str_list.concat(gener_random(Math.random() * 10000, [1, 5]));
|
|
457
|
+
return String.fromCharCode.apply(null, random_str_list);
|
|
458
|
+
}
|
|
459
|
+
export default (url, user_agent) => {
|
|
460
|
+
let result_str = generate_random_str() + generate_rc4_bb_str((new URLSearchParams((new URL(url)).search)).toString(), user_agent, "1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32");
|
|
461
|
+
return result_encrypt(result_str, 's4') + '=';
|
|
462
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { signature } from './a_bougs.js';
|
|
1
|
+
import a_bogus from './a_bogus.js';
|
|
3
2
|
import crypto from 'crypto';
|
|
4
3
|
const headers = {
|
|
5
4
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'
|
|
@@ -11,9 +10,9 @@ export default class sign {
|
|
|
11
10
|
const randomBytes = crypto.randomBytes(length);
|
|
12
11
|
return Array.from(randomBytes, (byte) => characters[byte % characters.length]).join('');
|
|
13
12
|
}
|
|
14
|
-
/**
|
|
13
|
+
/** a_bogus 签名算法 */
|
|
15
14
|
static AB(url) {
|
|
16
|
-
return
|
|
15
|
+
return a_bogus(url, headers['User-Agent']);
|
|
17
16
|
}
|
|
18
17
|
/** 生成一个唯一的验证字符串 */
|
|
19
18
|
static VerifyFpManager() {
|
package/lib/model/networks.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fetch, { Response } from 'node-fetch';
|
|
2
2
|
import { logger } from '../model/index.js';
|
|
3
|
+
const controller = new AbortController();
|
|
3
4
|
export default class Networks {
|
|
4
5
|
url;
|
|
5
6
|
method;
|
|
@@ -92,6 +93,10 @@ export default class Networks {
|
|
|
92
93
|
if (result.status === 504) {
|
|
93
94
|
return result;
|
|
94
95
|
}
|
|
96
|
+
if (result.status === 429) {
|
|
97
|
+
logger.warn('HTTP 响应状态码: 429');
|
|
98
|
+
throw new Error('ratelimit triggered, 触发 https://www.douyin.com/ 的速率限制!!!');
|
|
99
|
+
}
|
|
95
100
|
this.fetch = result;
|
|
96
101
|
this.isGetResult = true;
|
|
97
102
|
}
|
|
@@ -212,7 +217,6 @@ export default class Networks {
|
|
|
212
217
|
this.fetch = await this.fetch.blob();
|
|
213
218
|
}
|
|
214
219
|
timeoutPromise(timeout) {
|
|
215
|
-
const controller = new AbortController();
|
|
216
220
|
return new Promise((resolve, reject) => {
|
|
217
221
|
this.timer = setTimeout(() => {
|
|
218
222
|
logger.info('执行力');
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikenxuan/amagi",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"homepage": "https://github.com/ikenxuan/amagi",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "tsx lib/dev.js",
|
|
10
|
-
"build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json
|
|
10
|
+
"build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"/lib/**/*.js",
|
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
// All the content in this article is only for learning and communication use, not for any other purpose, strictly prohibited for commercial use and illegal use, otherwise all the consequences are irrelevant to the author!
|
|
2
|
-
function rc4_encrypt (plaintext, key) {
|
|
3
|
-
const s = []
|
|
4
|
-
for (var i = 0; i < 256; i++) {
|
|
5
|
-
s[i] = i
|
|
6
|
-
}
|
|
7
|
-
var j = 0
|
|
8
|
-
for (var i = 0; i < 256; i++) {
|
|
9
|
-
j = (j + s[i] + key.charCodeAt(i % key.length)) % 256
|
|
10
|
-
var temp = s[i]
|
|
11
|
-
s[i] = s[j]
|
|
12
|
-
s[j] = temp
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
var i = 0
|
|
16
|
-
var j = 0
|
|
17
|
-
const cipher = []
|
|
18
|
-
for (let k = 0; k < plaintext.length; k++) {
|
|
19
|
-
i = (i + 1) % 256
|
|
20
|
-
j = (j + s[i]) % 256
|
|
21
|
-
var temp = s[i]
|
|
22
|
-
s[i] = s[j]
|
|
23
|
-
s[j] = temp
|
|
24
|
-
const t = (s[i] + s[j]) % 256
|
|
25
|
-
cipher.push(String.fromCharCode(s[t] ^ plaintext.charCodeAt(k)))
|
|
26
|
-
}
|
|
27
|
-
return cipher.join('')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function le (e, r) {
|
|
31
|
-
return ((e << (r %= 32)) | (e >>> (32 - r))) >>> 0
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function de (e) {
|
|
35
|
-
return e >= 0 && e < 16 ? 2043430169 : e >= 16 && e < 64 ? 2055708042 : void console.error('invalid j for constant Tj')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function pe (e, r, t, n) {
|
|
39
|
-
return e >= 0 && e < 16
|
|
40
|
-
? (r ^ t ^ n) >>> 0
|
|
41
|
-
: e >= 16 && e < 64
|
|
42
|
-
? ((r & t) | (r & n) | (t & n)) >>> 0
|
|
43
|
-
: (console.error('invalid j for bool function FF'), 0)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function he (e, r, t, n) {
|
|
47
|
-
return e >= 0 && e < 16 ? (r ^ t ^ n) >>> 0 : e >= 16 && e < 64 ? ((r & t) | (~r & n)) >>> 0 : (console.error('invalid j for bool function GG'), 0)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function reset () {
|
|
51
|
-
(this.reg[0] = 1937774191),
|
|
52
|
-
(this.reg[1] = 1226093241),
|
|
53
|
-
(this.reg[2] = 388252375),
|
|
54
|
-
(this.reg[3] = 3666478592),
|
|
55
|
-
(this.reg[4] = 2842636476),
|
|
56
|
-
(this.reg[5] = 372324522),
|
|
57
|
-
(this.reg[6] = 3817729613),
|
|
58
|
-
(this.reg[7] = 2969243214),
|
|
59
|
-
(this.chunk = []),
|
|
60
|
-
(this.size = 0)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function write (e) {
|
|
64
|
-
let n
|
|
65
|
-
var a =
|
|
66
|
-
typeof e == 'string'
|
|
67
|
-
? (function (e) {
|
|
68
|
-
; (n = encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function (e, r) {
|
|
69
|
-
return String.fromCharCode('0x' + r)
|
|
70
|
-
})),
|
|
71
|
-
(a = new Array(n.length))
|
|
72
|
-
return (
|
|
73
|
-
Array.prototype.forEach.call(n, function (e, r) {
|
|
74
|
-
a[r] = e.charCodeAt(0)
|
|
75
|
-
}),
|
|
76
|
-
a
|
|
77
|
-
)
|
|
78
|
-
})(e)
|
|
79
|
-
: e
|
|
80
|
-
this.size += a.length
|
|
81
|
-
let f = 64 - this.chunk.length
|
|
82
|
-
if (a.length < f) this.chunk = this.chunk.concat(a)
|
|
83
|
-
else {
|
|
84
|
-
for (this.chunk = this.chunk.concat(a.slice(0, f)); this.chunk.length >= 64;) { this._compress(this.chunk), f < a.length ? (this.chunk = a.slice(f, Math.min(f + 64, a.length))) : (this.chunk = []), (f += 64) }
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function sum (e, t) {
|
|
89
|
-
e && (this.reset(), this.write(e)), this._fill()
|
|
90
|
-
for (var f = 0; f < this.chunk.length; f += 64) this._compress(this.chunk.slice(f, f + 64))
|
|
91
|
-
let i = null
|
|
92
|
-
if (t == 'hex') {
|
|
93
|
-
i = ''
|
|
94
|
-
for (f = 0; f < 8; f++) i += se(this.reg[f].toString(16), 8, '0')
|
|
95
|
-
} else {
|
|
96
|
-
for (i = new Array(32), f = 0; f < 8; f++) {
|
|
97
|
-
let c = this.reg[f]
|
|
98
|
-
; (i[4 * f + 3] = (255 & c) >>> 0),
|
|
99
|
-
(c >>>= 8),
|
|
100
|
-
(i[4 * f + 2] = (255 & c) >>> 0),
|
|
101
|
-
(c >>>= 8),
|
|
102
|
-
(i[4 * f + 1] = (255 & c) >>> 0),
|
|
103
|
-
(c >>>= 8),
|
|
104
|
-
(i[4 * f] = (255 & c) >>> 0)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return this.reset(), i
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function _compress (t) {
|
|
111
|
-
if (t < 64) console.error('compress error: not enough data')
|
|
112
|
-
else {
|
|
113
|
-
for (
|
|
114
|
-
var f = (function (e) {
|
|
115
|
-
for (var r = new Array(132), t = 0; t < 16; t++) { (r[t] = e[4 * t] << 24), (r[t] |= e[4 * t + 1] << 16), (r[t] |= e[4 * t + 2] << 8), (r[t] |= e[4 * t + 3]), (r[t] >>>= 0) }
|
|
116
|
-
for (var n = 16; n < 68; n++) {
|
|
117
|
-
let a = r[n - 16] ^ r[n - 9] ^ le(r[n - 3], 15)
|
|
118
|
-
; (a = a ^ le(a, 15) ^ le(a, 23)), (r[n] = (a ^ le(r[n - 13], 7) ^ r[n - 6]) >>> 0)
|
|
119
|
-
}
|
|
120
|
-
for (n = 0; n < 64; n++) r[n + 68] = (r[n] ^ r[n + 4]) >>> 0
|
|
121
|
-
return r
|
|
122
|
-
})(t),
|
|
123
|
-
i = this.reg.slice(0),
|
|
124
|
-
c = 0;
|
|
125
|
-
c < 64;
|
|
126
|
-
c++
|
|
127
|
-
) {
|
|
128
|
-
let o = le(i[0], 12) + i[4] + le(de(c), c)
|
|
129
|
-
const s = ((o = le((o = (4294967295 & o) >>> 0), 7)) ^ le(i[0], 12)) >>> 0
|
|
130
|
-
let u = pe(c, i[0], i[1], i[2])
|
|
131
|
-
u = (4294967295 & (u = u + i[3] + s + f[c + 68])) >>> 0
|
|
132
|
-
let b = he(c, i[4], i[5], i[6])
|
|
133
|
-
; (b = (4294967295 & (b = b + i[7] + o + f[c])) >>> 0),
|
|
134
|
-
(i[3] = i[2]),
|
|
135
|
-
(i[2] = le(i[1], 9)),
|
|
136
|
-
(i[1] = i[0]),
|
|
137
|
-
(i[0] = u),
|
|
138
|
-
(i[7] = i[6]),
|
|
139
|
-
(i[6] = le(i[5], 19)),
|
|
140
|
-
(i[5] = i[4]),
|
|
141
|
-
(i[4] = (b ^ le(b, 9) ^ le(b, 17)) >>> 0)
|
|
142
|
-
}
|
|
143
|
-
for (let l = 0; l < 8; l++) this.reg[l] = (this.reg[l] ^ i[l]) >>> 0
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function _fill () {
|
|
148
|
-
const a = 8 * this.size
|
|
149
|
-
let f = this.chunk.push(128) % 64
|
|
150
|
-
for (64 - f < 8 && (f -= 64); f < 56; f++) this.chunk.push(0)
|
|
151
|
-
for (var i = 0; i < 4; i++) {
|
|
152
|
-
const c = Math.floor(a / 4294967296)
|
|
153
|
-
this.chunk.push((c >>> (8 * (3 - i))) & 255)
|
|
154
|
-
}
|
|
155
|
-
for (i = 0; i < 4; i++) this.chunk.push((a >>> (8 * (3 - i))) & 255)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function SM3 () {
|
|
159
|
-
this.reg = []
|
|
160
|
-
this.chunk = []
|
|
161
|
-
this.size = 0
|
|
162
|
-
this.reset()
|
|
163
|
-
}
|
|
164
|
-
SM3.prototype.reset = reset
|
|
165
|
-
SM3.prototype.write = write
|
|
166
|
-
SM3.prototype.sum = sum
|
|
167
|
-
SM3.prototype._compress = _compress
|
|
168
|
-
SM3.prototype._fill = _fill
|
|
169
|
-
|
|
170
|
-
function result_encrypt (long_str, num = null) {
|
|
171
|
-
const s_obj = {
|
|
172
|
-
s0: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
173
|
-
s1: 'Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=',
|
|
174
|
-
s2: 'Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=',
|
|
175
|
-
s3: 'ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe',
|
|
176
|
-
s4: 'Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe'
|
|
177
|
-
}
|
|
178
|
-
const constant = {
|
|
179
|
-
0: 16515072,
|
|
180
|
-
1: 258048,
|
|
181
|
-
2: 4032,
|
|
182
|
-
str: s_obj[num]
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
let result = ''
|
|
186
|
-
let lound = 0
|
|
187
|
-
let long_int = get_long_int(lound, long_str)
|
|
188
|
-
for (let i = 0; i < (long_str.length / 3) * 4; i++) {
|
|
189
|
-
if (Math.floor(i / 4) !== lound) {
|
|
190
|
-
lound += 1
|
|
191
|
-
long_int = get_long_int(lound, long_str)
|
|
192
|
-
}
|
|
193
|
-
const key = i % 4
|
|
194
|
-
let temp_int
|
|
195
|
-
switch (key) {
|
|
196
|
-
case 0:
|
|
197
|
-
temp_int = (long_int & constant['0']) >> 18
|
|
198
|
-
result += constant.str.charAt(temp_int)
|
|
199
|
-
break
|
|
200
|
-
case 1:
|
|
201
|
-
temp_int = (long_int & constant['1']) >> 12
|
|
202
|
-
result += constant.str.charAt(temp_int)
|
|
203
|
-
break
|
|
204
|
-
case 2:
|
|
205
|
-
temp_int = (long_int & constant['2']) >> 6
|
|
206
|
-
result += constant.str.charAt(temp_int)
|
|
207
|
-
break
|
|
208
|
-
case 3:
|
|
209
|
-
temp_int = long_int & 63
|
|
210
|
-
result += constant.str.charAt(temp_int)
|
|
211
|
-
break
|
|
212
|
-
default:
|
|
213
|
-
break
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return result
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function get_long_int (round, long_str) {
|
|
220
|
-
round = round * 3
|
|
221
|
-
return (long_str.charCodeAt(round) << 16) | (long_str.charCodeAt(round + 1) << 8) | long_str.charCodeAt(round + 2)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function gener_random (random, option) {
|
|
225
|
-
return [
|
|
226
|
-
(random & 255 & 170) | (option[0] & 85), // 163
|
|
227
|
-
(random & 255 & 85) | (option[0] & 170), // 87
|
|
228
|
-
((random >> 8) & 255 & 170) | (option[1] & 85), // 37
|
|
229
|
-
((random >> 8) & 255 & 85) | (option[1] & 170) // 41
|
|
230
|
-
]
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/// ///////////////////////////////////////////
|
|
234
|
-
function generate_rc4_bb_str (url_search_params, user_agent, window_env_str, suffix = 'cus', Arguments = [0, 1, 14]) {
|
|
235
|
-
const sm3 = new SM3()
|
|
236
|
-
const start_time = Date.now()
|
|
237
|
-
/**
|
|
238
|
-
* 进行3次加密处理
|
|
239
|
-
* 1: url_search_params两次sm3之的结果
|
|
240
|
-
* 2: 对后缀两次sm3之的结果
|
|
241
|
-
* 3: 对ua处理之后的结果
|
|
242
|
-
*/
|
|
243
|
-
// url_search_params两次sm3之的结果
|
|
244
|
-
const url_search_params_list = sm3.sum(sm3.sum(url_search_params + suffix))
|
|
245
|
-
// 对后缀两次sm3之的结果
|
|
246
|
-
const cus = sm3.sum(sm3.sum(suffix))
|
|
247
|
-
// 对ua处理之后的结果
|
|
248
|
-
const ua = sm3.sum(result_encrypt(rc4_encrypt(user_agent, String.fromCharCode.apply(null, [0.00390625, 1, 14])), 's3'))
|
|
249
|
-
//
|
|
250
|
-
const end_time = Date.now()
|
|
251
|
-
// b
|
|
252
|
-
const b = {
|
|
253
|
-
8: 3, // 固定
|
|
254
|
-
10: end_time, // 3次加密结束时间
|
|
255
|
-
15: {
|
|
256
|
-
aid: 6383,
|
|
257
|
-
pageId: 6241,
|
|
258
|
-
boe: false,
|
|
259
|
-
ddrt: 7,
|
|
260
|
-
paths: {
|
|
261
|
-
include: [{}, {}, {}, {}, {}, {}, {}],
|
|
262
|
-
exclude: []
|
|
263
|
-
},
|
|
264
|
-
track: {
|
|
265
|
-
mode: 0,
|
|
266
|
-
delay: 300,
|
|
267
|
-
paths: []
|
|
268
|
-
},
|
|
269
|
-
dump: true,
|
|
270
|
-
rpU: ''
|
|
271
|
-
},
|
|
272
|
-
16: start_time, // 3次加密开始时间
|
|
273
|
-
18: 44, // 固定
|
|
274
|
-
19: [1, 0, 1, 5]
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// 3次加密开始时间
|
|
278
|
-
b[20] = (b[16] >> 24) & 255
|
|
279
|
-
b[21] = (b[16] >> 16) & 255
|
|
280
|
-
b[22] = (b[16] >> 8) & 255
|
|
281
|
-
b[23] = b[16] & 255
|
|
282
|
-
b[24] = (b[16] / 256 / 256 / 256 / 256) >> 0
|
|
283
|
-
b[25] = (b[16] / 256 / 256 / 256 / 256 / 256) >> 0
|
|
284
|
-
|
|
285
|
-
// 参数Arguments [0, 1, 14, ...]
|
|
286
|
-
// let Arguments = [0, 1, 14]
|
|
287
|
-
b[26] = (Arguments[0] >> 24) & 255
|
|
288
|
-
b[27] = (Arguments[0] >> 16) & 255
|
|
289
|
-
b[28] = (Arguments[0] >> 8) & 255
|
|
290
|
-
b[29] = Arguments[0] & 255
|
|
291
|
-
|
|
292
|
-
b[30] = (Arguments[1] / 256) & 255
|
|
293
|
-
b[31] = Arguments[1] % 256 & 255
|
|
294
|
-
b[32] = (Arguments[1] >> 24) & 255
|
|
295
|
-
b[33] = (Arguments[1] >> 16) & 255
|
|
296
|
-
|
|
297
|
-
b[34] = (Arguments[2] >> 24) & 255
|
|
298
|
-
b[35] = (Arguments[2] >> 16) & 255
|
|
299
|
-
b[36] = (Arguments[2] >> 8) & 255
|
|
300
|
-
b[37] = Arguments[2] & 255
|
|
301
|
-
|
|
302
|
-
// (url_search_params + "cus") 两次sm3之的结果
|
|
303
|
-
/** let url_search_params_list = [
|
|
304
|
-
91, 186, 35, 86, 143, 253, 6, 76,
|
|
305
|
-
34, 21, 167, 148, 7, 42, 192, 219,
|
|
306
|
-
188, 20, 182, 85, 213, 74, 213, 147,
|
|
307
|
-
37, 155, 93, 139, 85, 118, 228, 213
|
|
308
|
-
] */
|
|
309
|
-
b[38] = url_search_params_list[21]
|
|
310
|
-
b[39] = url_search_params_list[22]
|
|
311
|
-
|
|
312
|
-
// ("cus") 对后缀两次sm3之的结果
|
|
313
|
-
/**
|
|
314
|
-
* let cus = [
|
|
315
|
-
136, 101, 114, 147, 58, 77, 207, 201,
|
|
316
|
-
215, 162, 154, 93, 248, 13, 142, 160,
|
|
317
|
-
105, 73, 215, 241, 83, 58, 51, 43,
|
|
318
|
-
255, 38, 168, 141, 216, 194, 35, 236
|
|
319
|
-
] */
|
|
320
|
-
b[40] = cus[21]
|
|
321
|
-
b[41] = cus[22]
|
|
322
|
-
|
|
323
|
-
// 对ua处理之后的结果
|
|
324
|
-
/**
|
|
325
|
-
* let ua = [
|
|
326
|
-
129, 190, 70, 186, 86, 196, 199, 53,
|
|
327
|
-
99, 38, 29, 209, 243, 17, 157, 69,
|
|
328
|
-
147, 104, 53, 23, 114, 126, 66, 228,
|
|
329
|
-
135, 30, 168, 185, 109, 156, 251, 88
|
|
330
|
-
] */
|
|
331
|
-
b[42] = ua[23]
|
|
332
|
-
b[43] = ua[24]
|
|
333
|
-
|
|
334
|
-
// 3次加密结束时间
|
|
335
|
-
b[44] = (b[10] >> 24) & 255
|
|
336
|
-
b[45] = (b[10] >> 16) & 255
|
|
337
|
-
b[46] = (b[10] >> 8) & 255
|
|
338
|
-
b[47] = b[10] & 255
|
|
339
|
-
b[48] = b[8]
|
|
340
|
-
b[49] = (b[10] / 256 / 256 / 256 / 256) >> 0
|
|
341
|
-
b[50] = (b[10] / 256 / 256 / 256 / 256 / 256) >> 0
|
|
342
|
-
|
|
343
|
-
// object配置项
|
|
344
|
-
b[51] = b[15].pageId
|
|
345
|
-
b[52] = (b[15].pageId >> 24) & 255
|
|
346
|
-
b[53] = (b[15].pageId >> 16) & 255
|
|
347
|
-
b[54] = (b[15].pageId >> 8) & 255
|
|
348
|
-
b[55] = b[15].pageId & 255
|
|
349
|
-
|
|
350
|
-
b[56] = b[15].aid
|
|
351
|
-
b[57] = b[15].aid & 255
|
|
352
|
-
b[58] = (b[15].aid >> 8) & 255
|
|
353
|
-
b[59] = (b[15].aid >> 16) & 255
|
|
354
|
-
b[60] = (b[15].aid >> 24) & 255
|
|
355
|
-
|
|
356
|
-
// 中间进行了环境检测
|
|
357
|
-
// 代码索引: 2496 索引值: 17 (索引64关键条件)
|
|
358
|
-
// '1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32'.charCodeAt()得到65位数组
|
|
359
|
-
/**
|
|
360
|
-
* let window_env_list = [49, 53, 51, 54, 124, 55, 52, 55, 124, 49, 53, 51, 54, 124, 56, 51, 52, 124, 48, 124, 51,
|
|
361
|
-
* 48, 124, 48, 124, 48, 124, 49, 53, 51, 54, 124, 56, 51, 52, 124, 49, 53, 51, 54, 124, 56,
|
|
362
|
-
* 54, 52, 124, 49, 53, 50, 53, 124, 55, 52, 55, 124, 50, 52, 124, 50, 52, 124, 87, 105, 110,
|
|
363
|
-
* 51, 50]
|
|
364
|
-
*/
|
|
365
|
-
const window_env_list = []
|
|
366
|
-
for (let index = 0; index < window_env_str.length; index++) {
|
|
367
|
-
window_env_list.push(window_env_str.charCodeAt(index))
|
|
368
|
-
}
|
|
369
|
-
b[64] = window_env_list.length
|
|
370
|
-
b[65] = b[64] & 255
|
|
371
|
-
b[66] = (b[64] >> 8) & 255
|
|
372
|
-
|
|
373
|
-
b[69] = [].length
|
|
374
|
-
b[70] = b[69] & 255
|
|
375
|
-
b[71] = (b[69] >> 8) & 255
|
|
376
|
-
|
|
377
|
-
b[72] =
|
|
378
|
-
b[18] ^
|
|
379
|
-
b[20] ^
|
|
380
|
-
b[26] ^
|
|
381
|
-
b[30] ^
|
|
382
|
-
b[38] ^
|
|
383
|
-
b[40] ^
|
|
384
|
-
b[42] ^
|
|
385
|
-
b[21] ^
|
|
386
|
-
b[27] ^
|
|
387
|
-
b[31] ^
|
|
388
|
-
b[35] ^
|
|
389
|
-
b[39] ^
|
|
390
|
-
b[41] ^
|
|
391
|
-
b[43] ^
|
|
392
|
-
b[22] ^
|
|
393
|
-
b[28] ^
|
|
394
|
-
b[32] ^
|
|
395
|
-
b[36] ^
|
|
396
|
-
b[23] ^
|
|
397
|
-
b[29] ^
|
|
398
|
-
b[33] ^
|
|
399
|
-
b[37] ^
|
|
400
|
-
b[44] ^
|
|
401
|
-
b[45] ^
|
|
402
|
-
b[46] ^
|
|
403
|
-
b[47] ^
|
|
404
|
-
b[48] ^
|
|
405
|
-
b[49] ^
|
|
406
|
-
b[50] ^
|
|
407
|
-
b[24] ^
|
|
408
|
-
b[25] ^
|
|
409
|
-
b[52] ^
|
|
410
|
-
b[53] ^
|
|
411
|
-
b[54] ^
|
|
412
|
-
b[55] ^
|
|
413
|
-
b[57] ^
|
|
414
|
-
b[58] ^
|
|
415
|
-
b[59] ^
|
|
416
|
-
b[60] ^
|
|
417
|
-
b[65] ^
|
|
418
|
-
b[66] ^
|
|
419
|
-
b[70] ^
|
|
420
|
-
b[71]
|
|
421
|
-
let bb = [
|
|
422
|
-
b[18],
|
|
423
|
-
b[20],
|
|
424
|
-
b[52],
|
|
425
|
-
b[26],
|
|
426
|
-
b[30],
|
|
427
|
-
b[34],
|
|
428
|
-
b[58],
|
|
429
|
-
b[38],
|
|
430
|
-
b[40],
|
|
431
|
-
b[53],
|
|
432
|
-
b[42],
|
|
433
|
-
b[21],
|
|
434
|
-
b[27],
|
|
435
|
-
b[54],
|
|
436
|
-
b[55],
|
|
437
|
-
b[31],
|
|
438
|
-
b[35],
|
|
439
|
-
b[57],
|
|
440
|
-
b[39],
|
|
441
|
-
b[41],
|
|
442
|
-
b[43],
|
|
443
|
-
b[22],
|
|
444
|
-
b[28],
|
|
445
|
-
b[32],
|
|
446
|
-
b[60],
|
|
447
|
-
b[36],
|
|
448
|
-
b[23],
|
|
449
|
-
b[29],
|
|
450
|
-
b[33],
|
|
451
|
-
b[37],
|
|
452
|
-
b[44],
|
|
453
|
-
b[45],
|
|
454
|
-
b[59],
|
|
455
|
-
b[46],
|
|
456
|
-
b[47],
|
|
457
|
-
b[48],
|
|
458
|
-
b[49],
|
|
459
|
-
b[50],
|
|
460
|
-
b[24],
|
|
461
|
-
b[25],
|
|
462
|
-
b[65],
|
|
463
|
-
b[66],
|
|
464
|
-
b[70],
|
|
465
|
-
b[71]
|
|
466
|
-
]
|
|
467
|
-
bb = bb.concat(window_env_list).concat(b[72])
|
|
468
|
-
return rc4_encrypt(String.fromCharCode.apply(null, bb), String.fromCharCode.apply(null, [121]))
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
function generate_random_str () {
|
|
472
|
-
let random_str_list = []
|
|
473
|
-
random_str_list = random_str_list.concat(gener_random(Math.random() * 10000, [3, 45]))
|
|
474
|
-
random_str_list = random_str_list.concat(gener_random(Math.random() * 10000, [1, 0]))
|
|
475
|
-
random_str_list = random_str_list.concat(gener_random(Math.random() * 10000, [1, 5]))
|
|
476
|
-
return String.fromCharCode.apply(null, random_str_list)
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
export function signature (url_search_params, user_agent) {
|
|
480
|
-
/**
|
|
481
|
-
* url_search_params:"device_platform=webapp&aid=6383&channel=channel_pc_web&update_version_code=170400&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1536&screen_height=864&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=123.0.0.0&browser_online=true&engine_name=Blink&engine_version=123.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7362810250930783783&msToken=VkDUvz1y24CppXSl80iFPr6ez-3FiizcwD7fI1OqBt6IICq9RWG7nCvxKb8IVi55mFd-wnqoNkXGnxHrikQb4PuKob5Q-YhDp5Um215JzlBszkUyiEvR"
|
|
482
|
-
* user_agent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
|
|
483
|
-
*/
|
|
484
|
-
const result_str =
|
|
485
|
-
generate_random_str() + generate_rc4_bb_str(url_search_params, user_agent, '1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32')
|
|
486
|
-
return result_encrypt(result_str, 's4') + '='
|
|
487
|
-
}
|