formatUnicorn templates

This commit is contained in:
sanex3339
2016-07-20 15:49:08 +03:00
parent 4339361cd4
commit 70184ce3da
20 changed files with 257 additions and 227 deletions
@@ -1,3 +1,5 @@
import 'format-unicorn';
import { INode } from "../../interfaces/nodes/INode";
import { IOptions } from "../../interfaces/IOptions";
@@ -43,7 +45,9 @@ export class DebugProtectionFunctionCallNode extends Node {
*/
protected getNodeStructure (): INode {
return NodeUtils.convertCodeToStructure(
DebugProtectionFunctionCallTemplate(this.debugProtectionFunctionName)
DebugProtectionFunctionCallTemplate().formatUnicorn({
debugProtectionFunctionName: this.debugProtectionFunctionName
})
);
}
}
@@ -1,3 +1,5 @@
import 'format-unicorn';
import { INode } from "../../interfaces/nodes/INode";
import { IOptions } from "../../interfaces/IOptions";
@@ -43,7 +45,9 @@ export class DebugProtectionFunctionIntervalNode extends Node {
*/
protected getNodeStructure (): INode {
return NodeUtils.convertCodeToStructure(
DebugProtectionFunctionIntervalTemplate(this.debugProtectionFunctionName)
DebugProtectionFunctionIntervalTemplate().formatUnicorn({
debugProtectionFunctionName: this.debugProtectionFunctionName
})
);
}
}
@@ -1,3 +1,5 @@
import 'format-unicorn';
import { INode } from "../../interfaces/nodes/INode";
import { IOptions } from "../../interfaces/IOptions";
@@ -59,7 +61,9 @@ export class DebugProtectionFunctionNode extends Node {
*/
protected getNodeStructure (): INode {
return NodeUtils.convertCodeToStructure(
DebugProtectionFunctionTemplate(this.debugProtectionFunctionName)
DebugProtectionFunctionTemplate().formatUnicorn({
debugProtectionFunctionName: this.debugProtectionFunctionName
})
);
}
}
@@ -41,7 +41,10 @@ export class SelfDefendingUnicodeNode extends Node {
*/
protected getNodeStructure (): INode {
return NodeUtils.convertCodeToStructure(
JavaScriptObfuscator.obfuscate(SelfDefendingTemplate(), NO_CUSTOM_NODES_PRESET).getObfuscatedCode()
JavaScriptObfuscator.obfuscate(
SelfDefendingTemplate(),
NO_CUSTOM_NODES_PRESET
).getObfuscatedCode()
);
}
}
@@ -1,3 +1,5 @@
import 'format-unicorn';
import { INode } from "../../interfaces/nodes/INode";
import { IOptions } from "../../interfaces/IOptions";
@@ -9,6 +11,7 @@ import { UnicodeArrayCallsWrapperTemplate } from "../../templates/custom-nodes/u
import { Node } from '../Node';
import { NodeUtils } from "../../NodeUtils";
import { Utils } from "../../Utils";
export class UnicodeArrayCallsWrapper extends Node {
/**
@@ -79,8 +82,14 @@ export class UnicodeArrayCallsWrapper extends Node {
* @returns {INode}
*/
protected getNodeStructure (): INode {
let keyName: string = Utils.getRandomVariableName();
return NodeUtils.convertCodeToStructure(
UnicodeArrayCallsWrapperTemplate(this.unicodeArrayCallsWrapperName, this.unicodeArrayName)
UnicodeArrayCallsWrapperTemplate().formatUnicorn({
keyName: keyName,
unicodeArrayCallsWrapperName: this.unicodeArrayCallsWrapperName,
unicodeArrayName: this.unicodeArrayName
})
);
}
}
@@ -1,3 +1,4 @@
import 'format-unicorn';
import { INode } from "../../interfaces/nodes/INode";
import { IOptions } from "../../interfaces/IOptions";
@@ -6,12 +7,15 @@ import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement";
import { AppendState } from "../../enums/AppendState";
import { NO_CUSTOM_NODES_PRESET } from "../../preset-options/NoCustomNodesPreset";
import { AtobTemplate } from "../../templates/custom-nodes/AtobTemplate";
import { SelfDefendingTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/SelfDefendingTemplate";
import { UnicodeArrayDecodeTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-decode-node/UnicodeArrayDecodeTemplate";
import { JavaScriptObfuscator } from '../../JavaScriptObfuscator';
import { Node } from '../Node';
import { NodeUtils } from "../../NodeUtils";
import { Utils } from "../../Utils";
export class UnicodeArrayDecodeNode extends Node {
/**
@@ -67,18 +71,29 @@ export class UnicodeArrayDecodeNode extends Node {
* @returns {INode}
*/
protected getNodeStructure (): INode {
const forLoopFunctionName: string = Utils.getRandomVariableName();
const forLoopFunctionName: string = 'forLoopFunc';
let code: string = '';
let code: string;
if (this.options.selfDefending) {
code = SelfDefendingTemplate(this.unicodeArrayName, forLoopFunctionName);
code = SelfDefendingTemplate().formatUnicorn({
forLoopFunctionName,
unicodeArrayName: this.unicodeArrayName
});
} else {
code = `${forLoopFunctionName}();`;
}
return NodeUtils.convertCodeToStructure(
UnicodeArrayDecodeTemplate(code, this.unicodeArrayName, forLoopFunctionName)
JavaScriptObfuscator.obfuscate(
UnicodeArrayDecodeTemplate().formatUnicorn({
atobPolyfill: AtobTemplate(),
code,
forLoopFunctionName,
unicodeArrayName: this.unicodeArrayName
}),
NO_CUSTOM_NODES_PRESET
).getObfuscatedCode()
);
}
}
@@ -1,3 +1,5 @@
import 'format-unicorn';
import { INode } from '../../interfaces/nodes/INode';
import { IOptions } from "../../interfaces/IOptions";
@@ -5,10 +7,11 @@ import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement";
import { AppendState } from '../../enums/AppendState';
import { UnicodeArrayTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-node/UnicodeArrayTemplate";
import { Node } from '../Node';
import { NodeUtils } from "../../NodeUtils";
import { Utils } from '../../Utils';
import {UnicodeArrayTemplate} from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-node/UnicodeArrayTemplate";
export class UnicodeArrayNode extends Node {
/**
@@ -98,7 +101,10 @@ export class UnicodeArrayNode extends Node {
*/
protected getNodeStructure (): INode {
return NodeUtils.convertCodeToStructure(
UnicodeArrayTemplate(this.unicodeArrayName, this.unicodeArray.join(','))
UnicodeArrayTemplate().formatUnicorn({
unicodeArrayName: this.unicodeArrayName,
unicodeArray: this.unicodeArray.join(',')
})
);
}
}
@@ -1,3 +1,5 @@
import 'format-unicorn';
import { INode } from "../../interfaces/nodes/INode";
import { IOptions } from "../../interfaces/IOptions";
@@ -82,22 +84,25 @@ export class UnicodeArrayRotateFunctionNode extends Node {
whileFunctionName: string = Utils.getRandomVariableName();
if (this.options.selfDefending) {
code = JavaScriptObfuscator.obfuscate(
SelfDefendingTemplate(whileFunctionName, timesName),
NO_CUSTOM_NODES_PRESET
).getObfuscatedCode();
code = SelfDefendingTemplate().formatUnicorn({
timesName,
whileFunctionName
});
} else {
code = `${whileFunctionName}(++${timesName})`;
}
return NodeUtils.convertCodeToStructure(
UnicodeArrayRotateFunctionTemplate(
code,
this.unicodeArrayName,
this.unicodeArrayRotateValue,
whileFunctionName,
timesName
)
JavaScriptObfuscator.obfuscate(
UnicodeArrayRotateFunctionTemplate().formatUnicorn({
code,
timesName,
unicodeArrayName: this.unicodeArrayName,
unicodeArrayRotateValue: Utils.decToHex(this.unicodeArrayRotateValue),
whileFunctionName
}),
NO_CUSTOM_NODES_PRESET
).getObfuscatedCode()
);
}
}
@@ -1,9 +1,6 @@
/**
* @param debugProtectionFunctionName
* @returns {string}
*/
export function DebugProtectionFunctionCallTemplate (debugProtectionFunctionName: string): string {
return `
${debugProtectionFunctionName}();
`;
export function DebugProtectionFunctionCallTemplate (): string {
return `{debugProtectionFunctionName}();`;
}
@@ -1,11 +1,10 @@
/**
* @param debugProtectionFunctionName
* @returns {string}
*/
export function DebugProtectionFunctionIntervalTemplate (debugProtectionFunctionName: string): string {
export function DebugProtectionFunctionIntervalTemplate (): string {
return `
setInterval(function () {
${debugProtectionFunctionName}();
{debugProtectionFunctionName}();
}, 4000);
`;
}
@@ -1,12 +1,11 @@
import { Utils } from "../../../../Utils";
/**
* @param debugProtectionFunctionName
* @returns {string}
*/
export function DebugProtectionFunctionTemplate (debugProtectionFunctionName: string): string {
export function DebugProtectionFunctionTemplate (): string {
return `
var ${debugProtectionFunctionName} = function () {
var {debugProtectionFunctionName} = function () {
function debuggerProtection (counter) {
if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {
(function () {}.constructor('debugger')());
@@ -1,16 +1,14 @@
import { JSFuck } from "../../../../enums/JSFuck";
import { Utils } from "../../../../Utils";
export function SelfDefendingTemplate (): string {
return `
(function () {
var func = function(){return ${Utils.stringToUnicode('dev')};},
var func = function(){return 'dev';},
func2 = function () {
return 'window';
};
!Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})().test(func.toString()) ? Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func2.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')();
!Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})().test(func.toString()) ? Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func2.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')();
})();
`;
}
@@ -1,16 +1,10 @@
import { Utils } from "../../../../Utils";
/**
* @param unicodeArrayCallsWrapperName
* @param unicodeArrayName
* @returns {string}
*/
export function UnicodeArrayCallsWrapperTemplate (unicodeArrayCallsWrapperName: string, unicodeArrayName: string): string {
let keyName: string = Utils.getRandomVariableName();
export function UnicodeArrayCallsWrapperTemplate (): string {
return `
var ${unicodeArrayCallsWrapperName} = function (${keyName}) {
return ${unicodeArrayName}[parseInt(${keyName}, 0x010)];
var {unicodeArrayCallsWrapperName} = function ({keyName}) {
return {unicodeArrayName}[parseInt({keyName}, 0x010)];
};
`;
}
@@ -1,18 +1,12 @@
import { JSFuck } from "../../../../enums/JSFuck";
import { Utils } from "../../../../Utils";
/**
* @param unicodeArrayName
* @param forLoopFunctionName
* @returns {string}
*/
export function SelfDefendingTemplate (unicodeArrayName: string, forLoopFunctionName: string): string {
let environmentName: string = Utils.getRandomVariableName();
export function SelfDefendingTemplate (): string {
return `
var ${environmentName} = function(){return ${Utils.stringToUnicode('dev')};};
var func = function(){return 'dev';};
Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils.stringToUnicode('test')}](${environmentName}[${Utils.stringToUnicode('toString')}]()) !== ${JSFuck.True} && !${unicodeArrayName}++ ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : Function(${Utils.stringToUnicode('a')}, atob(${Utils.stringToUnicode(Utils.btoa('a.call()'))}))(${forLoopFunctionName}) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')();
Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()['test'](func['toString']()) !== true && !{unicodeArrayName}++ ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')() : Function('a', atob(${Utils.stringToUnicode(Utils.btoa('a.call()'))}))({forLoopFunctionName}) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')();
`;
}
@@ -1,35 +1,22 @@
import { NO_CUSTOM_NODES_PRESET } from "../../../../preset-options/NoCustomNodesPreset";
import { AtobTemplate } from "../../AtobTemplate";
import { JavaScriptObfuscator } from '../../../../JavaScriptObfuscator';
import { Utils } from "../../../../Utils";
/**
* @param code
* @param unicodeArrayName
* @param forLoopFunctionName
* @returns {string}
*/
export function UnicodeArrayDecodeTemplate (code: string, unicodeArrayName: string, forLoopFunctionName: string): string {
let indexVariableName: string = Utils.getRandomVariableName(),
tempArrayName: string = Utils.getRandomVariableName();
export function UnicodeArrayDecodeTemplate (): string {
return `
(function () {
${JavaScriptObfuscator.obfuscate(AtobTemplate(), NO_CUSTOM_NODES_PRESET).getObfuscatedCode()}
{atobPolyfill}
var ${forLoopFunctionName} = function () {
var ${tempArrayName} = [];
var {forLoopFunctionName} = function () {
var array = [];
for (var ${indexVariableName} in ${unicodeArrayName}) {
${tempArrayName}[${Utils.stringToUnicode('push')}](decodeURI(atob(${unicodeArrayName}[${indexVariableName}])));
for (var i in {unicodeArrayName}) {
array['push'](decodeURI(atob({unicodeArrayName}[i])));
}
${unicodeArrayName} = ${tempArrayName};
{unicodeArrayName} = array;
};
${code}
{code}
})();
`;
}
@@ -1,10 +1,8 @@
/**
* @param unicodeArrayName
* @param unicodeArray
* @returns {string}
*/
export function UnicodeArrayTemplate (unicodeArrayName: string, unicodeArray: string): string {
export function UnicodeArrayTemplate (): string {
return `
var ${unicodeArrayName} = [${unicodeArray}];
var {unicodeArrayName} = [{unicodeArray}];
`;
}
@@ -1,16 +1,12 @@
import { JSFuck } from "../../../../enums/JSFuck";
import { Utils } from "../../../../Utils";
/**
* @param whileFunctionName
* @param timesName
* @returns {string}
*/
export function SelfDefendingTemplate (whileFunctionName: string, timesName: string): string {
export function SelfDefendingTemplate (): string {
return `(function () {
var func = function(){return ${Utils.stringToUnicode('dev')};};
var func = function(){return 'dev';};
!Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : Function(${Utils.stringToUnicode('a')}, ${Utils.stringToUnicode('b')}, ${Utils.stringToUnicode('a(++b)')})(${whileFunctionName}, ${timesName}) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')();
!Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')() : Function('a', 'b', 'a(++b)')({whileFunctionName}, {timesName}) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(false){}')();
})();`;
}
@@ -1,32 +1,16 @@
import { Utils } from "../../../../Utils";
/**
* @param code
* @param unicodeArrayName
* @param unicodeArrayRotateValue
* @param whileFunctionName
* @param timesName
* @returns {string}
*/
export function UnicodeArrayRotateFunctionTemplate (
code: string,
unicodeArrayName: string,
unicodeArrayRotateValue: number,
whileFunctionName: string,
timesName: string
): string {
let arrayName: string = Utils.getRandomVariableName(),
timesArgumentName: string = Utils.getRandomVariableName();
export function UnicodeArrayRotateFunctionTemplate (): string {
return `
(function (${arrayName}, ${timesName}) {
var ${whileFunctionName} = function (${timesArgumentName}) {
while (--${timesArgumentName}) {
${arrayName}[${Utils.stringToUnicode('push')}](${arrayName}[${Utils.stringToUnicode('shift')}]());
(function (array, {timesName}) {
var {whileFunctionName} = function (times) {
while (--times) {
array['push'](array['shift']());
}
};
${code}
})(${unicodeArrayName}, 0x${Utils.decToHex(unicodeArrayRotateValue)});
{code}
})({unicodeArrayName}, 0x{unicodeArrayRotateValue});
`;
}