mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
control flow flattening wip
This commit is contained in:
+14
-46
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user