-
Notifications
You must be signed in to change notification settings - Fork 44
/
Decryptor.js
1660 lines (1580 loc) · 104 KB
/
Decryptor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* JsjiamiV6解密工具
* @author NXY666
* @version 2.9.0
*/
const fs = require("fs");
const readline = require("readline");
const Path = require("path");
const vm = require("vm");
let vm2;
/**
* 获取数组末尾的值。
* @param {number} offset 偏移值。
* @returns {any | undefined} 返回数组末尾的值。若数组为空,则返回undefined。
*/
Array.prototype.top = function (offset = 0) {
return this[this.length - 1 - offset];
};
/**
* 使用字符串替换当前字符串中的一段字符。
* @param {number} st 起始位置。
* @param {number} en 结束位置。
* @param {string} str 替换结果字符串。
*/
String.prototype.replaceWithStr = function (st, en, str) {
return this.slice(0, st) + str + this.slice(en);
};
/**
* 以一段长度相同的字符串为模板分割当前字符串。
* @param {string} str 字符串模板。
* @param {string} separator 分隔符。
* @returns {string[]} 返回分割后的字符串数组。
* @throws {Error} 字符串模板长度与当前字符串长度不一致时抛出错误。
*/
String.prototype.splitByOtherStr = function (str, separator) {
if (this.length !== str.length) {
throw Error("字符串模板长度与当前字符串长度不一致。");
}
let splitRes = str.split(separator);
let nowPos = 0;
return splitRes.map(function (item) {
let res = this.slice(nowPos, nowPos + item.length);
nowPos += item.length + separator.length;
return res;
}.bind(this));
};
/**
* 使用正则表达式或字符串从某一位置开始搜索字符串。
* @param {RegExp|string} regexp 正则表达式。若为字符串则等同于 String.indexOf 。
* @param {number?} position 起始位置。若不指定则从 0 位置开始搜索。
* @returns {number} 匹配到的索引值。若未匹配成功,则返回 -1。
*/
String.prototype.searchOf = function (regexp, position = 0) {
if (typeof regexp == "string") {
return this.indexOf(regexp, position);
}
if (position < 0) {
position = 0;
} else if (position >= this.length) {
return -1;
}
let searchRes = this.slice(position).search(regexp);
return searchRes === -1 ? -1 : position + searchRes;
};
/**
* 使用正则表达式或字符串从字符串末尾的某一位置开始搜索字符串。
* @param {RegExp|string} regexp 正则表达式。若为字符串则等同于 String.lastIndexOf ,在该方法下贪婪模式不生效。
* @param {number?} position 起始位置。若不指定则从 +Infinity 位置开始搜索。
* @returns {number} 匹配到的索引值。若未匹配成功,则返回 -1。
*/
String.prototype.lastSearchOf = function (regexp, position = Number.POSITIVE_INFINITY) {
let srcReg = regexp;
if (regexp instanceof RegExp) {
regexp = new RegExp(`[\\s\\S]*(?=(?:${regexp.source}))`, regexp.flags.replace(/g/g, ''));
} else {
return this.lastIndexOf(regexp, position);
}
let thisStr = this;
if (position < 0) {
return -1;
} else if (position < thisStr.length) {
thisStr = thisStr.slice(0, position + 1);
}
if (!srcReg.test(thisStr)) {
return -1;
}
return thisStr.match(regexp)[0].length;
};
/**
* 填充字符串。
* @param {string} char 正则表达式。若为字符串则等同于 String.lastIndexOf ,在该方法下贪婪模式不生效。
* @param {number?} st 起始位置。若不指定则从字符串开头开始。
* @param {number?} en 结束位置。若不指定则从字符串末尾结束。
* @returns {string} 填充结果。
*/
String.prototype.fill = function (char, st = 0, en = this.length) {
if (st < 0) {
st = 0;
} else if (st >= this.length) {
return this;
}
if (en < 0) {
return this;
} else if (en >= this.length) {
en = this.length;
}
return this.split("").fill(char, st, en).join("");
};
// fs.writeFileSync("res.txt", "");
/**
* 日志工具
* */
const Logger = (function () {
function Logger(options) {
options = options || {};
this.mergeOptions(this._options, options);
this._data.progress.layers[-1] = {
index: -1,
now: 0,
max: 1,
tempSize: 100,
tempProg: 0
};
console.clear();
}
Logger.prototype._options = {
// 进度选项
content: {
linePrefix: {
first: "* ",
others: "· "
}
},
// 进度选项
progress: {
length: 50,
frequency: 100,
emptyStr: " ",
fullStr: "="
}
};
Logger.prototype._data = {
// 日志数据
log: {
content: null,
lastTime: 0,
line: 0,
lastContentLines: 0
},
// 进度数据
progress: {
enabled: false,
determine: false,
finished: false,
max: 100,
now: 0,
layers: []
}
};
Logger.prototype.mergeOptions = function (targetOption, newOption) {
if (!newOption) {
return targetOption;
}
Object.keys(targetOption).forEach(function (key) {
if (newOption[key] === undefined) {
return;
}
if (typeof targetOption[key] != "object" || Array.isArray(targetOption[key])) {
targetOption[key] = newOption[key];
} else {
targetOption[key] = this.mergeOptions(targetOption[key], newOption[key]);
}
}.bind(this));
return targetOption;
};
Logger.prototype.weakUpdate = function () {
this.updateConsole();
};
Logger.prototype.updateConsole = function (forceOutput, stayInline) {
// 检查更新是否过于频繁
if (!forceOutput && Date.now() - this._data.log.lastTime < this._options.progress.frequency) {
return;
} else {
this._data.log.lastTime = Date.now();
}
// 日志进度
let now, max, length, percent;
let progressArr = [], progressStr = "";
if (this._data.progress.enabled) {
now = this._data.progress.now;
max = this._data.progress.max;
if (now > max) {
now = max;
}
progressArr.length = length = this._options.progress.length;
if (this._data.progress.determine) {
percent = Math.floor(now / max * length);
progressArr.fill(this._options.progress.fullStr, 0, percent);
progressArr.fill(this._options.progress.emptyStr, percent, length);
progressStr = `[${progressArr.join("")}] ${(now / max * 100).toFixed(1).padStart(5, " ")}%`;
} else {
if (this._data.progress.finished) {
progressArr.fill(this._options.progress.fullStr, 0, length);
progressStr = `[${progressArr.join("")}]`;
} else {
let progressBarStart = now % length,
progressBarEnd = progressBarStart + length / 5;
progressArr.fill(this._options.progress.emptyStr, 0, length);
progressArr.fill(this._options.progress.fullStr, progressBarStart, progressBarEnd);
let exceed = progressBarEnd - length;
if (exceed > 0) {
progressArr.fill(this._options.progress.fullStr, 0, exceed);
}
progressStr = `[${progressArr.join("")}]`;
this._data.progress.now++;
}
}
}
let logContents = this._data.log.content.split("\n"), logContentLength = logContents.length;
// 写入日志
if (stayInline) {
this._data.log.line += this._data.log.lastContentLines;
} else {
readline.cursorTo(process.stdout, 0, this._data.log.line);
}
let lastContentLines = this._data.log.lastContentLines;
logContents.forEach(function (line, index) {
console.info((index === 0 ? this._options.content.linePrefix.first : this._options.content.linePrefix.others) + line + (index === logContentLength - 1 ? " " + progressStr : ""));
}.bind(this));
if (lastContentLines > logContentLength) {
for (let i = lastContentLines - logContentLength; i > 0; i--) {
console.info("\n");
}
}
this._data.log.lastContentLines = logContentLength;
};
Logger.prototype.logWithProgress = function (content, now, max) {
let logChanged = this._data.log.content !== null && this._data.log.content !== content;
if (logChanged && !this._data.progress.determine) {
this.logWithoutDetermineFinished();
}
this._data.log.content = content;
this._data.progress.enabled = true;
this._data.progress.determine = true;
this._data.progress.now = now;
this._data.progress.max = max;
this.updateConsole(true, logChanged);
};
Logger.prototype.logWithoutDetermine = function (content) {
let logChanged = this._data.log.content !== null && this._data.log.content !== content;
if (logChanged && !this._data.progress.determine) {
this.logWithoutDetermineFinished();
}
this._data.log.content = content;
this._data.progress.enabled = true;
this._data.progress.determine = false;
this._data.progress.finished = false;
this._data.progress.now = 0;
this._data.progress.max = Number.POSITIVE_INFINITY;
this.updateConsole(true, logChanged);
};
Logger.prototype.logWithoutDetermineFinished = function () {
this._data.progress.finished = true;
this.updateConsole(true);
};
Logger.prototype.logWithoutProgress = function (content) {
let logChanged = this._data.log.content !== null && this._data.log.content !== content;
if (logChanged && !this._data.progress.determine) {
this.logWithoutDetermineFinished();
}
this._data.log.content = content;
this._data.progress.enabled = false;
this.updateConsole(true, logChanged);
};
Logger.prototype.addLayer = function (max) {
let nowIndex = this._data.progress.layers.length;
let lastLayer = this._data.progress.layers[nowIndex - 1];
this._data.progress.layers.push({
index: nowIndex,
now: 0,
max,
tempSize: lastLayer.tempSize / lastLayer.max,
tempProg: lastLayer.tempProg
});
};
Logger.prototype.setLayer = function (now, max) {
let lastLayer = this._data.progress.layers.top(-1);
let nowLayer = this._data.progress.layers.top();
if (now !== undefined) {
nowLayer.now = now;
}
if (max !== undefined) {
nowLayer.max = max;
}
nowLayer.tempProg = lastLayer.tempProg + nowLayer.tempSize * nowLayer.now / nowLayer.max;
};
Logger.prototype.removeLayer = function () {
this._data.progress.layers.pop();
};
return Logger;
})();
function pause(text) {
if (config["quietMode"]) {
return;
}
// process.stdin.setRawMode已被废弃,某些版本只能使用回车键来解除暂停
console.warn(`${text !== undefined ? text + "\n" : ""}[请按${process.stdin.setRawMode ? '任意' : '回车'}键继续]`);
let stopTime = Date.now();
process.stdin.setRawMode && process.stdin.setRawMode(true);
try {
fs.readSync(0, Buffer.alloc(1), 0, 1, null);
} catch (e) {
if (e.code === 'EAGAIN') {
// 'resource temporarily unavailable'
// Happens on OS X 10.8.3 (not Windows 7!)
throw Error("暂停功能不受支持,请在配置文件中启用安静模式。");
} else if (e.code === 'EOF') {
// Happens on Windows 7, but not OS X 10.8.3:
// simply signals the end of *piped* stdin input.
} else {
throw e;
}
}
process.stdin.setRawMode && process.stdin.setRawMode(false);
PAUSE_TIME += Date.now() - stopTime;
}
/**
* 代码分析工具
* */
function transStr(jsStr) {
let signStack = [], jsArr = jsStr.split("");
let signStartPosStack = [], lastQuoteStartPos = -1;
for (let nowPos = 0; nowPos < jsArr.length; nowPos++) {
switch (jsArr[nowPos]) {
case '/':
if (signStack.top() === jsArr[nowPos]) {
// 结束正则
signStack.pop();
lastQuoteStartPos = signStartPosStack.pop();
continue;
} else if (signStack.length === 0) {
// [{( +-* <>=? &|! ~^ ,
if (jsArr[nowPos + 1] === '*') {
// 块注释
let endPos = jsStr.indexOf("*/", nowPos);
jsArr.fill("C", nowPos + 2, endPos);
nowPos = endPos + 1;
} else if (jsArr[nowPos + 1] === '/') {
// 行注释
let endPos = jsStr.searchOf(/\n?\r|\r?\n/, nowPos);
jsArr.fill("C", nowPos + 2, endPos);
nowPos = endPos - 1;
} else if (nowPos === 0 || (() => {
let jsStrBehind = jsStr.slice(0, nowPos).trim();
if (
// 符号后为正则表达式
/(\.|\(|,|{|}|\[|;|(?:[=!]?=|\+|-|\*|%|<?<|>?>?>|&|\||^|\/|!)?=|\*|%|\+?\+|-?-|<?<|>?>?>|&?&|^|!|~|\|?\||\?|:)$/.test(jsStrBehind) ||
// 关键字后为正则表达式
/(?:^|[\u0000-\u0023\u0025-\u002d\u002f\u003a-\u0040\u005b-\u005c\u005e\u0060\u007b-\u00a9\u00ab-\u00b4\u00b6\u00b8-\u00b9\u00bb-\u00bf\u00d7\u00f7\u02c2-\u02c5\u02d2-\u02df\u02e5-\u02eb\u02ed\u02ef-\u02ff\u0375\u0378-\u0379\u037e\u0380-\u0385\u038b\u038d\u03a2\u03f6\u0482\u0488-\u0489\u0530\u0557-\u0558\u055a-\u055f\u0589-\u0590\u05be\u05c0\u05c3\u05c6\u05c8-\u05cf\u05eb-\u05ee\u05f3-\u060f\u061b-\u061f\u066a-\u066d\u06d4\u06dd-\u06de\u06e9\u06fd-\u06fe\u0700-\u070f\u074b-\u074c\u07b2-\u07bf\u07f6-\u07f9\u07fb-\u07fc\u07fe-\u07ff\u082e-\u083f\u085c-\u085f\u086b-\u086f\u0888\u088f-\u0897\u08e2\u0964-\u0965\u0970\u0984\u098d-\u098e\u0991-\u0992\u09a9\u09b1\u09b3-\u09b5\u09ba-\u09bb\u09c5-\u09c6\u09c9-\u09ca\u09cf-\u09d6\u09d8-\u09db\u09de\u09e4-\u09e5\u09f2-\u09fb\u09fd\u09ff-\u0a00\u0a04\u0a0b-\u0a0e\u0a11-\u0a12\u0a29\u0a31\u0a34\u0a37\u0a3a-\u0a3b\u0a3d\u0a43-\u0a46\u0a49-\u0a4a\u0a4e-\u0a50\u0a52-\u0a58\u0a5d\u0a5f-\u0a65\u0a76-\u0a80\u0a84\u0a8e\u0a92\u0aa9\u0ab1\u0ab4\u0aba-\u0abb\u0ac6\u0aca\u0ace-\u0acf\u0ad1-\u0adf\u0ae4-\u0ae5\u0af0-\u0af8\u0b00\u0b04\u0b0d-\u0b0e\u0b11-\u0b12\u0b29\u0b31\u0b34\u0b3a-\u0b3b\u0b45-\u0b46\u0b49-\u0b4a\u0b4e-\u0b54\u0b58-\u0b5b\u0b5e\u0b64-\u0b65\u0b70\u0b72-\u0b81\u0b84\u0b8b-\u0b8d\u0b91\u0b96-\u0b98\u0b9b\u0b9d\u0ba0-\u0ba2\u0ba5-\u0ba7\u0bab-\u0bad\u0bba-\u0bbd\u0bc3-\u0bc5\u0bc9\u0bce-\u0bcf\u0bd1-\u0bd6\u0bd8-\u0be5\u0bf0-\u0bff\u0c0d\u0c11\u0c29\u0c3a-\u0c3b\u0c45\u0c49\u0c4e-\u0c54\u0c57\u0c5b-\u0c5c\u0c5e-\u0c5f\u0c64-\u0c65\u0c70-\u0c7f\u0c84\u0c8d\u0c91\u0ca9\u0cb4\u0cba-\u0cbb\u0cc5\u0cc9\u0cce-\u0cd4\u0cd7-\u0cdc\u0cdf\u0ce4-\u0ce5\u0cf0\u0cf3-\u0cff\u0d0d\u0d11\u0d45\u0d49\u0d4f-\u0d53\u0d58-\u0d5e\u0d64-\u0d65\u0d70-\u0d79\u0d80\u0d84\u0d97-\u0d99\u0db2\u0dbc\u0dbe-\u0dbf\u0dc7-\u0dc9\u0dcb-\u0dce\u0dd5\u0dd7\u0de0-\u0de5\u0df0-\u0df1\u0df4-\u0e00\u0e3b-\u0e3f\u0e4f\u0e5a-\u0e80\u0e83\u0e85\u0e8b\u0ea4\u0ea6\u0ebe-\u0ebf\u0ec5\u0ec7\u0ece-\u0ecf\u0eda-\u0edb\u0ee0-\u0eff\u0f01-\u0f17\u0f1a-\u0f1f\u0f2a-\u0f34\u0f36\u0f38\u0f3a-\u0f3d\u0f48\u0f6d-\u0f70\u0f85\u0f98\u0fbd-\u0fc5\u0fc7-\u0fff\u104a-\u104f\u109e-\u109f\u10c6\u10c8-\u10cc\u10ce-\u10cf\u10fb\u1249\u124e-\u124f\u1257\u1259\u125e-\u125f\u1289\u128e-\u128f\u12b1\u12b6-\u12b7\u12bf\u12c1\u12c6-\u12c7\u12d7\u1311\u1316-\u1317\u135b-\u135c\u1360-\u1368\u1372-\u137f\u1390-\u139f\u13f6-\u13f7\u13fe-\u1400\u166d-\u166e\u1680\u169b-\u169f\u16eb-\u16ed\u16f9-\u16ff\u1716-\u171e\u1735-\u173f\u1754-\u175f\u176d\u1771\u1774-\u177f\u17d4-\u17d6\u17d8-\u17db\u17de-\u17df\u17ea-\u180a\u180e\u181a-\u181f\u1879-\u187f\u18ab-\u18af\u18f6-\u18ff\u191f\u192c-\u192f\u193c-\u1945\u196e-\u196f\u1975-\u197f\u19ac-\u19af\u19ca-\u19cf\u19db-\u19ff\u1a1c-\u1a1f\u1a5f\u1a7d-\u1a7e\u1a8a-\u1a8f\u1a9a-\u1aa6\u1aa8-\u1aaf\u1abe\u1acf-\u1aff\u1b4d-\u1b4f\u1b5a-\u1b6a\u1b74-\u1b7f\u1bf4-\u1bff\u1c38-\u1c3f\u1c4a-\u1c4c\u1c7e-\u1c7f\u1c89-\u1c8f\u1cbb-\u1cbc\u1cc0-\u1ccf\u1cd3\u1cfb-\u1cff\u1f16-\u1f17\u1f1e-\u1f1f\u1f46-\u1f47\u1f4e-\u1f4f\u1f58\u1f5a\u1f5c\u1f5e\u1f7e-\u1f7f\u1fb5\u1fbd\u1fbf-\u1fc1\u1fc5\u1fcd-\u1fcf\u1fd4-\u1fd5\u1fdc-\u1fdf\u1fed-\u1ff1\u1ff5\u1ffd-\u200b\u200e-\u203e\u2041-\u2053\u2055-\u2070\u2072-\u207e\u2080-\u208f\u209d-\u20cf\u20dd-\u20e0\u20e2-\u20e4\u20f1-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2117\u211e-\u2123\u2125\u2127\u2129\u213a-\u213b\u2140-\u2144\u214a-\u214d\u214f-\u215f\u2189-\u2bff\u2ce5-\u2cea\u2cf4-\u2cff\u2d26\u2d28-\u2d2c\u2d2e-\u2d2f\u2d68-\u2d6e\u2d70-\u2d7e\u2d97-\u2d9f\u2da7\u2daf\u2db7\u2dbf\u2dc7\u2dcf\u2dd7\u2ddf\u2e00-\u3004\u3008-\u3020\u3030\u3036-\u3037\u303d-\u3040\u3097-\u3098\u30a0\u30fb\u3100-\u3104\u3130\u318f-\u319f\u31c0-\u31ef\u3200-\u33ff\u4dc0-\u4dff\ua48d-\ua4cf\ua4fe-\ua4ff\ua60d-\ua60f\ua62c-\ua63f\ua670-\ua673\ua67e\ua6f2-\ua716\ua720-\ua721\ua789-\ua78a\ua7cb-\ua7cf\ua7d2\ua7d4\ua7da-\ua7f1\ua828-\ua82b\ua82d-\ua83f\ua874-\ua87f\ua8c6-\ua8cf\ua8da-\ua8df\ua8f8-\ua8fa\ua8fc\ua92e-\ua92f\ua954-\ua95f\ua97d-\ua97f\ua9c1-\ua9ce\ua9da-\ua9df\ua9ff\uaa37-\uaa3f\uaa4e-\uaa4f\uaa5a-\uaa5f\uaa77-\uaa79\uaac3-\uaada\uaade-\uaadf\uaaf0-\uaaf1\uaaf7-\uab00\uab07-\uab08\uab0f-\uab10\uab17-\uab1f\uab27\uab2f\uab5b\uab6a-\uab6f\uabeb\uabee-\uabef\uabfa-\uabff\ud7a4-\ud7af\ud7c7-\ud7ca\ud7fc-\uf8ff\ufa6e-\ufa6f\ufada-\ufaff\ufb07-\ufb12\ufb18-\ufb1c\ufb29\ufb37\ufb3d\ufb3f\ufb42\ufb45\ufbb2-\ufbd2\ufd3e-\ufd4f\ufd90-\ufd91\ufdc8-\ufdef\ufdfc-\ufdff\ufe10-\ufe1f\ufe30-\ufe32\ufe35-\ufe4c\ufe50-\ufe6f\ufe75\ufefd-\uff0f\uff1a-\uff20\uff3b-\uff3e\uff40\uff5b-\uff65\uffbf-\uffc1\uffc8-\uffc9\uffd0-\uffd1\uffd8-\uffd9\uffdd-\uffff])(?:await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|function|if|import|in|instanceof|new|return|super|switch|throw|try|typeof|var|void|while|with|yield)$/.test(jsStrBehind)
) {
return true;
}
if (jsStrBehind.endsWith(")")) {
return /(?:^|[\u0000-\u0023\u0025-\u002f\u003a-\u0040\u005b-\u005e\u0060\u007b-\u00a9\u00ab-\u00b4\u00b6\u00b8-\u00b9\u00bb-\u00bf\u00d7\u00f7\u02c2-\u02c5\u02d2-\u02df\u02e5-\u02eb\u02ed\u02ef-\u02ff\u0375\u0378-\u0379\u037e\u0380-\u0385\u038b\u038d\u03a2\u03f6\u0482\u0488-\u0489\u0530\u0557-\u0558\u055a-\u055f\u0589-\u0590\u05be\u05c0\u05c3\u05c6\u05c8-\u05cf\u05eb-\u05ee\u05f3-\u060f\u061b-\u061f\u066a-\u066d\u06d4\u06dd-\u06de\u06e9\u06fd-\u06fe\u0700-\u070f\u074b-\u074c\u07b2-\u07bf\u07f6-\u07f9\u07fb-\u07fc\u07fe-\u07ff\u082e-\u083f\u085c-\u085f\u086b-\u086f\u0888\u088f-\u0897\u08e2\u0964-\u0965\u0970\u0984\u098d-\u098e\u0991-\u0992\u09a9\u09b1\u09b3-\u09b5\u09ba-\u09bb\u09c5-\u09c6\u09c9-\u09ca\u09cf-\u09d6\u09d8-\u09db\u09de\u09e4-\u09e5\u09f2-\u09fb\u09fd\u09ff-\u0a00\u0a04\u0a0b-\u0a0e\u0a11-\u0a12\u0a29\u0a31\u0a34\u0a37\u0a3a-\u0a3b\u0a3d\u0a43-\u0a46\u0a49-\u0a4a\u0a4e-\u0a50\u0a52-\u0a58\u0a5d\u0a5f-\u0a65\u0a76-\u0a80\u0a84\u0a8e\u0a92\u0aa9\u0ab1\u0ab4\u0aba-\u0abb\u0ac6\u0aca\u0ace-\u0acf\u0ad1-\u0adf\u0ae4-\u0ae5\u0af0-\u0af8\u0b00\u0b04\u0b0d-\u0b0e\u0b11-\u0b12\u0b29\u0b31\u0b34\u0b3a-\u0b3b\u0b45-\u0b46\u0b49-\u0b4a\u0b4e-\u0b54\u0b58-\u0b5b\u0b5e\u0b64-\u0b65\u0b70\u0b72-\u0b81\u0b84\u0b8b-\u0b8d\u0b91\u0b96-\u0b98\u0b9b\u0b9d\u0ba0-\u0ba2\u0ba5-\u0ba7\u0bab-\u0bad\u0bba-\u0bbd\u0bc3-\u0bc5\u0bc9\u0bce-\u0bcf\u0bd1-\u0bd6\u0bd8-\u0be5\u0bf0-\u0bff\u0c0d\u0c11\u0c29\u0c3a-\u0c3b\u0c45\u0c49\u0c4e-\u0c54\u0c57\u0c5b-\u0c5c\u0c5e-\u0c5f\u0c64-\u0c65\u0c70-\u0c7f\u0c84\u0c8d\u0c91\u0ca9\u0cb4\u0cba-\u0cbb\u0cc5\u0cc9\u0cce-\u0cd4\u0cd7-\u0cdc\u0cdf\u0ce4-\u0ce5\u0cf0\u0cf3-\u0cff\u0d0d\u0d11\u0d45\u0d49\u0d4f-\u0d53\u0d58-\u0d5e\u0d64-\u0d65\u0d70-\u0d79\u0d80\u0d84\u0d97-\u0d99\u0db2\u0dbc\u0dbe-\u0dbf\u0dc7-\u0dc9\u0dcb-\u0dce\u0dd5\u0dd7\u0de0-\u0de5\u0df0-\u0df1\u0df4-\u0e00\u0e3b-\u0e3f\u0e4f\u0e5a-\u0e80\u0e83\u0e85\u0e8b\u0ea4\u0ea6\u0ebe-\u0ebf\u0ec5\u0ec7\u0ece-\u0ecf\u0eda-\u0edb\u0ee0-\u0eff\u0f01-\u0f17\u0f1a-\u0f1f\u0f2a-\u0f34\u0f36\u0f38\u0f3a-\u0f3d\u0f48\u0f6d-\u0f70\u0f85\u0f98\u0fbd-\u0fc5\u0fc7-\u0fff\u104a-\u104f\u109e-\u109f\u10c6\u10c8-\u10cc\u10ce-\u10cf\u10fb\u1249\u124e-\u124f\u1257\u1259\u125e-\u125f\u1289\u128e-\u128f\u12b1\u12b6-\u12b7\u12bf\u12c1\u12c6-\u12c7\u12d7\u1311\u1316-\u1317\u135b-\u135c\u1360-\u1368\u1372-\u137f\u1390-\u139f\u13f6-\u13f7\u13fe-\u1400\u166d-\u166e\u1680\u169b-\u169f\u16eb-\u16ed\u16f9-\u16ff\u1716-\u171e\u1735-\u173f\u1754-\u175f\u176d\u1771\u1774-\u177f\u17d4-\u17d6\u17d8-\u17db\u17de-\u17df\u17ea-\u180a\u180e\u181a-\u181f\u1879-\u187f\u18ab-\u18af\u18f6-\u18ff\u191f\u192c-\u192f\u193c-\u1945\u196e-\u196f\u1975-\u197f\u19ac-\u19af\u19ca-\u19cf\u19db-\u19ff\u1a1c-\u1a1f\u1a5f\u1a7d-\u1a7e\u1a8a-\u1a8f\u1a9a-\u1aa6\u1aa8-\u1aaf\u1abe\u1acf-\u1aff\u1b4d-\u1b4f\u1b5a-\u1b6a\u1b74-\u1b7f\u1bf4-\u1bff\u1c38-\u1c3f\u1c4a-\u1c4c\u1c7e-\u1c7f\u1c89-\u1c8f\u1cbb-\u1cbc\u1cc0-\u1ccf\u1cd3\u1cfb-\u1cff\u1f16-\u1f17\u1f1e-\u1f1f\u1f46-\u1f47\u1f4e-\u1f4f\u1f58\u1f5a\u1f5c\u1f5e\u1f7e-\u1f7f\u1fb5\u1fbd\u1fbf-\u1fc1\u1fc5\u1fcd-\u1fcf\u1fd4-\u1fd5\u1fdc-\u1fdf\u1fed-\u1ff1\u1ff5\u1ffd-\u200b\u200e-\u203e\u2041-\u2053\u2055-\u2070\u2072-\u207e\u2080-\u208f\u209d-\u20cf\u20dd-\u20e0\u20e2-\u20e4\u20f1-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2117\u211e-\u2123\u2125\u2127\u2129\u213a-\u213b\u2140-\u2144\u214a-\u214d\u214f-\u215f\u2189-\u2bff\u2ce5-\u2cea\u2cf4-\u2cff\u2d26\u2d28-\u2d2c\u2d2e-\u2d2f\u2d68-\u2d6e\u2d70-\u2d7e\u2d97-\u2d9f\u2da7\u2daf\u2db7\u2dbf\u2dc7\u2dcf\u2dd7\u2ddf\u2e00-\u3004\u3008-\u3020\u3030\u3036-\u3037\u303d-\u3040\u3097-\u3098\u30a0\u30fb\u3100-\u3104\u3130\u318f-\u319f\u31c0-\u31ef\u3200-\u33ff\u4dc0-\u4dff\ua48d-\ua4cf\ua4fe-\ua4ff\ua60d-\ua60f\ua62c-\ua63f\ua670-\ua673\ua67e\ua6f2-\ua716\ua720-\ua721\ua789-\ua78a\ua7cb-\ua7cf\ua7d2\ua7d4\ua7da-\ua7f1\ua828-\ua82b\ua82d-\ua83f\ua874-\ua87f\ua8c6-\ua8cf\ua8da-\ua8df\ua8f8-\ua8fa\ua8fc\ua92e-\ua92f\ua954-\ua95f\ua97d-\ua97f\ua9c1-\ua9ce\ua9da-\ua9df\ua9ff\uaa37-\uaa3f\uaa4e-\uaa4f\uaa5a-\uaa5f\uaa77-\uaa79\uaac3-\uaada\uaade-\uaadf\uaaf0-\uaaf1\uaaf7-\uab00\uab07-\uab08\uab0f-\uab10\uab17-\uab1f\uab27\uab2f\uab5b\uab6a-\uab6f\uabeb\uabee-\uabef\uabfa-\uabff\ud7a4-\ud7af\ud7c7-\ud7ca\ud7fc-\uf8ff\ufa6e-\ufa6f\ufada-\ufaff\ufb07-\ufb12\ufb18-\ufb1c\ufb29\ufb37\ufb3d\ufb3f\ufb42\ufb45\ufbb2-\ufbd2\ufd3e-\ufd4f\ufd90-\ufd91\ufdc8-\ufdef\ufdfc-\ufdff\ufe10-\ufe1f\ufe30-\ufe32\ufe35-\ufe4c\ufe50-\ufe6f\ufe75\ufefd-\uff0f\uff1a-\uff20\uff3b-\uff3e\uff40\uff5b-\uff65\uffbf-\uffc1\uffc8-\uffc9\uffd0-\uffd1\uffd8-\uffd9\uffdd-\uffff])(?:for|while|with|if)$/.test(jsStr.slice(0, lastQuoteStartPos).trim());
}
return false;
})()) {
// 开始正则
signStack.push(jsArr[nowPos]);
signStartPosStack.push(nowPos);
}
continue;
}
break;
case '"':
case "'":
case '`':
if (signStack.top() === jsArr[nowPos]) {
// 结束字符串
signStack.pop();
lastQuoteStartPos = signStartPosStack.pop();
continue;
} else if (signStack.length === 0) {
// 开始字符串
signStack.push(jsArr[nowPos]);
signStartPosStack.push(nowPos);
continue;
}
break;
case '\\':
if (signStack.top() === '"' || signStack.top() === "'" || signStack.top() === '/' || signStack.top() === '`') {
jsArr[nowPos++] = 'S';
}
break;
default:
break;
}
if (signStack.top() === '"' || signStack.top() === "'" || signStack.top() === '/' || signStack.top() === '`') {
jsArr[nowPos] = 'S';
}
}
return jsArr.join("");
}
function transLayer(jsStr, layer, hasTrans) {
jsStr = hasTrans ? jsStr : transStr(jsStr);
if (layer === undefined) {
layer = 1;
}
let signStack = [], jsArr = jsStr.split("");
for (let nowPos = 0; nowPos < jsArr.length; nowPos++) {
switch (jsArr[nowPos]) {
case '[':
case '{':
case '(':
// 开始
signStack.push(jsArr[nowPos]);
if (signStack.length > layer) {
jsArr[nowPos] = 'Q';
}
break;
case ']':
if (signStack.top() === "[") {
// 结束
if (signStack.length > layer) {
jsArr[nowPos] = 'Q';
}
signStack.pop();
} else {
throw SyntaxError("尝试关闭不存在的“[]”。");
}
break;
case '}':
if (signStack.top() === "{") {
// 结束
if (signStack.length > layer) {
jsArr[nowPos] = 'Q';
}
signStack.pop();
} else {
throw SyntaxError("尝试关闭不存在的“{}”。");
}
break;
case ')':
if (signStack.top() === "(") {
// 结束
if (signStack.length > layer) {
jsArr[nowPos] = 'Q';
}
signStack.pop();
} else {
throw SyntaxError("尝试关闭不存在的“()”。");
}
break;
default:
if (signStack.length > layer - 1) {
jsArr[nowPos] = 'Q';
}
break;
}
}
return jsArr.join("");
}
function escapeEvalStr(str) {
return "'" + JSON.stringify(str).slice(1, -1).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'";
}
function getQuoteEndPos(jsStr, startPos) {
if (startPos === undefined) {
startPos = 0;
}
jsStr = transStr(jsStr);
let signStack = [], jsArr = jsStr.split("");
for (let nowPos = startPos; nowPos < jsArr.length; nowPos++) {
switch (jsArr[nowPos]) {
case '[':
case '{':
case '(':
// 开始
signStack.push(jsArr[nowPos]);
break;
case ']':
if (signStack.top() === "[") {
// 结束
signStack.pop();
} else {
throw SyntaxError("尝试关闭不存在的“[]”。");
}
break;
case '}':
if (signStack.top() === "{") {
// 结束
signStack.pop();
} else {
throw SyntaxError("尝试关闭不存在的“{}”。");
}
break;
case ')':
if (signStack.top() === "(") {
// 结束
signStack.pop();
} else {
throw SyntaxError("尝试关闭不存在的“()”。");
}
break;
default:
break;
}
if (signStack.length === 0) {
return nowPos;
}
}
throw Error("未知错误。");
}
function splitStatements(jsStr, statementType) {
let transLayerRes = transLayer(jsStr), splitJsArr = [];
if (statementType === undefined) {
let tmpStr = transLayerRes.replace(/[0-9a-zA-Z]+/g, "W");
if (tmpStr === "" || tmpStr === ";") {
// 空
statementType = "EMPTY";
} else if (/^(?:[^,:;]+:[^,:;]+,)*[^,:;]+:[^,:;]+$/.test(tmpStr)) {
// 对象
statementType = "OBJECT";
} else if (/^(?:case[!"%&'(*+,\-.\/:;<=>?@\[^{|~ ]|default:)/.test(transLayerRes.slice(0, 8))) {
// case
statementType = "SWITCH_CASE";
} else {
// 普通
statementType = "COMMON";
}
}
switch (statementType) {
case "EMPTY": {
break;
}
case "OBJECT": {
break;
}
case "SWITCH_CASE":
case "COMMON": {
let startPos = 0, endPos = transLayerRes.indexOf(";", startPos);
if (endPos === -1) {
endPos = Number.POSITIVE_INFINITY;
}
do {
let partJsStr = jsStr.slice(startPos, endPos + 1),
transPartJsStr = transLayerRes.slice(startPos, endPos + 1);
if (statementType === "SWITCH_CASE") {
if (/^(?:case[!"'(+\-.\[{~ ]|default:)/.test(transPartJsStr.slice(0, 8))) {
// switch...case
endPos = (() => {
let reg = /[?:]/g, res, cnt = 0;
while (res = reg.exec(transPartJsStr)) {
res[0] === "?" ? cnt++ : cnt--;
if (cnt === -1) {
return res.index;
}
}
})();
splitJsArr.push(partJsStr.slice(0, endPos + 1));
startPos += endPos + 1;
// case后跟{则一定是代码块
if (transPartJsStr[startPos] === "{") {
endPos = getQuoteEndPos(partJsStr, startPos);
splitJsArr.push(partJsStr.slice(startPos, endPos + 1));
startPos = endPos + 1;
}
} else if ((() => {
let matchRes =
transLayerRes.slice(startPos).match(/^(?:yiled )?(?:await )?if\(Q+\){?.*?(?:};|;|})(?:else if\(Q+\){?.*?(};|;|}))*(?:else{?.*?(};|;|}))?/) || // if...else
transPartJsStr.match(/^(?:yiled )?(?:await )?(?:async )?function\*? [^(]+?\(Q*\){Q*};?/) || // function(花括号不可省略,无需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?(?:for|while|with)\(Q+\){?.*?(?:};|;|})/) || // for / while / with(花括号可省略,需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?do{?.*?[;}]\(Q+\);?/) || // do...while(花括号可省略,需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?try{Q*}(?:catch(?:\(Q+\))?{Q*})?(?:finally{Q*})?;?/) || // try...catch(两个花括号都不能省,所以无需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?switch\(Q+\){Q*};?/); // switch(两个花括号都不能省,所以无需判断)
return matchRes && (endPos = startPos + matchRes[0].length);
})()) {
splitJsArr.push(jsStr.slice(startPos, endPos));
startPos = endPos;
} else {
// 其它
splitJsArr.push(...splitStatements(jsStr.slice(startPos, endPos + 1)));
startPos = endPos + 1;
}
} else if ((() => {
let matchRes =
transLayerRes.slice(startPos).match(/^(?:yiled )?(?:await )?if\(Q+\){?.*?(?:};|;|})(?:else if\(Q+\){?.*?(};|;|}))*(?:else{?.*?(};|;|}))?/) || // if...else
transPartJsStr.match(/^(?:yiled )?(?:await )?(?:async )?function\*? [^(]+?\(Q*\){Q*};?/) || // function(花括号不可省略,无需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?(?:for|while|with)\(Q+\){?.*?(?:};|;|})/) || // for / while / with(花括号可省略,需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?do{?.*?[;}]\(Q+\);?/) || // do...while(花括号可省略,需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?try{Q*}catch\(Q+\){Q*}(?:finally{Q*})?;?/) || // try...catch(两个花括号都不能省,所以无需判断)
transPartJsStr.match(/^(?:yiled )?(?:await )?switch\(Q+\){Q*};?/); // switch(两个花括号都不能省,所以无需判断)
return matchRes && (endPos = startPos + matchRes[0].length);
})()) {
splitJsArr.push(jsStr.slice(startPos, endPos));
startPos = endPos;
} else {
// 其它
splitJsArr.push(jsStr.slice(startPos, endPos + 1));
startPos = endPos + 1;
}
} while (statementType === "SWITCH_CASE" ? (endPos = transLayerRes.searchOf(/[;:}](?:case[!"'(+\-.\[{~ ]|default:)/, startPos)) !== -1 : (endPos = transLayerRes.indexOf(";", startPos)) !== -1);
if (startPos < jsStr.length) {
splitJsArr.push(...splitStatements(jsStr.slice(startPos)));
}
break;
}
default: {
throw Error(`包含无法解析的代码块类型“${statementType}”。`);
}
}
splitJsArr.type = statementType;
return splitJsArr;
}
/**
* JSON5工具
*/
const JSON5 = {
parse: function (jsonStr) {
let transRes = transStr(jsonStr);
let commentPos = Number.POSITIVE_INFINITY;
while ((commentPos === Number.POSITIVE_INFINITY || commentPos - 1 >= 0) && (commentPos = Math.max(
transRes.lastSearchOf(/\/\*C*\*\//, commentPos - 1),
transRes.lastSearchOf(/\/\/C*(?:\n?\r|\r?\n)/, commentPos - 1)
)) !== -1) {
switch (transRes[commentPos + 1]) {
case '*': {
let blockComment = transRes.slice(commentPos).match(/^\/\*C*\*\//)[0];
jsonStr = jsonStr.replaceWithStr(commentPos, commentPos + blockComment.length, "");
break;
}
case '/': {
let lineComment = transRes.slice(commentPos).match(/^\/\/C*(?:\n?\r|\r?\n)/)[0];
jsonStr = jsonStr.replaceWithStr(commentPos, commentPos + lineComment.length, "");
break;
}
default:
throw Error(`包含未知的注释类型“/${transRes[commentPos + 1]}”。`);
}
}
return JSON.parse(jsonStr);
},
stringify: JSON.stringify
};
/**
* 虚拟机执行工具
* */
let globalContext = vm.createContext();
try {
let {VM} = require("vm2");
vm2 = new VM({
allowAsync: false,
sandbox: globalContext
});
} catch (e) {
}
function virtualEval(jsStr) {
return virtualGlobalEval(jsStr);
}
function virtualGlobalEval(jsStr) {
return vm2 ? vm2.run(String(jsStr)) : vm.runInContext(jsStr, globalContext);
}
let config;
try {
config = JSON5.parse(fs.readFileSync("config.json").toString());
} catch (e) {
console.error(e);
throw Error(`未找到配置文件(config.json),请确认该文件是否存在于当前目录。`);
}
// 开始计时
let START_TIMESTAMP = Date.now(), PAUSE_TIME = 0;
// 初始化日志工具并确认文件路径
let logger = new Logger(config["logger"]);
logger.logWithoutProgress("----====* JsjiamiV6 Decryptor *====----");
let absolutePathStr = Path.resolve(config.target);
logger.logWithoutProgress(`解密文件:${absolutePathStr}`);
logger.logWithoutProgress(`输出目录:${Path.resolve("./")}`);
logger.logWithoutProgress(`模拟模块:${vm2 ? "vm2" : "vm (不安全)"}`);
if (!vm2) {
console.warn("【安全建议】当前未安装 vm2 模块,该模块支持相对安全地执行 JavaScript 代码。在安装 vm2 模块之前,解密器将使用 Node.js 内建的 vm 模块。因此,请尽量避免解密不可信的 JavaScript 文件。");
}
pause();
let js;
try {
js = fs.readFileSync(absolutePathStr).toString().trim() + ";";
} catch (e) {
console.error(e);
throw Error(`目标脚本不存在或无权访问,请检查后再试。`);
}
logger.logWithoutDetermine("净化代码");
function compressionCode(jsStr) {
let transRes = transStr(jsStr);
let commentPos = Number.POSITIVE_INFINITY;
while ((commentPos === Number.POSITIVE_INFINITY || commentPos - 1 >= 0) && (commentPos = Math.max(
transRes.lastSearchOf(/\/\*C*\*\//, commentPos - 1),
transRes.lastSearchOf(/\/\/C*(?:\n?\r|\r?\n)/, commentPos - 1)
)) !== -1) {
logger.weakUpdate();
switch (transRes[commentPos + 1]) {
case '*': {
let blockComment = transRes.slice(commentPos).match(/^\/\*C*\*\//)[0];
jsStr = jsStr.replaceWithStr(commentPos, commentPos + blockComment.length, "");
break;
}
case '/': {
let lineComment = transRes.slice(commentPos).match(/^\/\/C*(?:\n?\r|\r?\n)/)[0];
jsStr = jsStr.replaceWithStr(commentPos, commentPos + lineComment.length, "");
break;
}
default:
throw Error(`包含未知的注释类型“${transRes[commentPos + 1]}”。`);
}
}
transRes = transStr(jsStr);
let spacePos = Number.POSITIVE_INFINITY;
while ((spacePos === Number.POSITIVE_INFINITY || spacePos - 1 >= 0) && (spacePos = Math.max(
transRes.lastSearchOf(/\s/, spacePos - 1)
)) !== -1) {
logger.weakUpdate();
if (
(jsStr[spacePos - 1] == null || jsStr[spacePos - 1].match(/[{}\[\]().,+\-*\/~!%<>=&|^?:;@\s]/)) ||
(jsStr[spacePos + 1] == null || jsStr[spacePos + 1].match(/[{}\[\]().,+\-*\/~!%<>=&|^?:;@\s]/))
) {
jsStr = jsStr.replaceWithStr(spacePos, spacePos + 1, "");
}
}
return jsStr;
}
js = compressionCode(js);
fs.writeFileSync("DecryptResult0.js", js);
logger.logWithoutDetermine("解除全局加密");
const STATEMENTS_TYPE_SCHEMAS = {
signInfo: {
"Self": /^var (?:_?[0-9a-zA-Z$iO]+?='S+?',(?:_?[0-9a-zA-Z$iO]+?_=\['S+?'],)?)?_?[0-9a-zA-Z$]+=\[_?[0-9a-zA-Z$iO']+?(?:,'S+?')*?];?/
},
preprocessFunction: {
// _0x102809='po';var _0x111dc8='shift',_0x47c13d='push'
"PoShiftPushString": /_?[0-9a-zA-Z$]+='po';var _?[0-9a-zA-Z$]+='shift',_?[0-9a-zA-Z$]+='push'/,
// while(--_0x1f4621){
"DecreasingLoop": /while\(--_?[0-9a-zA-Z$]+\)\{/,
// _0x362d54=_0x5845c1,_0x2576f4=_0x2d8f05[_0x4fbc7a+'p']();
"AddPFunction": /_?[0-9a-zA-Z$]+=_?[0-9a-zA-Z$]+,_?[0-9a-zA-Z$]+=_?[0-9a-zA-Z$]+\[_?[0-9a-zA-Z$]+\+'p']\(\);/,
// ['replace'](/[zUrTestTestZTest=]/g,'')
"ReplaceBase64RegExp": /\['replace']\(\/\[[0-9a-zA-Z]*?=]\/g,''\)/,
// c['push'](c['shift']());
"PushAndShift": /_?[0-9a-zA-Z$]+\['push']\(_?[0-9a-zA-Z$]+\['shift']\(\)\)/,
// return _0x43c762(++_0x3c2786,_0x2db158)>>_0x3c2786^_0x2db158;
"ReturnWith++And>>And^": /return _?[0-9a-zA-Z$]+\(\+\+_?[0-9a-zA-Z$]+,_?[0-9a-zA-Z$]+\)>>_?[0-9a-zA-Z$]+\^_?[0-9a-zA-Z$]+/,
// var _0xeaaebc={'data':{'key':'cookie','value':'timeout'}
"CookieTimeoutDataObject": /var _?[0-9a-zA-Z$]+=\{'data':\{'key':'cookie','value':'timeout'}/,
// new RegExp\(\'\(\?\:\^\|\;\\x20\)\'\+_0x49a403\[\'replace\'\]\(\/\(\[\.\$\?\*\|\{\}\(\)\[\]\\\/\+\^\]\)\/g\,\'\$1\'\)\+\'\=\(\[\^\;\]\*\)\'\)
"SignReplaceRegExp": /new RegExp\('\(\?:\^\|;\\x20\)'\+_?[0-9a-zA-Z$]+\['replace']\(\/\(\[\.\$\?\*\|\{}\(\)\[]\\\/\+\^]\)\/g,'\$1'\)\+'=\(\[\^;]\*\)'\)/,
// new RegExp('\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*[\x27|\x22].+[\x27|\x22];?\x20*}');
"EscapedRegExp": /new RegExp\('\\x5cw+\\x20*\\x5c\(\\x5c\)\\x20\*\{\\x5cw\+\\x20\*\[\\x27|\\x22]\.\+\[\\x27|\\x22];\?\\x20*}'\);/
},
decryptor: {
/* 有预处理函数 */
// _0x542044=~~'0x'['concat'](_0x542044
"DoubleWaveConcat": /_?[0-9a-zA-Z$]+=~~'0x'\['concat']\(_?[0-9a-zA-Z$]+/,
// Function('return\x20(function()\x20'+'{}.constructor(\x22return\x20this\x22)(\x20)'+');')
"FunctionConstructorString": /Function\('return\\x20\(function\(\)\\x20'\+'\{}\.constructor\(\\x22return\\x20this\\x22\)\(\\x20\)'\+'\);'\)/,
// var _0x3ef5fb=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;
"WhatIsThis": /var _?[0-9a-zA-Z$]+=typeof window!=='undefined'\?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'\?global:this;/,
// var _0x1d2c53='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
"CharSetString": /var _?[0-9a-zA-Z$]+='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\+\/=';/,
// '%'+('00'+_0x1f82f7['charCodeAt']
"ZeroPlusCharCodeAt": /'%'\+\('00'\+_?[0-9a-zA-Z$]+\['charCodeAt']/,
// _0x53656e['charCodeAt'](_0x578a24%_0x53656e['length']))%0x100;
"CharCodeAtLength": /_?[0-9a-zA-Z$]+\['charCodeAt']\(_?[0-9a-zA-Z$]+%_?[0-9a-zA-Z$]+\['length']\)\)%0x100;/,
// +=String['fromCharCode'](
"PlusStringFromCharCode": /\+=String\['fromCharCode']\(/,
/* 无预处理函数 */
// function _0x9549(_0x52aa18,_0x1a09ad){_0x52aa18=~~'0x'['concat'](_0x52aa18['slice'](0x0));var _0x4fe032=_0x34a7[_0x52aa18];return _0x4fe032;};
"WithoutPreprocess": /(?:function _?[0-9a-zA-Z$]+|var _?[0-9a-zA-Z$]+=function)\(_?[0-9a-zA-Z$]+,_?[0-9a-zA-Z$]+\)\{_?[0-9a-zA-Z$]+=~~'0x'\['concat']\(_?[0-9a-zA-Z$]+(?:\['slice']\(0x0\))?\);var _?[0-9a-zA-Z$]+=_?[0-9a-zA-Z$]+\[_?[0-9a-zA-Z$]+];return _?[0-9a-zA-Z$]+;};/
},
verifyFunction: {
// for(_0x36eaeb=_0x39941e['shift'](_0x422e9c>>0x2);_0x36eaeb&&_0x36eaeb!==(_0x39941e['pop'](_0x422e9c>>0x3)+'')['replace'](/[ChUlbeWOEtLSnTtk=]/g,'');_0x422e9c++)
"Self": /for\(_?[0-9a-zA-Z$]+=_?[0-9a-zA-Z$]+\['shift']\(_?[0-9a-zA-Z$]+>>0x2\);_?[0-9a-zA-Z$]+&&_?[0-9a-zA-Z$]+!==\(_?[0-9a-zA-Z$]+\['pop']\(_?[0-9a-zA-Z$]+>>0x3\)\+''\)\['replace']\(\/\[[a-zA-Z]+=?]\/g,''\);_?[0-9a-zA-Z$]+\+\+\)/
}
};
const GLOBAL_DECRYPTOR_INFO = {
signInfo: {
name: null,
// _0xod / _0x / iIl / oO0 / abc
confuseType: null,
nameRegExp: null,
hasSignString: null,
hasMemberArray: null,
raw: null
},
preprocessFunction: {
raw: null
},
verifyFunction: {
raw: null
},
decryptor: {
// function / var
type: null,
name: null,
raw: null
}
};
function getStatementsType(jsArr) {
return jsArr.map(function (jsStr) {
let transRes = transStr(jsStr);
/**
* 签名信息
* @namespace signInfo
* @description 用于存放签名以及处理前的解密数据。
* 签名命名规则 _?[0-9a-zA-Z$iO]+
* 变量命名规则 _?[0-9a-zA-Z$]+
* 字符串规则 'S+'
*/
if (GLOBAL_DECRYPTOR_INFO.signInfo.raw == null) {
let schemas = STATEMENTS_TYPE_SCHEMAS.signInfo;
if (schemas["Self"].test(transRes)) {
GLOBAL_DECRYPTOR_INFO.signInfo.name = jsStr.slice(4, transRes.indexOf("=", 4));
(signName => {
if (/^_0xod[0-9a-zA-Z]$/.test(signName)) {
GLOBAL_DECRYPTOR_INFO.signInfo.confuseType = "_0xod";
GLOBAL_DECRYPTOR_INFO.signInfo.nameRegExp = `_0x[0-9a-f]+`;
} else if (/^_0x[0-9a-f]{4}$/.test(signName)) {
GLOBAL_DECRYPTOR_INFO.signInfo.confuseType = "_0x";
GLOBAL_DECRYPTOR_INFO.signInfo.nameRegExp = `_0x[0-9a-f]+`;
} else if (/^[iil]+$/.test(signName)) {
GLOBAL_DECRYPTOR_INFO.signInfo.confuseType = "iIl";
GLOBAL_DECRYPTOR_INFO.signInfo.nameRegExp = `[iIl1]+`;
} else if (/^[OO0$]+$/.test(signName)) {
GLOBAL_DECRYPTOR_INFO.signInfo.confuseType = "oO0";
GLOBAL_DECRYPTOR_INFO.signInfo.nameRegExp = `[O0Q$]+`;
} else if (/^[a-z]+$/.test(signName)) {
GLOBAL_DECRYPTOR_INFO.signInfo.confuseType = "abc";
GLOBAL_DECRYPTOR_INFO.signInfo.nameRegExp = `[a-z]+`;
} else {
throw Error(`包含未知的混淆模式“${signName}”。`);
}
})(GLOBAL_DECRYPTOR_INFO.signInfo.name);
GLOBAL_DECRYPTOR_INFO.signInfo.hasSignString = /^var _?[0-9a-zA-Z$iO]+='S+?',/.test(transRes);
GLOBAL_DECRYPTOR_INFO.signInfo.hasMemberArray = /_?[0-9a-zA-Z$iO]+_=\['S+?'],/.test(transRes);
GLOBAL_DECRYPTOR_INFO.signInfo.raw = jsStr;
return {
type: "SIGN_INFO",
content: GLOBAL_DECRYPTOR_INFO.signInfo
};
}
} else {
if (new RegExp(`^${GLOBAL_DECRYPTOR_INFO.signInfo.name.replace(/\$/g, "\\$")}='S*';?$`).test(transRes)) {
return {
type: "SIGN_REITERATE",
content: {
raw: jsStr
}
};
}
}
/**
* 预处理函数
* @namespace globalDecryptorInfo.preprocessFunction
* @description 将签名信息预处理为可用的解密数据。
* 变量命名规则 _?[0-9a-zA-Z$]+
* 字符串规则 'S+'
* */
if (GLOBAL_DECRYPTOR_INFO.signInfo.raw != null && GLOBAL_DECRYPTOR_INFO.preprocessFunction.raw == null) {
let schemas = STATEMENTS_TYPE_SCHEMAS.preprocessFunction;
if (
schemas["PoShiftPushString"].test(jsStr) +
schemas["DecreasingLoop"].test(jsStr) +
schemas["ReplaceBase64RegExp"].test(jsStr) +
schemas["PushAndShift"].test(jsStr) +
schemas["ReturnWith++And>>And^"].test(jsStr) +
schemas["CookieTimeoutDataObject"].test(jsStr) +
schemas["SignReplaceRegExp"].test(jsStr) +
schemas["EscapedRegExp"].test(jsStr) >= 3
) {
GLOBAL_DECRYPTOR_INFO.preprocessFunction.raw = jsStr;
return {
type: "PREPROCESS_FUNCTION",
content: GLOBAL_DECRYPTOR_INFO.preprocessFunction
};
}
}
/**
* 解密函数
* @namespace globalDecryptorInfo.decryptor
* @description 使用解密数据完成字符串解密。
* 变量命名规则 _?[0-9a-zA-Z$]+
* 字符串规则 'S+'
* */
if (GLOBAL_DECRYPTOR_INFO.signInfo.raw != null && GLOBAL_DECRYPTOR_INFO.decryptor.raw == null) {
let isDecryptor = false;
let schemas = STATEMENTS_TYPE_SCHEMAS.decryptor;
if (GLOBAL_DECRYPTOR_INFO.preprocessFunction.raw != null) {
// 有预处理函数
if (
schemas["DoubleWaveConcat"].test(jsStr) +
schemas["FunctionConstructorString"].test(jsStr) +
schemas["WhatIsThis"].test(jsStr) +
schemas["CharSetString"].test(jsStr) +
schemas["ZeroPlusCharCodeAt"].test(jsStr) +
schemas["CharCodeAtLength"].test(jsStr) +
schemas["PlusStringFromCharCode"].test(jsStr) >= 4
) {
isDecryptor = true;
}
} else {
// 无预处理函数
if (schemas["WithoutPreprocess"].test(jsStr)) {
isDecryptor = true;
}
}
if (isDecryptor) {
if (jsStr.startsWith("function ")) {
GLOBAL_DECRYPTOR_INFO.decryptor.type = "function";
GLOBAL_DECRYPTOR_INFO.decryptor.name = jsStr.slice(9, transRes.indexOf("("));
GLOBAL_DECRYPTOR_INFO.decryptor.raw = jsStr;
return {
type: "DECRYPTOR",
content: GLOBAL_DECRYPTOR_INFO.decryptor
};
} else if (jsStr.startsWith("var ")) {
GLOBAL_DECRYPTOR_INFO.decryptor.type = "var";
GLOBAL_DECRYPTOR_INFO.decryptor.name = jsStr.slice(4, transRes.indexOf("="));
GLOBAL_DECRYPTOR_INFO.decryptor.raw = jsStr;
return {
type: "DECRYPTOR",
content: GLOBAL_DECRYPTOR_INFO.decryptor
};
}
}
}
/**
* 验证函数
* @namespace globalDecryptorInfo.verifyFunction
* @description 验证解密数据是否被修改,并去掉头尾多余内容。
* 变量命名规则 _?[0-9a-zA-Z$]+
* 字符串规则 'S+'
* */
if (GLOBAL_DECRYPTOR_INFO.signInfo.raw != null && GLOBAL_DECRYPTOR_INFO.preprocessFunction.raw == null && GLOBAL_DECRYPTOR_INFO.decryptor.raw != null) {
let schemas = STATEMENTS_TYPE_SCHEMAS.verifyFunction;
if (schemas["Self"].test(jsStr)) {
GLOBAL_DECRYPTOR_INFO.verifyFunction.raw = jsStr;
return {
type: "VERIFY_FUNCTION",
content: GLOBAL_DECRYPTOR_INFO.verifyFunction
};
}
}
/**
* 空语句
* @namespace globalDecryptorInfo.empty
* @description 空语句。
* */
if (jsStr.trim() === "" || jsStr.trim() === ";") {
return {
type: "EMPTY",
content: {
raw: jsStr