optimisations

This commit is contained in:
sanex3339
2016-06-05 16:24:01 +03:00
parent f942f7698c
commit 95587de108
10 changed files with 63 additions and 111 deletions
@@ -6,6 +6,7 @@ import { IOptions } from "../../interfaces/IOptions";
import { TBlockScopeNode } from "../../types/TBlockScopeNode";
import { AppendState } from "../../enums/AppendState";
import { JSFuck } from "../../enums/JSFuck";
import { NO_CUSTOM_NODES_PRESET } from "../../preset-options/NoCustomNodesPreset";
@@ -54,11 +55,7 @@ export class SelfDefendingUnicodeNode extends Node {
return 'window';
};
if (
!Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString())
) {
[]['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')();
}
!Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : !!!!!![] ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')();
})();
`, NO_CUSTOM_NODES_PRESET)
);
@@ -85,33 +85,12 @@ export class UnicodeArrayCallsWrapper extends Node {
* @returns {INode}
*/
protected getNodeStructure (): INode {
let code: string = '',
environmentName: string = Utils.getRandomVariableName(),
keyName: string = Utils.getRandomVariableName(),
let keyName: string = Utils.getRandomVariableName(),
node: INode;
if (this.options['selfDefending']) {
code = `
var ${environmentName} = function(){return ${Utils.stringToUnicode('production')};};
if (
${keyName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0x0 &&
(
Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils.stringToUnicode('test')}](
${environmentName}[${Utils.stringToUnicode('toString')}]()
) === ${JSFuck.True} || ${keyName}++
)
);
return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)];
`;
} else {
code = `return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]`;
}
node = esprima.parse(`
var ${this.unicodeArrayCallsWrapperName} = function (${keyName}) {
${code}
return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)];
};
`);
@@ -74,6 +74,7 @@ export class UnicodeArrayDecodeNode extends Node {
*/
protected getNodeStructure (): INode {
const environmentName: string = Utils.getRandomVariableName(),
forLoopFunctionName: string = Utils.getRandomVariableName(),
indexVariableName: string = Utils.getRandomVariableName(),
tempArrayName: string = Utils.getRandomVariableName();
@@ -83,15 +84,8 @@ export class UnicodeArrayDecodeNode extends Node {
if (this.options['selfDefending']) {
code = `
var ${environmentName} = function(){return ${Utils.stringToUnicode('dev')};};
if (
${indexVariableName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 &&
Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils.stringToUnicode('test')}](
${environmentName}[${Utils.stringToUnicode('toString')}]()
) !== ${JSFuck.True} && ${indexVariableName}++
) {
continue;
}
Function(${Utils.stringToUnicode(`return/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/`)})()[${Utils.stringToUnicode('test')}](${environmentName}[${Utils.stringToUnicode('toString')}]()) !== ${JSFuck.True} && !${this.unicodeArrayName}++ ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : ${JSFuck.Window}.eval(${forLoopFunctionName}()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')();
`;
}
@@ -118,15 +112,17 @@ export class UnicodeArrayDecodeNode extends Node {
})();
`, NO_CUSTOM_NODES_PRESET)}
var ${tempArrayName} = [];
var ${forLoopFunctionName} = function () {
var ${tempArrayName} = [];
for (var ${indexVariableName} in ${this.unicodeArrayName}) {
${tempArrayName}[${Utils.stringToUnicode('push')}](decodeURI(atob(${this.unicodeArrayName}[${indexVariableName}])));
}
${this.unicodeArrayName} = ${tempArrayName};
};
for (var ${indexVariableName} in ${this.unicodeArrayName}) {
${code}
${tempArrayName}[${Utils.stringToUnicode('push')}](decodeURI(atob(${this.unicodeArrayName}[${indexVariableName}])));
}
${this.unicodeArrayName} = ${tempArrayName};
${code}
})();
`);
@@ -82,7 +82,9 @@ export class UnicodeArrayRotateFunctionNode extends Node {
let arrayName: string = Utils.getRandomVariableName(),
code: string = '',
timesName: string = Utils.getRandomVariableName(),
timesArgumentName: string = Utils.getRandomVariableName(),
tempArrayName: string = Utils.getRandomVariableName(),
whileFunctionName: string = Utils.getRandomVariableName(),
node: INode;
if (this.options['selfDefending']) {
@@ -92,13 +94,11 @@ export class UnicodeArrayRotateFunctionNode extends Node {
return 'window';
};
if (
!Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString())
) {
[]['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')();
}
!Function(${Utils.stringToUnicode(`return/(\\\\[x|u](\\w){2,4})+/`)})().test(func.toString()) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')() : ${JSFuck.Window}.eval(${whileFunctionName}(${timesName})) ? []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')() : []['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.False}){}')();
})();
`, NO_CUSTOM_NODES_PRESET);
} else {
code = `${whileFunctionName}(${timesName})`;
}
node = esprima.parse(`
@@ -109,11 +109,14 @@ export class UnicodeArrayRotateFunctionNode extends Node {
var ${tempArrayName};
while (${timesName}--) {
${code}
${tempArrayName} = ${arrayName}[${Utils.stringToUnicode('shift')}]();
${arrayName}[${Utils.stringToUnicode('push')}](${tempArrayName});
}
var ${whileFunctionName} = function (${timesArgumentName}) {
while (${timesArgumentName}--) {
${tempArrayName} = ${arrayName}[${Utils.stringToUnicode('shift')}]();
${arrayName}[${Utils.stringToUnicode('push')}](${tempArrayName});
}
};
${code}
})(${this.unicodeArrayName}, 0x${Utils.decToHex(this.unicodeArrayRotateValue)});
`);
+2
View File
@@ -1,4 +1,6 @@
export const JSFuck: any = {
Window: '[]["filter"]["constructor"]("return this")()',
False: '![]',
True: '!![]',