control flow flattening wip

This commit is contained in:
sanex3339
2016-11-21 15:25:51 +03:00
parent 8e5c127226
commit 2fc6c96165
40 changed files with 541 additions and 1027 deletions
+14 -46
View File
@@ -1,4 +1,5 @@
'use strict';
import { NO_CUSTOM_NODES_PRESET } from '../../src/preset-options/NoCustomNodesPreset';
if (!(<any>global)._babelPolyfill) {
require('babel-polyfill');
@@ -7,54 +8,21 @@ if (!(<any>global)._babelPolyfill) {
(function () {
const JavaScriptObfuscator: any = require("../../index");
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
(function(){
var result = 1,
term1 = 0,
term2 = 1,
i = 1;
while(i < 10)
{
var test = 10;
result = term1 + term2;
console.log(result);
term1 = term2;
term2 = result;
i++;
}
console.log(test);
var test = function (test) {
console.log(test);
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(`
(function(){
function t () {
return function () {
var t = 1 * 2;
}
}
if (true) {
var test = 5
}
}
function t () {
return function () {
return 100 * 2 - 70;
}
}
var n = 100 + 50;
var b = true + true;
var s = 'str' + 'ing';
var r = /re/ + /g/;
console.log(t()());
console.log(n);
})();
var s = 1 - 3;
})();
`,
{
controlFlow: true,
disableConsoleOutput: false,
selfDefending: true,
stringArrayEncoding: 'rc4'
}
Object.assign({}, NO_CUSTOM_NODES_PRESET, {
controlFlowFlattening: true,
disableConsoleOutput: false
})
).getObfuscatedCode();
console.log(obfuscatedCode);