|
@@ -2,6 +2,7 @@ import * as esprima from 'esprima';
|
|
|
import { JavaScriptObfuscator } from '../../JavaScriptObfuscator';
|
|
|
|
|
|
import { INode } from "../../interfaces/nodes/INode";
|
|
|
+import { IOptions } from "../../interfaces/IOptions";
|
|
|
|
|
|
import { TBlockScopeNode } from "../../types/TBlockScopeNode";
|
|
|
|
|
@@ -32,12 +33,14 @@ export class UnicodeArrayDecodeNode extends Node {
|
|
|
/**
|
|
|
* @param unicodeArrayName
|
|
|
* @param unicodeArray
|
|
|
+ * @param options
|
|
|
*/
|
|
|
constructor (
|
|
|
unicodeArrayName: string,
|
|
|
- unicodeArray: string[]
|
|
|
+ unicodeArray: string[],
|
|
|
+ options: IOptions = {}
|
|
|
) {
|
|
|
- super();
|
|
|
+ super(options);
|
|
|
|
|
|
this.unicodeArrayName = unicodeArrayName;
|
|
|
this.unicodeArray = unicodeArray;
|
|
@@ -60,6 +63,8 @@ export class UnicodeArrayDecodeNode extends Node {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ this.updateNode();
|
|
|
+
|
|
|
return super.getNode();
|
|
|
}
|
|
|
|
|
@@ -67,10 +72,29 @@ export class UnicodeArrayDecodeNode extends Node {
|
|
|
* @returns {INode}
|
|
|
*/
|
|
|
protected getNodeStructure (): INode {
|
|
|
- const indexVariableName: string = Utils.getRandomVariableName(),
|
|
|
+ const environmentName: string = Utils.getRandomVariableName(),
|
|
|
+ indexVariableName: string = Utils.getRandomVariableName(),
|
|
|
tempArrayName: string = Utils.getRandomVariableName();
|
|
|
|
|
|
- let node: INode = esprima.parse(`
|
|
|
+ let node: INode,
|
|
|
+ selfDefendingCode: string = '';
|
|
|
+
|
|
|
+ if (this.options['selfDefending']) {
|
|
|
+ selfDefendingCode = `
|
|
|
+ var ${environmentName} = function(){return ${Utils.stringToUnicode('dev')};};
|
|
|
+
|
|
|
+ if (
|
|
|
+ ${indexVariableName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 &&
|
|
|
+ /\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/.test(
|
|
|
+ ${environmentName}.toString()
|
|
|
+ ) !== true && ${indexVariableName}++
|
|
|
+ ) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ `;
|
|
|
+ }
|
|
|
+
|
|
|
+ node = esprima.parse(`
|
|
|
(function () {
|
|
|
${JavaScriptObfuscator.obfuscate(`
|
|
|
(function () {
|
|
@@ -96,6 +120,8 @@ export class UnicodeArrayDecodeNode extends Node {
|
|
|
var ${tempArrayName} = [];
|
|
|
|
|
|
for (var ${indexVariableName} in ${this.unicodeArrayName}) {
|
|
|
+ ${selfDefendingCode}
|
|
|
+
|
|
|
${tempArrayName}[${Utils.stringToUnicode('push')}](decodeURI(atob(${this.unicodeArrayName}[${indexVariableName}])));
|
|
|
}
|
|
|
|