Of course, assuming that a typical m[x][y] returns functions or whatever as necessary, this would all be very easily decipherable. So after every m[x][y] call, m[x][y] would switch position with m[x+1][y-1] which would switch at his turn position with m[0][2] and basically I want to mixed them up so bad you wouldn't even dare attempt to decipher. Probably using random generated math, and that goes as per function.

The point is that the obfuscator needs to know this formula beforehand, so it knows which m[x][y] to call in, and at which point, and decide the order in which to bandwagon the functions. A working implementation might even result in:

(function( m[0][0](m[0][0](m[0][0]))(m[0][0]) ))

And still work. So here are my questions:

How can I split javascript code into smaller functions? I know compilers basically do that, but I also seen some on-line JS beautifiers, and syntax highlighters being able to distinguish code and do their thing properly. I mean can basic regex do the job?

1 Answer
1

First of all congrats on what you are doing. It is a bit of insane, but it's almost brilliant.

Question 1:

I do not know how you could do this. I've spent some time thinking about the same principle.

Question 2:

Your first example doesn't work because the first call for a it is actually a( "2 * 2 = " + x ) where x would be the second call, so when the first a is called you get a NaN because you give it a String

Question 3:

Similar projects? Hmm let me think... I guess everybody has it's own project for something like this, because the code is visible. Actual sources i do not know.

Proposal:

You could consider that square 2D matrix a 3D Rubik's Cube this way you could shuffle it and solve it. The interesting part is that you can combine that a series of moves to actually be a big function for doing something. Anyway probably the best solution for this kind of things IMHO would be to duplicate and then erase the main objects of the JS language and store it in a complex graph inside a anonymous function where nobody can enter to mess around, as for the code to be unreadable, well i think this is an ART.

For (2), I've tried the other way around too and it doesn't work either. I'll open this in a separate question because I find it very interesting.
–
GRIGORE-TURBODISELMar 30 '12 at 10:54

1

@GRIGORE-TURBODISEL After 3 years I just re-read this. For Question 2, the answer is simple: Because the line a('2*2=' + a(2)) is actually putting the original function a twice in the stack. Even though after the first call a redefines itself, you can't manipulate the ops that are already on the stack. So in this case the original a is called twice instead of once. Making polymorphic code is difficult, but having this in mind and with some type-checking it could be a nice idea for some implementations, but it should remain out of any production environments.
–
helly0dJan 21 at 19:03