使用Javascript - 如何花车功能,在每次通话后改变他们的目的是什么?他们的、目的、花车、功能

2023-09-12 21:22:17 作者:弄丢了的岁月*

我工作的一个简单的JavaScript code混淆。

假设你有 N×N个的2D方阵的JavaScript功能。对于n = 3:

 变种M = [
   [功能(){返回1},功能(){返回2},功能(){返回3}],
   [功能(){返回4},功能(){返回5},功能(){返回6}],
   [功能(){返回7},功能(){返回8},功能(){返回9}]
]
 

现在,在这个例子中,这些功能的每一个实际上包含code块从code被扰乱,并呼吁,在一个典型的混淆code是这样的:

(函数(){米[1] [2](M [2] [0](米[0] [1]))(米[1] [0])(米[2] [2])(米[1] [1](米[1] [2](M [2] [0])));}());

以上转化成这样的:

(功能(){6(7(2))(4)(9)(5(6(7)));}());

当然,假设一个典型的 M [X] [Y] 返回功能或根据需要什么,这都将是很容易辨认。所以每 M [X] [Y] 通话后, M [X] [Y] 将开关位置用 M [X + 1] [Y-1] 这将在轮到他位置开关与 M [0] [2] 基本上我想要把它们混合起来如此糟糕,你不会甚至不敢尝试破译。可能使用随机生成的数学,而变为按功能。

的一点是,混淆器需要预先知道这个公式,所以它知道哪些 M [X] [Y] 打电话进来,在这一点上,和决定在其中的行列功能的顺序。工作实现甚至可能导致:

(功能(米[0] [0](米[0] [0](米[0] [0]))(米[0] [0])))

和仍然工作。因此,这里是我的问题:

我怎么可以拆分的JavaScript code成更小的功能呢?我知道的编译器基本上做到这一点,但我也看到了一些在网上JS美化和语法荧光笔能够分辨code,做自己的事情正常。我的意思是可以基本正则表达式完成这项工作?

如何看待2019年多家开源公司修改软件许可

这不工作,它应该:

  window.a =功能(X){
    变种R = X * 2;
    window.a =警报;第一次通话后//重新定义自己
    返回ř;
};
一个('2 * 2 ='+ A(2)); //不起作用。它应该已经惊动2 * 2 = 4
 

这在另一方面不工作:

 变种i = 0;
window.a =功能(X){
    如果(ⅰ=== 1){
        I = 0;
        返回警报(X);
    }

    I = 1;
    返回X * 2;
};
一个('2 * 2 ='+ A(2));
 

为什么?

有没有类似的正在进行的项目?也许我可以得到一些笔记或引用它们。

解决方案

首先对自己在做什么都恭喜的。这是一个有点疯狂,但它几乎辉煌。

问题1:

我不知道你能做到这一点。我花了一些时间思考同样的原则。

问题2:

您第一个例子中不起作用,因为第一次调用了它实际上是 A(2 * 2 =+ X)其中x是第二个电话,所以当第一个叫你得到一个 NaN的,因为你给它一个字符串

问题3:

类似的项目?嗯,让我想想...我想每个人都有自己的项目这样的事情,因为code是可见的。实际来源,我不知道。

建议:

您可以考虑方形矩阵二维三维魔方这种方式,你可以随机播放,并解决它。有趣的是,你可以结合的一系列举动实际上是一个很大的功能做一些事情。反正大概是这样的事情恕我直言最好的解决办法是复制,然后删除JS语言的主要对象,并将其存储在一个匿名函数内部的复杂的图,其中没有人可以左右进入到一塌糊涂,作为code到无法读取,以及我认为这是一门艺术。

I'm working on a simple javascript code obfuscator.

Say you have a 2D square matrix of NxN javascript 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 one of those functions would actually contain chunks of code from the code to be obfuscated, and call that in. A typical obfuscated 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 translates into this:

(function(){ 6( 7(2) )( 4 )( 9 )( 5( 6( 7 ) ) ); }());

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?

This doesn't work and it should:

window.a = function(x){ 
    var r = x*2; 
    window.a =alert; // redefines itself after first call
    return r;
}; 
a('2 * 2 = ' + a(2)); // doesn't work. it should've alerted "2 * 2 = 4"

This on the other hand does work:

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));

Why?

Are there any similar on-going projects? Maybe I can get some notes or reference to them.

解决方案

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.