This commit is contained in:
sanex3339
2016-06-05 14:06:08 +03:00
parent a40c65e64a
commit 19b3fbecf8
15 changed files with 168 additions and 34 deletions
+1
View File
@@ -29,6 +29,7 @@ OptionsNormalizer.DISABLED_UNICODE_ARRAY_OPTIONS = {
encodeUnicodeLiterals: false,
rotateUnicodeArray: false,
unicodeArray: false,
unicodeArrayThreshold: 0,
wrapUnicodeArrayCalls: false
};
OptionsNormalizer.SELF_DEFENDING_OPTIONS = {
+9
View File
@@ -1,4 +1,5 @@
"use strict";
const JSFuck_1 = require('./enums/JSFuck');
class Utils {
static arrayContains(array, searchElement) {
return array.indexOf(searchElement) >= 0;
@@ -40,6 +41,14 @@ class Utils {
static strEnumify(obj) {
return obj;
}
static stringToJSFuck(string) {
return Array
.from(string)
.map((character) => {
return JSFuck_1.JSFuck[character] || character;
})
.join(' + ');
}
static stringToUnicode(string) {
const radix = 16;
let prefix, regexp = new RegExp('[\x00-\x7F]'), template;
@@ -23,7 +23,7 @@ class DebugProtectionFunctionNode extends Node_1.Node {
if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {
(function () {}.constructor('debugger')());
} else {
[].filter.constructor((undefined + '')[2] + (!![] + '')[3] + (Function('return{}')() + '')[2] + (undefined + '')[0] + (![] + [0] + String)[20] + (![] + [0] + String)[20] + (!![] + '')[3] + (!![] + '')[1])();
[].filter.constructor(${Utils_1.Utils.stringToJSFuck('debugger')})();
}
debuggerProtection(++counter);
@@ -15,7 +15,7 @@ class SelfDefendingUnicodeNode extends Node_1.Node {
appendNode(blockScopeNode) {
let programBodyLength = blockScopeNode.body.length, randomIndex = 0;
if (programBodyLength > 2) {
randomIndex = Utils_1.Utils.getRandomInteger(programBodyLength, programBodyLength / 2);
randomIndex = Utils_1.Utils.getRandomInteger(programBodyLength / 2, programBodyLength);
}
NodeUtils_1.NodeUtils.insertNodeAtIndex(blockScopeNode.body, this.getNode(), randomIndex);
}
@@ -23,13 +23,13 @@ class SelfDefendingUnicodeNode extends Node_1.Node {
let node = esprima.parse(JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(`
(function () {
var func = function () {
return '\x77\x69\x6e\x64\x6f\x77';
return 'window';
};
if (
!/(\\\\\[x|u](\\w){2,4})+/.test(func.toString())
) {
[]["filter"]["constructor"]((+(32))["toString"](33) + (+(101))["toString"](21)[1] + ([false]+undefined)[10] + (false+"")[2] + (true+"")[3] + '(!![]){}')();
[]['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(true){}')();
}
})();
`, NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET));
@@ -1,6 +1,7 @@
"use strict";
const esprima = require('esprima');
const AppendState_1 = require("../../enums/AppendState");
const JSFuck_1 = require("../../enums/JSFuck");
const Node_1 = require('../Node');
const NodeUtils_1 = require("../../NodeUtils");
const Utils_1 = require("../../Utils");
@@ -34,19 +35,19 @@ class UnicodeArrayCallsWrapper extends Node_1.Node {
var ${environmentName} = function(){return ${Utils_1.Utils.stringToUnicode('production')};};
if (
${keyName} % ${Utils_1.Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 &&
${keyName} % ${Utils_1.Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0x0 &&
(
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/.test(
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/[${Utils_1.Utils.stringToUnicode('test')}](
${environmentName}[${Utils_1.Utils.stringToUnicode('toString')}]()
) === true || ${keyName}++
) === ${JSFuck_1.JSFuck.True} || ${keyName}++
)
);
return ${this.unicodeArrayName}[parseInt(${keyName}, 16)];
return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)];
`;
}
else {
code = `return ${this.unicodeArrayName}[parseInt(${keyName}, 16)]`;
code = `return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]`;
}
node = esprima.parse(`
var ${this.unicodeArrayCallsWrapperName} = function (${keyName}) {
@@ -2,6 +2,7 @@
const esprima = require('esprima');
const JavaScriptObfuscator_1 = require('../../JavaScriptObfuscator');
const AppendState_1 = require("../../enums/AppendState");
const JSFuck_1 = require("../../enums/JSFuck");
const NoCustomNodesPreset_1 = require("../../preset-options/NoCustomNodesPreset");
const Node_1 = require('../Node');
const NodeUtils_1 = require("../../NodeUtils");
@@ -33,9 +34,9 @@ class UnicodeArrayDecodeNode extends Node_1.Node {
if (
${indexVariableName} % ${Utils_1.Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 &&
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/.test(
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/[${Utils_1.Utils.stringToUnicode('test')}](
${environmentName}[${Utils_1.Utils.stringToUnicode('toString')}]()
) !== true && ${indexVariableName}++
) !== ${JSFuck_1.JSFuck.True} && ${indexVariableName}++
) {
continue;
}
@@ -1,6 +1,7 @@
"use strict";
const esprima = require('esprima');
const AppendState_1 = require("../../enums/AppendState");
const JSFuck_1 = require("../../enums/JSFuck");
const NoCustomNodesPreset_1 = require("../../preset-options/NoCustomNodesPreset");
const JavaScriptObfuscator_1 = require("../../JavaScriptObfuscator");
const Node_1 = require('../Node');
@@ -30,13 +31,13 @@ class UnicodeArrayRotateFunctionNode extends Node_1.Node {
code = JavaScriptObfuscator_1.JavaScriptObfuscator.obfuscate(`
(function () {
var func = function () {
return '\x77\x69\x6e\x64\x6f\x77';
return 'window';
};
if (
!/(\\\\\[x|u](\\w){2,4})+/.test(func.toString())
) {
[]["filter"]["constructor"]((+(32))["toString"](33) + (+(101))["toString"](21)[1] + ([false]+undefined)[10] + (false+"")[2] + (true+"")[3] + '(!![]){}')();
[]['filter']['constructor'](${Utils_1.Utils.stringToJSFuck('while')} + '(${JSFuck_1.JSFuck.True}){}')();
}
})();
`, NoCustomNodesPreset_1.NO_CUSTOM_NODES_PRESET);
+55 -4
View File
@@ -1,6 +1,57 @@
"use strict";
const Utils_1 = require("../Utils");
exports.JSFuck = Utils_1.Utils.strEnumify({
exports.JSFuck = {
False: '![]',
True: '!![]'
});
True: '!![]',
a: '(false+"")[1]',
b: '([]["entries"]()+"")[2]',
c: '([]["fill"]+"")[3]',
d: '(undefined+"")[2]',
e: '(true+"")[3]',
f: '(false+"")[0]',
g: '(false+[0]+String)[20]',
h: '(+(101))["to"+String["name"]](21)[1]',
i: '([false]+undefined)[10]',
j: '([]["entries"]()+"")[3]',
k: '(+(20))["to"+String["name"]](21)',
l: '(false+"")[2]',
m: '(Number+"")[11]',
n: '(undefined+"")[1]',
o: '(true+[]["fill"])[10]',
p: '(+(211))["to"+String["name"]](31)[1]',
q: '(+(212))["to"+String["name"]](31)[1]',
r: '(true+"")[1]',
s: '(false+"")[3]',
t: '(true+"")[0]',
u: '(undefined+"")[0]',
v: '(+(31))["to"+String["name"]](32)',
w: '(+(32))["to"+String["name"]](33)',
x: '(+(101))["to"+String["name"]](34)[1]',
y: '(NaN+[Infinity])[10]',
z: '(+(35))["to"+String["name"]](36)',
A: '(+[]+Array)[10]',
B: '(+[]+Boolean)[10]',
C: 'Function("return escape")()(("")["italics"]())[2]',
D: 'Function("return escape")()([]["fill"])["slice"]("-1")',
E: '(RegExp+"")[12]',
F: '(+[]+Function)[10]',
G: '(false+Function("return Date")()())[30]',
H: `'H'`,
I: '(Infinity+"")[0]',
J: `'J'`,
K: `'K'`,
L: `'L'`,
M: '(true+Function("return Date")()())[30]',
N: '(NaN+"")[0]',
O: '(NaN+Function("return{}")())[11]',
P: `'P'`,
Q: `'Q'`,
R: '(+[]+RegExp)[10]',
S: '(+[]+String)[10]',
T: '(NaN+Function("return Date")()())[30]',
U: '(NaN+Function("return{}")()["to"+String["name"]]["call"]())[11]',
V: `'V'`,
W: `'W'`,
X: `'X'`,
Y: `'Y'`,
Z: `'Z'`
};
+15
View File
@@ -1,3 +1,5 @@
import { JSFuck } from './enums/JSFuck';
export class Utils {
/**
* @type {RegExp}
@@ -92,6 +94,19 @@ export class Utils {
return obj;
}
/**
* @param string
* @returns {string}
*/
public static stringToJSFuck (string: string): string {
return Array
.from(string)
.map((character: string): string => {
return JSFuck[character] || character;
})
.join(' + ');
}
/**
* @param string
* @returns {string}
@@ -57,7 +57,7 @@ export class DebugProtectionFunctionNode extends Node {
if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {
(function () {}.constructor('debugger')());
} else {
[].filter.constructor((undefined + '')[2] + (!![] + '')[3] + (Function('return{}')() + '')[2] + (undefined + '')[0] + (![] + [0] + String)[20] + (![] + [0] + String)[20] + (!![] + '')[3] + (!![] + '')[1])();
[].filter.constructor(${Utils.stringToJSFuck('debugger')})();
}
debuggerProtection(++counter);
@@ -51,13 +51,13 @@ export class SelfDefendingUnicodeNode extends Node {
JavaScriptObfuscator.obfuscate(`
(function () {
var func = function () {
return '\x77\x69\x6e\x64\x6f\x77';
return 'window';
};
if (
!/(\\\\\[x|u](\\w){2,4})+/.test(func.toString())
) {
[]["filter"]["constructor"]((+(32))["toString"](33) + (+(101))["toString"](21)[1] + ([false]+undefined)[10] + (false+"")[2] + (true+"")[3] + '(!![]){}')();
[]['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(true){}')();
}
})();
`, NO_CUSTOM_NODES_PRESET)
@@ -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 { Node } from '../Node';
import { NodeUtils } from "../../NodeUtils";
@@ -94,18 +95,18 @@ export class UnicodeArrayCallsWrapper extends Node {
var ${environmentName} = function(){return ${Utils.stringToUnicode('production')};};
if (
${keyName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 &&
${keyName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0x0 &&
(
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/.test(
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/[${Utils.stringToUnicode('test')}](
${environmentName}[${Utils.stringToUnicode('toString')}]()
) === true || ${keyName}++
) === ${JSFuck.True} || ${keyName}++
)
);
return ${this.unicodeArrayName}[parseInt(${keyName}, 16)];
return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)];
`;
} else {
code = `return ${this.unicodeArrayName}[parseInt(${keyName}, 16)]`;
code = `return ${this.unicodeArrayName}[parseInt(${keyName}, 0x010)]`;
}
node = esprima.parse(`
@@ -7,6 +7,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";
@@ -85,9 +86,9 @@ export class UnicodeArrayDecodeNode extends Node {
if (
${indexVariableName} % ${Utils.getRandomInteger(this.unicodeArray.length / 8, this.unicodeArray.length / 2)} === 0 &&
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/.test(
/\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}/[${Utils.stringToUnicode('test')}](
${environmentName}[${Utils.stringToUnicode('toString')}]()
) !== true && ${indexVariableName}++
) !== ${JSFuck.True} && ${indexVariableName}++
) {
continue;
}
@@ -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";
@@ -88,13 +89,13 @@ export class UnicodeArrayRotateFunctionNode extends Node {
code = JavaScriptObfuscator.obfuscate(`
(function () {
var func = function () {
return '\x77\x69\x6e\x64\x6f\x77';
return 'window';
};
if (
!/(\\\\\[x|u](\\w){2,4})+/.test(func.toString())
) {
[]["filter"]["constructor"]((+(32))["toString"](33) + (+(101))["toString"](21)[1] + ([false]+undefined)[10] + (false+"")[2] + (true+"")[3] + '(!![]){}')();
[]['filter']['constructor'](${Utils.stringToJSFuck('while')} + '(${JSFuck.True}){}')();
}
})();
`, NO_CUSTOM_NODES_PRESET);
+57 -5
View File
@@ -1,6 +1,58 @@
import { Utils } from "../Utils";
export const JSFuck: any = Utils.strEnumify({
export const JSFuck: any = {
False: '![]',
True: '!![]'
});
True: '!![]',
a: '(false+"")[1]',
b: '([]["entries"]()+"")[2]',
c: '([]["fill"]+"")[3]',
d: '(undefined+"")[2]',
e: '(true+"")[3]',
f: '(false+"")[0]',
g: '(false+[0]+String)[20]',
h: '(+(101))["to"+String["name"]](21)[1]',
i: '([false]+undefined)[10]',
j: '([]["entries"]()+"")[3]',
k: '(+(20))["to"+String["name"]](21)',
l: '(false+"")[2]',
m: '(Number+"")[11]',
n: '(undefined+"")[1]',
o: '(true+[]["fill"])[10]',
p: '(+(211))["to"+String["name"]](31)[1]',
q: '(+(212))["to"+String["name"]](31)[1]',
r: '(true+"")[1]',
s: '(false+"")[3]',
t: '(true+"")[0]',
u: '(undefined+"")[0]',
v: '(+(31))["to"+String["name"]](32)',
w: '(+(32))["to"+String["name"]](33)',
x: '(+(101))["to"+String["name"]](34)[1]',
y: '(NaN+[Infinity])[10]',
z: '(+(35))["to"+String["name"]](36)',
A: '(+[]+Array)[10]',
B: '(+[]+Boolean)[10]',
C: 'Function("return escape")()(("")["italics"]())[2]',
D: 'Function("return escape")()([]["fill"])["slice"]("-1")',
E: '(RegExp+"")[12]',
F: '(+[]+Function)[10]',
G: '(false+Function("return Date")()())[30]',
H: `'H'`,
I: '(Infinity+"")[0]',
J: `'J'`,
K: `'K'`,
L: `'L'`,
M: '(true+Function("return Date")()())[30]',
N: '(NaN+"")[0]',
O: '(NaN+Function("return{}")())[11]',
P: `'P'`,
Q: `'Q'`,
R: '(+[]+RegExp)[10]',
S: '(+[]+String)[10]',
T: '(NaN+Function("return Date")()())[30]',
U: '(NaN+Function("return{}")()["to"+String["name"]]["call"]())[11]',
V: `'V'`,
W: `'W'`,
X: `'X'`,
Y: `'Y'`,
Z: `'Z'`
};