node-automator 1.4.11 → 1.4.13
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/commands/mgr.js +9 -7
- package/commands/obfuscate.js +79 -0
- package/package.json +2 -1
- package/utils/selection_tool.js +1 -1
package/commands/mgr.js
CHANGED
|
@@ -119,6 +119,7 @@ const { AliOssCommand } = require('./ali_oss');
|
|
|
119
119
|
const { BackupCommand } = require('./backup');
|
|
120
120
|
const { CompressCommand } = require('./compress');
|
|
121
121
|
const { Word2txtCommand } = require('./word2txt');
|
|
122
|
+
const { ObfuscateCommand } = require('./obfuscate');
|
|
122
123
|
|
|
123
124
|
const globalData = {
|
|
124
125
|
"executed_cfg": [], // 执行过的配置文件
|
|
@@ -135,7 +136,7 @@ const commandMap = {};
|
|
|
135
136
|
*/
|
|
136
137
|
const commandPool = {};
|
|
137
138
|
const showLogs = {
|
|
138
|
-
|
|
139
|
+
|
|
139
140
|
};
|
|
140
141
|
|
|
141
142
|
|
|
@@ -209,7 +210,7 @@ async function execSingle(commandCfg) {
|
|
|
209
210
|
let totalRetryTimes = commandCfg.retry || 0;
|
|
210
211
|
let retryTimes = 0;
|
|
211
212
|
let ret = null;
|
|
212
|
-
while(true) {
|
|
213
|
+
while (true) {
|
|
213
214
|
if (retryTimes > 0) { // 仅在重试时,重置错误
|
|
214
215
|
setLastError(null);
|
|
215
216
|
}
|
|
@@ -294,9 +295,9 @@ async function _execSingle(commandCfg, depth, progressData) {
|
|
|
294
295
|
return;
|
|
295
296
|
}
|
|
296
297
|
if (commandCfg.show_progress /* !== false */ && progressData && shareData.$COMPRESS_PROGERSS <= 0) {
|
|
297
|
-
progress(progressData.curr, progressData.total, {depth: depth, desc: `> ${commandCfg.title || commandCfg.type}`, color: "white"});
|
|
298
|
+
progress(progressData.curr, progressData.total, { depth: depth, desc: `> ${commandCfg.title || commandCfg.type}`, color: "white" });
|
|
298
299
|
}
|
|
299
|
-
|
|
300
|
+
|
|
300
301
|
if (showLogs[commandCfg.type]) {
|
|
301
302
|
log("");
|
|
302
303
|
}
|
|
@@ -337,14 +338,14 @@ async function _execSingle(commandCfg, depth, progressData) {
|
|
|
337
338
|
is_first = false;
|
|
338
339
|
} while (!ret && commandCfg.required);
|
|
339
340
|
recyleCommand(command);
|
|
340
|
-
|
|
341
|
+
|
|
341
342
|
if (!getLastError()) {
|
|
342
343
|
if (commandCfg.show_progress /* !== false */ && progressData && shareData.$COMPRESS_PROGERSS <= 0) {
|
|
343
|
-
progress(progressData.curr + 1, progressData.total, {depth: depth, desc: `✔ ${commandCfg.title || commandCfg.type}`['cyan']});
|
|
344
|
+
progress(progressData.curr + 1, progressData.total, { depth: depth, desc: `✔ ${commandCfg.title || commandCfg.type}`['cyan'] });
|
|
344
345
|
}
|
|
345
346
|
} else {
|
|
346
347
|
if (commandCfg.show_progress /* !== false */ && progressData && shareData.$COMPRESS_PROGERSS <= 0) {
|
|
347
|
-
progress(progressData.curr + 1, progressData.total, {depth: depth, desc: `✖ ${commandCfg.title || commandCfg.type}`['red']});
|
|
348
|
+
progress(progressData.curr + 1, progressData.total, { depth: depth, desc: `✖ ${commandCfg.title || commandCfg.type}`['red'] });
|
|
348
349
|
}
|
|
349
350
|
if (commandCfg.ignore_error) {
|
|
350
351
|
resetError(commandCfg.ignore_error);
|
|
@@ -481,6 +482,7 @@ function init() {
|
|
|
481
482
|
register("backup", BackupCommand, false);
|
|
482
483
|
register("compress", CompressCommand, false);
|
|
483
484
|
register("word2txt", Word2txtCommand, false);
|
|
485
|
+
register("obfuscate", ObfuscateCommand, false);
|
|
484
486
|
}
|
|
485
487
|
|
|
486
488
|
module.exports = {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const { BaseCommand } = require("./base");
|
|
2
|
+
const JavaScriptObfuscator = require('javascript-obfuscator');
|
|
3
|
+
|
|
4
|
+
class ObfuscateCommand extends BaseCommand {
|
|
5
|
+
async execute() {
|
|
6
|
+
const PRESET_OPTIONS = {
|
|
7
|
+
"optionsPreset": "default",
|
|
8
|
+
"compact": true,
|
|
9
|
+
"selfDefending": false,
|
|
10
|
+
"disableConsoleOutput": false,
|
|
11
|
+
"debugProtection": false,
|
|
12
|
+
"debugProtectionInterval": 0,
|
|
13
|
+
"splitStrings": false,
|
|
14
|
+
"splitStringsChunkLength": 10,
|
|
15
|
+
"splitStringsChunkLengthEnabled": false,
|
|
16
|
+
"stringArray": true,
|
|
17
|
+
"stringArrayRotate": true,
|
|
18
|
+
"stringArrayRotateEnabled": true,
|
|
19
|
+
"stringArrayShuffle": true,
|
|
20
|
+
"stringArrayShuffleEnabled": true,
|
|
21
|
+
"simplify": true,
|
|
22
|
+
"stringArrayThreshold": 0.75,
|
|
23
|
+
"stringArrayThresholdEnabled": true,
|
|
24
|
+
"stringArrayIndexesType": [
|
|
25
|
+
"hexadecimal-number"
|
|
26
|
+
],
|
|
27
|
+
"stringArrayIndexShift": true,
|
|
28
|
+
"stringArrayCallsTransform": false,
|
|
29
|
+
"stringArrayCallsTransformThreshold": 0.5,
|
|
30
|
+
"stringArrayEncoding": [
|
|
31
|
+
"none"
|
|
32
|
+
],
|
|
33
|
+
"stringArrayEncodingEnabled": true,
|
|
34
|
+
"stringArrayWrappersCount": 1,
|
|
35
|
+
"stringArrayWrappersChainedCalls": true,
|
|
36
|
+
"stringArrayWrappersParametersMaxCount": 2,
|
|
37
|
+
"stringArrayWrappersType": "variable",
|
|
38
|
+
"numbersToExpressions": false,
|
|
39
|
+
"sourceMap": false,
|
|
40
|
+
"sourceMapBaseUrl": "",
|
|
41
|
+
"sourceMapFileName": "",
|
|
42
|
+
"domainLock": [],
|
|
43
|
+
"domainLockRedirectUrl": "about:blank",
|
|
44
|
+
"domainLockEnabled": true,
|
|
45
|
+
"forceTransformStrings": [],
|
|
46
|
+
"reservedNames": [],
|
|
47
|
+
"reservedStrings": [],
|
|
48
|
+
"seed": 0,
|
|
49
|
+
"controlFlowFlatteningThreshold": 0.75,
|
|
50
|
+
"controlFlowFlattening": false,
|
|
51
|
+
"deadCodeInjectionThreshold": 0.4,
|
|
52
|
+
"deadCodeInjection": false,
|
|
53
|
+
"unicodeEscapeSequence": false,
|
|
54
|
+
"renameGlobals": false,
|
|
55
|
+
"renameProperties": false,
|
|
56
|
+
"renamePropertiesMode": "safe",
|
|
57
|
+
"target": "browser",
|
|
58
|
+
"identifierNamesGenerator": "hexadecimal",
|
|
59
|
+
"identifiersDictionary": [],
|
|
60
|
+
"identifiersPrefix": "",
|
|
61
|
+
"transformObjectKeys": false,
|
|
62
|
+
"ignoreImports": false
|
|
63
|
+
};
|
|
64
|
+
const options = {
|
|
65
|
+
...PRESET_OPTIONS,
|
|
66
|
+
...this.selfData.options,
|
|
67
|
+
}
|
|
68
|
+
const result = JavaScriptObfuscator.obfuscate(this.content, options);
|
|
69
|
+
return result.getObfuscatedCode();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getRequireContent() {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = {
|
|
78
|
+
ObfuscateCommand,
|
|
79
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-automator",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.13",
|
|
4
4
|
"description": "Execute automation with yaml configuration(compatible with json)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"html-to-text": "^8.2.0",
|
|
35
35
|
"iconv-lite": "^0.6.2",
|
|
36
36
|
"image-size": "^1.0.0",
|
|
37
|
+
"javascript-obfuscator": "^4.1.1",
|
|
37
38
|
"jimp": "^0.22.12",
|
|
38
39
|
"json-stable-stringify": "^1.0.1",
|
|
39
40
|
"jwt-js": "^0.5.0",
|
package/utils/selection_tool.js
CHANGED
|
@@ -341,7 +341,7 @@ async function multiSelect(content, data) {
|
|
|
341
341
|
const options = content;
|
|
342
342
|
const viewOptions = optionKeys.map((optionKey, index) => {
|
|
343
343
|
let optionValue = options[optionKey];
|
|
344
|
-
const showKey = isContentArray ? (
|
|
344
|
+
const showKey = isContentArray ? (+optionKey + 1) : optionKey;
|
|
345
345
|
if (data.preview_handler) {
|
|
346
346
|
return {
|
|
347
347
|
showKey,
|