node-automator 1.0.5 → 1.2.0

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.
Files changed (38) hide show
  1. package/commands/deobfuscate.js +15 -0
  2. package/commands/mgr.js +4 -0
  3. package/commands/register_search_install_location.js +12 -0
  4. package/commands/which.js +8 -49
  5. package/package.json +7 -2
  6. package/utils/deobfuscator/deobfuscator.js +97 -0
  7. package/utils/deobfuscator/helpers/declaration.js +57 -0
  8. package/utils/deobfuscator/helpers/expression.js +36 -0
  9. package/utils/deobfuscator/helpers/misc.js +38 -0
  10. package/utils/deobfuscator/helpers/strings/decoders/base64StringDecoder.js +50 -0
  11. package/utils/deobfuscator/helpers/strings/decoders/basicStringDecoder.js +28 -0
  12. package/utils/deobfuscator/helpers/strings/decoders/rc4StringDecoder.js +77 -0
  13. package/utils/deobfuscator/helpers/strings/decoders/stringDecoder.js +22 -0
  14. package/utils/deobfuscator/helpers/strings/rotation/rotation.js +216 -0
  15. package/utils/deobfuscator/helpers/strings/util/util.js +30 -0
  16. package/utils/deobfuscator/helpers/variable.js +140 -0
  17. package/utils/deobfuscator/index.js +25 -0
  18. package/utils/deobfuscator/transformations/config.js +43 -0
  19. package/utils/deobfuscator/transformations/controlFlow/controlFlowRecoverer.js +160 -0
  20. package/utils/deobfuscator/transformations/controlFlow/deadBranchRemover.js +120 -0
  21. package/utils/deobfuscator/transformations/controlFlow/sequenceSplitter.js +168 -0
  22. package/utils/deobfuscator/transformations/expressions/expressionSimplifier.js +288 -0
  23. package/utils/deobfuscator/transformations/objects/objectPacker.js +125 -0
  24. package/utils/deobfuscator/transformations/objects/objectSimplifier.js +71 -0
  25. package/utils/deobfuscator/transformations/objects/proxyObject.js +144 -0
  26. package/utils/deobfuscator/transformations/properties/propertySimplifier.js +70 -0
  27. package/utils/deobfuscator/transformations/proxyFunctions/proxyFunction.js +151 -0
  28. package/utils/deobfuscator/transformations/proxyFunctions/proxyFunctionInliner.js +46 -0
  29. package/utils/deobfuscator/transformations/strings/stringRevealer.js +381 -0
  30. package/utils/deobfuscator/transformations/transformation.js +28 -0
  31. package/utils/deobfuscator/transformations/variables/constantPropagator.js +73 -0
  32. package/utils/deobfuscator/transformations/variables/reassignmentRemover.js +78 -0
  33. package/utils/deobfuscator/transformations/variables/unusedVariableRemover.js +93 -0
  34. package/utils/log_tool.js +1 -1
  35. package/utils/reg_tool.js +66 -0
  36. package/utils/request_tool.js +10 -21
  37. package/utils/shell_tool.js +2 -1
  38. package/utils/which_tool.js +54 -0
@@ -0,0 +1,15 @@
1
+ const { deobfuscate } = require('../utils/deobfuscator');
2
+ const { BaseCommand } = require("./base");
3
+
4
+ class DeobfuscateCommand extends BaseCommand {
5
+ async execute() {
6
+ return deobfuscate(this.content, this.selfData.sourceType, this.selfData.config);
7
+ }
8
+ getRequireContent() {
9
+ return true;
10
+ }
11
+ }
12
+
13
+ module.exports = {
14
+ DeobfuscateCommand,
15
+ };
package/commands/mgr.js CHANGED
@@ -113,6 +113,8 @@ const { AssertCommand } = require('./assert');
113
113
  const { SvnAddCommand } = require('./svn_add');
114
114
  const { ImageCropCommand } = require('./image_crop');
115
115
  const { CursorUpCommand } = require('./cursor_up');
116
+ const { RegisterSearchInstallLocationCommand } = require('./register_search_install_location');
117
+ const { DeobfuscateCommand } = require('./deobfuscate');
116
118
 
117
119
  const globalData = {
118
120
  "executed_cfg": [], // 执行过的配置文件
@@ -467,6 +469,8 @@ function init() {
467
469
  register("svn_add", SvnAddCommand, false);
468
470
  register("image_crop", ImageCropCommand, false);
469
471
  register("cursor_up", CursorUpCommand, false);
472
+ register("register_search_install_location", RegisterSearchInstallLocationCommand, false);
473
+ register("deobfuscate", DeobfuscateCommand, false);
470
474
  }
471
475
 
472
476
  module.exports = {
@@ -0,0 +1,12 @@
1
+ const { registerSearchInstallLocation } = require('../utils/reg_tool');
2
+ const { BaseCommand } = require("./base");
3
+
4
+ class RegisterSearchInstallLocationCommand extends BaseCommand {
5
+ async execute() {
6
+ return registerSearchInstallLocation(this.selfData.target);
7
+ }
8
+ }
9
+
10
+ module.exports = {
11
+ RegisterSearchInstallLocationCommand,
12
+ };
package/commands/which.js CHANGED
@@ -1,57 +1,16 @@
1
+ const { warn } = require('../utils/log_tool');
2
+ const { registerSearchInstallLocation } = require('../utils/reg_tool');
3
+ const { which } = require('../utils/which_tool');
1
4
  const { BaseCommand } = require("./base");
2
- const { exec_shell } = require('../utils/shell_tool');
3
- const { get_fst_file } = require("../utils/file_tool");
4
- const path = require("path");
5
- const fs = require("fs");
6
- const { warn } = require("../utils/log_tool");
5
+
7
6
 
8
7
  class WhichCommand extends BaseCommand {
9
8
  async execute() {
10
- let cmd;
11
- switch (process.platform) {
12
- case "win32": {
13
- cmd = "where";
14
- break;
15
- }
16
- default: {
17
- cmd = "which";
18
- break;
19
- }
20
- }
21
-
22
- let file;
23
- let stdout = await exec_shell({
24
- cmd: `${cmd} ${this.selfData.target}`,
25
- capture_stdout: true,
26
- ignore_code: true,
27
- });
28
- if (stdout) {
29
- /** @type {string[]} */
30
- let files = stdout.split(/[\r\n]{1,2}/);
31
- files = files.filter(v => v && v.trim());
32
- // windows系统下,优先选择有 .cmd 或者 .exe
33
- if (process.platform === "win32") {
34
- let preferExts = ['.exe', '.cmd'];
35
- files.sort((a, b) => {
36
- let exta = path.extname(a);
37
- let extb = path.extname(b);
38
- if (preferExts.includes(exta)) {
39
- return -1;
40
- } else if (preferExts.includes(extb)) {
41
- return 1;
42
- }
43
- return 0;
44
- });
45
- }
46
- file = get_fst_file(files);
47
- if (file) {
48
- file = fs.realpathSync(file);
49
- }
50
- }
51
- if (!file) {
52
- warn(`未找到 ${this.selfData.target}`);
9
+ let result = await which(this.selfData.target);
10
+ if (!result) {
11
+ warn(`未找到 ${this.selfData.target}`);
53
12
  }
54
- return file;
13
+ return result;
55
14
  }
56
15
  }
57
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.0.5",
3
+ "version": "1.2.0",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -59,6 +59,11 @@
59
59
  "xmldom": "^0.4.0",
60
60
  "yaml": "^1.10.0",
61
61
  "yamljs": "^0.3.0",
62
- "yargs": "^16.2.0"
62
+ "yargs": "^16.2.0",
63
+ "@babel/generator": "^7.22.3",
64
+ "@babel/parser": "^7.22.4",
65
+ "@babel/traverse": "^7.22.4",
66
+ "@babel/types": "^7.22.4",
67
+ "@types/node": "^20.2.5"
63
68
  }
64
69
  }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Deobfuscator = void 0;
7
+ const generator_1 = __importDefault(require("@babel/generator"));
8
+ const traverse_1 = __importDefault(require("@babel/traverse"));
9
+ const config_1 = require("./transformations/config");
10
+ const objectSimplifier_1 = require("./transformations/objects/objectSimplifier");
11
+ const proxyFunctionInliner_1 = require("./transformations/proxyFunctions/proxyFunctionInliner");
12
+ const unusedVariableRemover_1 = require("./transformations/variables/unusedVariableRemover");
13
+ const constantPropagator_1 = require("./transformations/variables/constantPropagator");
14
+ const reassignmentRemover_1 = require("./transformations/variables/reassignmentRemover");
15
+ const stringRevealer_1 = require("./transformations/strings/stringRevealer");
16
+ const deadBranchRemover_1 = require("./transformations/controlFlow/deadBranchRemover");
17
+ const sequenceSplitter_1 = require("./transformations/controlFlow/sequenceSplitter");
18
+ const propertySimplifier_1 = require("./transformations/properties/propertySimplifier");
19
+ const expressionSimplifier_1 = require("./transformations/expressions/expressionSimplifier");
20
+ const controlFlowRecoverer_1 = require("./transformations/controlFlow/controlFlowRecoverer");
21
+ const objectPacker_1 = require("./transformations/objects/objectPacker");
22
+ class Deobfuscator {
23
+ /**
24
+ * Creates a new deobfuscator.
25
+ * @param ast The AST.
26
+ * @param config The config (optional).
27
+ */
28
+ constructor(ast, config = config_1.defaultConfig) {
29
+ this.transformationTypes = [
30
+ unusedVariableRemover_1.UnusedVariableRemover,
31
+ constantPropagator_1.ConstantPropgator,
32
+ reassignmentRemover_1.ReassignmentRemover,
33
+ deadBranchRemover_1.DeadBranchRemover,
34
+ objectPacker_1.ObjectPacker,
35
+ proxyFunctionInliner_1.ProxyFunctionInliner,
36
+ expressionSimplifier_1.ExpressionSimplifier,
37
+ sequenceSplitter_1.SequenceSplitter,
38
+ controlFlowRecoverer_1.ControlFlowRecoverer,
39
+ propertySimplifier_1.PropertySimplifier,
40
+ objectSimplifier_1.ObjectSimplifier,
41
+ stringRevealer_1.StringRevealer
42
+ ];
43
+ this.ast = ast;
44
+ this.config = config;
45
+ }
46
+ /**
47
+ * Executes the deobfuscator.
48
+ * @returns The simplified code.
49
+ */
50
+ execute() {
51
+ let types = this.transformationTypes.filter(t => this.config[t.properties.key].isEnabled);
52
+ let i = 0;
53
+ while (i < Deobfuscator.MAX_ITERATIONS) {
54
+ let isModified = false;
55
+ if (!this.config.silent) {
56
+ console.log(`\n[${new Date().toISOString()}]: Starting pass ${i + 1}`);
57
+ }
58
+ for (const type of types) {
59
+ const transformationConfig = this.config[type.properties.key];
60
+ const transformation = new type(this.ast, transformationConfig);
61
+ if (!this.config.silent) {
62
+ console.log(`[${new Date().toISOString()}]: Executing ${transformation.constructor.name}`);
63
+ }
64
+ let modified = false;
65
+ try {
66
+ modified = transformation.execute(console.log.bind(console, `[${transformation.constructor.name}]:`));
67
+ }
68
+ catch (err) {
69
+ console.log(`Error: ${err}`);
70
+ }
71
+ if (modified) {
72
+ isModified = true;
73
+ }
74
+ if (!this.config.silent) {
75
+ console.log(`[${new Date().toISOString()}]: Executed ${transformation.constructor.name}, modified ${modified}`);
76
+ }
77
+ if (type.properties.rebuildScopeTree) {
78
+ this.clearCache();
79
+ }
80
+ }
81
+ i++;
82
+ if (!isModified) {
83
+ break;
84
+ }
85
+ }
86
+ return (0, generator_1.default)(this.ast, { jsescOption: { minimal: true } }).code;
87
+ }
88
+ /**
89
+ * Clears the traversal cache to force the scoping to be handled
90
+ * again on the next traverse.
91
+ */
92
+ clearCache() {
93
+ traverse_1.default.cache.clear();
94
+ }
95
+ }
96
+ exports.Deobfuscator = Deobfuscator;
97
+ Deobfuscator.MAX_ITERATIONS = 50;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isDeclarationOrAssignmentExpression = exports.isDeclarationOrAssignmentStatement = void 0;
27
+ const t = __importStar(require("@babel/types"));
28
+ /**
29
+ * Checks whether a node is a variable declaration or assignment expression
30
+ * within an expression statement that is initialising a variable that
31
+ * satisfies the provided constraints.
32
+ * @param node The AST node.
33
+ * @param isId The function that determines whether the variable being declared matches.
34
+ * @param isValue The function that determines whether the value the variable is initialised to matches.
35
+ * @returns Whether.
36
+ */
37
+ function isDeclarationOrAssignmentStatement(node, isId, isValue) {
38
+ return ((t.isVariableDeclaration(node) &&
39
+ node.declarations.length == 1 &&
40
+ isId(node.declarations[0].id) &&
41
+ node.declarations[0].init &&
42
+ isValue(node.declarations[0].init)) ||
43
+ (t.isExpressionStatement(node) &&
44
+ t.isAssignmentExpression(node.expression) &&
45
+ isId(node.expression.left) &&
46
+ isValue(node.expression.right)));
47
+ }
48
+ exports.isDeclarationOrAssignmentStatement = isDeclarationOrAssignmentStatement;
49
+ function isDeclarationOrAssignmentExpression(node, isId, isValue) {
50
+ return ((t.isVariableDeclaration(node) &&
51
+ node.declarations.length == 1 &&
52
+ isId(node.declarations[0].id) &&
53
+ node.declarations[0].init &&
54
+ isValue(node.declarations[0].init)) ||
55
+ (t.isAssignmentExpression(node) && isId(node.left) && isValue(node.right)));
56
+ }
57
+ exports.isDeclarationOrAssignmentExpression = isDeclarationOrAssignmentExpression;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isNegativeNumericLiteral = void 0;
27
+ const t = __importStar(require("@babel/types"));
28
+ /**
29
+ * Returns whether a node is a unary expression that represents a negative number.
30
+ * @param node The AST node.
31
+ * @returns Whether.
32
+ */
33
+ function isNegativeNumericLiteral(node) {
34
+ return t.isUnaryExpression(node) && node.operator == '-' && t.isNumericLiteral(node.argument);
35
+ }
36
+ exports.isNegativeNumericLiteral = isNegativeNumericLiteral;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getProperty = exports.setProperty = exports.copyExpression = void 0;
7
+ const generator_1 = __importDefault(require("@babel/generator"));
8
+ /**
9
+ * Copies an expression.
10
+ * @param expression The expression.
11
+ * @returns The copy.
12
+ */
13
+ const copyExpression = (expression) => {
14
+ const parseExpression = globalThis.parser
15
+ .parseExpression;
16
+ return parseExpression((0, generator_1.default)(expression).code);
17
+ };
18
+ exports.copyExpression = copyExpression;
19
+ /**
20
+ * Sets a property on an object.
21
+ * @param obj The object.
22
+ * @param property The property key.
23
+ * @param value The value.
24
+ */
25
+ const setProperty = (obj, property, value) => {
26
+ obj.property = value;
27
+ };
28
+ exports.setProperty = setProperty;
29
+ /**
30
+ * Gets the value of a property on an object.
31
+ * @param obj The object.
32
+ * @param property The property key.
33
+ * @returns
34
+ */
35
+ const getProperty = (obj, property) => {
36
+ return obj.property;
37
+ };
38
+ exports.getProperty = getProperty;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Base64StringDecoder = void 0;
4
+ const util_1 = require("../util/util");
5
+ const stringDecoder_1 = require("./stringDecoder");
6
+ class Base64StringDecoder extends stringDecoder_1.StringDecoder {
7
+ /**
8
+ * Creates a new base 64 string decoder.
9
+ * @param stringArray The string array.
10
+ * @param indexOffset The offset used when accessing elements by index.
11
+ */
12
+ constructor(stringArray, indexOffset) {
13
+ super(stringArray, indexOffset);
14
+ this.stringCache = new Map();
15
+ }
16
+ /**
17
+ * Returns the type of the decoder.
18
+ */
19
+ get type() {
20
+ return stringDecoder_1.DecoderType.BASE_64;
21
+ }
22
+ /**
23
+ * Decodes a string.
24
+ * @param index The index.
25
+ * @returns The string.
26
+ */
27
+ getString(index) {
28
+ const cacheKey = index + this.stringArray[0];
29
+ if (this.stringCache.has(cacheKey)) {
30
+ return this.stringCache.get(cacheKey);
31
+ }
32
+ const encoded = this.stringArray[index + this.indexOffset];
33
+ const str = (0, util_1.base64Transform)(encoded);
34
+ this.stringCache.set(cacheKey, str);
35
+ return str;
36
+ }
37
+ /**
38
+ * Decodes a string for the rotate string call.
39
+ * @param index The index.
40
+ * @returns THe string.
41
+ */
42
+ getStringForRotation(index) {
43
+ if (this.isFirstCall) {
44
+ this.isFirstCall = false;
45
+ throw new Error();
46
+ }
47
+ return this.getString(index);
48
+ }
49
+ }
50
+ exports.Base64StringDecoder = Base64StringDecoder;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BasicStringDecoder = void 0;
4
+ const stringDecoder_1 = require("./stringDecoder");
5
+ class BasicStringDecoder extends stringDecoder_1.StringDecoder {
6
+ /**
7
+ * Returns the type of the decoder.
8
+ */
9
+ get type() {
10
+ return stringDecoder_1.DecoderType.BASIC;
11
+ }
12
+ /**
13
+ * Decodes a string.
14
+ * @param index The index.
15
+ */
16
+ getString(index) {
17
+ return this.stringArray[index + this.indexOffset];
18
+ }
19
+ /**
20
+ * Decodes a string for the rotate string call.
21
+ * @param index The index.
22
+ * @returns THe string.
23
+ */
24
+ getStringForRotation(index) {
25
+ return this.getString(index);
26
+ }
27
+ }
28
+ exports.BasicStringDecoder = BasicStringDecoder;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rc4StringDecoder = void 0;
4
+ const util_1 = require("../util/util");
5
+ const stringDecoder_1 = require("./stringDecoder");
6
+ class Rc4StringDecoder extends stringDecoder_1.StringDecoder {
7
+ /**
8
+ * Creates a new RC4 string decoder.
9
+ * @param stringArray The string array.
10
+ * @param indexOffset The offset used when accessing elements by index.
11
+ */
12
+ constructor(stringArray, indexOffset) {
13
+ super(stringArray, indexOffset);
14
+ this.stringCache = new Map();
15
+ }
16
+ /**
17
+ * Returns the type of the decoder.
18
+ */
19
+ get type() {
20
+ return stringDecoder_1.DecoderType.RC4;
21
+ }
22
+ /**
23
+ * Decodes a string.
24
+ * @param index The index.
25
+ */
26
+ getString(index, key) {
27
+ const cacheKey = index + this.stringArray[0];
28
+ if (this.stringCache.has(cacheKey)) {
29
+ return this.stringCache.get(cacheKey);
30
+ }
31
+ const encoded = this.stringArray[index + this.indexOffset];
32
+ const str = this.rc4Decode(encoded, key);
33
+ this.stringCache.set(cacheKey, str);
34
+ return str;
35
+ }
36
+ /**
37
+ * Decodes a string for the rotate string call.
38
+ * @param index The index.
39
+ * @returns THe string.
40
+ */
41
+ getStringForRotation(index, key) {
42
+ if (this.isFirstCall) {
43
+ this.isFirstCall = false;
44
+ throw new Error();
45
+ }
46
+ return this.getString(index, key);
47
+ }
48
+ /**
49
+ * Decodes a string encoded with RC4.
50
+ * @param str The RC4 encoded string.
51
+ * @param key The key.
52
+ * @returns The decoded string.
53
+ */
54
+ rc4Decode(str, key) {
55
+ const s = [];
56
+ let j = 0;
57
+ let decoded = '';
58
+ str = (0, util_1.base64Transform)(str);
59
+ for (var i = 0; i < 256; i++) {
60
+ s[i] = i;
61
+ }
62
+ for (var i = 0; i < 256; i++) {
63
+ j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;
64
+ [s[i], s[j]] = [s[j], s[i]];
65
+ }
66
+ i = 0;
67
+ j = 0;
68
+ for (let y = 0; y < str.length; y++) {
69
+ i = (i + 1) % 256;
70
+ j = (j + s[i]) % 256;
71
+ [s[i], s[j]] = [s[j], s[i]];
72
+ decoded += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
73
+ }
74
+ return decoded;
75
+ }
76
+ }
77
+ exports.Rc4StringDecoder = Rc4StringDecoder;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DecoderType = exports.StringDecoder = void 0;
4
+ class StringDecoder {
5
+ /**
6
+ * Creates a new string decoder.
7
+ * @param stringArray The string array.
8
+ * @param indexOffset The offset used when accessing elements by index.
9
+ */
10
+ constructor(stringArray, indexOffset) {
11
+ this.stringArray = stringArray;
12
+ this.indexOffset = indexOffset;
13
+ this.isFirstCall = true;
14
+ }
15
+ }
16
+ exports.StringDecoder = StringDecoder;
17
+ var DecoderType;
18
+ (function (DecoderType) {
19
+ DecoderType["BASIC"] = "BASIC";
20
+ DecoderType["BASE_64"] = "BASE_64";
21
+ DecoderType["RC4"] = "RC4";
22
+ })(DecoderType || (exports.DecoderType = DecoderType = {}));