diff --git a/dist/index.js b/dist/index.js index e2278688..c7739484 100644 --- a/dist/index.js +++ b/dist/index.js @@ -225,10 +225,12 @@ var Utils = function () { } return result; }; - var customPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - var randomString = Utils.randomGenerator.string({ length: length, pool: customPool }), - randomStringDiff = randomString.replace(new RegExp('[' + escapeRegExp(str) + ']', 'g'), ''), - randomStringDiffArray = randomStringDiff.split(''); + var randomString = Utils.randomGenerator.string({ + length: length, + pool: Utils.randomGeneratorPool + }); + var randomStringDiff = randomString.replace(new RegExp('[' + escapeRegExp(str) + ']', 'g'), ''); + var randomStringDiffArray = randomStringDiff.split(''); Utils.randomGenerator.shuffle(randomStringDiffArray); randomStringDiff = randomStringDiffArray.join(''); return [randomMerge(str, randomStringDiff), randomStringDiff]; @@ -340,6 +342,7 @@ var Utils = function () { return Utils; }(); +Utils.randomGeneratorPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; Utils.randomGenerator = new chance_1.Chance(); exports.Utils = Utils; @@ -1222,7 +1225,7 @@ var StringLiteralReplacer = function (_AbstractReplacer_1$A) { value: function replaceStringLiteralWithStringArrayCall(value) { var stringArrayNode = this.nodes.get('stringArrayNode'); if (!stringArrayNode) { - throw new ReferenceError('`stringArrayNode` node is not found in Map with custom node.'); + throw new ReferenceError('`stringArrayNode` node is not found in Map with custom nodes.'); } var rc4Key = ''; switch (this.options.stringArrayEncoding) { @@ -3120,11 +3123,11 @@ var AbstractControlFlowReplacer = function () { } _createClass(AbstractControlFlowReplacer, null, [{ - key: 'getStorageKey', + key: "getStorageKey", value: function getStorageKey() { return Utils_1.Utils.getRandomGenerator().string({ length: 3, - pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + pool: Utils_1.Utils.randomGeneratorPool }); } }]); diff --git a/src/Utils.ts b/src/Utils.ts index 150bf94f..bf3174bd 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -5,6 +5,11 @@ import { JSFuck } from './enums/JSFuck'; const isEqual = require('is-equal'); export class Utils { + /** + * @type {string} + */ + public static randomGeneratorPool: string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + /** * @type {Chance.Chance | Chance.SeededChance} */ @@ -180,13 +185,16 @@ export class Utils { return result; }; - const customPool: string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + const randomString: string = Utils.randomGenerator.string({ + length: length, + pool: Utils.randomGeneratorPool + }); - let randomString: string = Utils.randomGenerator.string({length: length, pool: customPool}), - randomStringDiff: string = randomString.replace( - new RegExp('[' + escapeRegExp(str) + ']', 'g'), - ''), - randomStringDiffArray: string[] = randomStringDiff.split(''); + let randomStringDiff: string = randomString.replace( + new RegExp('[' + escapeRegExp(str) + ']', 'g'), + ''); + + const randomStringDiffArray: string[] = randomStringDiff.split(''); Utils.randomGenerator.shuffle(randomStringDiffArray); randomStringDiff = randomStringDiffArray.join(''); diff --git a/src/interfaces/IStorage.d.ts b/src/interfaces/IStorage.d.ts index 448deb71..036c8545 100644 --- a/src/interfaces/IStorage.d.ts +++ b/src/interfaces/IStorage.d.ts @@ -2,7 +2,7 @@ export interface IStorage { get (key: string | number): T; getKeyOf (value: T): string | number | null; getLength (): number; - getStorage (): Map | T[]; + getStorage (): any; set (key: string | number | null, value: T): void; toString (): string; } diff --git a/src/node-transformers/node-control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts b/src/node-transformers/node-control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts index 8c23cb63..1b01e146 100644 --- a/src/node-transformers/node-control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts +++ b/src/node-transformers/node-control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.ts @@ -33,7 +33,7 @@ export abstract class AbstractControlFlowReplacer implements IControlFlowReplace protected static getStorageKey (): string { return Utils.getRandomGenerator().string({ length: 3, - pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + pool: Utils.randomGeneratorPool }); } diff --git a/src/node-transformers/node-obfuscators/replacers/StringLiteralReplacer.ts b/src/node-transformers/node-obfuscators/replacers/StringLiteralReplacer.ts index fb4f438b..56b3558d 100644 --- a/src/node-transformers/node-obfuscators/replacers/StringLiteralReplacer.ts +++ b/src/node-transformers/node-obfuscators/replacers/StringLiteralReplacer.ts @@ -45,7 +45,7 @@ export class StringLiteralReplacer extends AbstractReplacer { const stringArrayNode: ICustomNodeWithData = this.nodes.get('stringArrayNode'); if (!stringArrayNode) { - throw new ReferenceError('`stringArrayNode` node is not found in Map with custom node.'); + throw new ReferenceError('`stringArrayNode` node is not found in Map with custom nodes.'); } let rc4Key: string = '';