I am working on simple javascript obfuscator code.
Say you have a two-dimensional square matrix of NxNjavascript functions . For n = 3:
var m = [
[function(){return 1}, function(){return 2}, function(){return 3}],
[function(){return 4}, function(){return 5}, function(){return 6}],
[function(){return 7}, function(){return 8}, function(){return 9}]
]
Now, in the example, each of these functions actually contains pieces of code from the code to be obfuscated, and calls it. A typical obfuscation code would look like this:
(function(){ m[1][2](m[2][0](m[0][1]))(m[1][0])(m[2][2])(m[1][1](m[1][2](m[2][0]))); }());
The above means the following:
(function(){ 6( 7(2) )( 4 )( 9 )( 5( 6( 7 ) ) ); }());
Of course, assuming that the typical m[x][y]returns functions or something else that is needed, it will all be very easy to decrypt. Therefore, after each call, I m[x][y] m[x][y]will switch from a position m[x+1][y-1]that will switch to my rotation position using m[0][2], and basically I want to mix them so that you would not even dare to decrypt. Probably using randomly generated math, and this goes according to function.
The fact is that the obfuscator must know this formula in advance, so he knows which m[x][y]one to call, and at what point, and decide the order in which to perform the functions. A working implementation may even lead to:
(function( m[0][0](m[0][0](m[0][0]))(m[0][0]) ))
And still work. So here are my questions:
JavaScript ? , , - JS , . , ?
, :
window.a = function(x){
var r = x*2;
window.a =alert;
return r;
};
a('2 * 2 = ' + a(2));
, , :
var i = 0;
window.a = function(x){
if(i===1){
i=0;
return alert(x);
}
i=1;
return x*2;
};
a('2 * 2='+a(2));
?
? , .