是否可以使用JSFuck约定调用具有2个或更多参数的函数? [英] It is possible to call function with 2 params or more using JSFuck convention?

查看:46
本文介绍了是否可以使用JSFuck约定调用具有2个或更多参数的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一些字符串,并且我想使用函数"replace"来代替(忽略console.log和头脑中的白色字符)

Suppose I have some string and I want to use function "replace" (ignore console.log and white chars in your head)

console.log( 
    "truefalse"["replace"]("true") 
)

我想使用 jsfuck (更多信息在此)我将按以下方式手工操作(忽略日志,注释,白色字符,换行符))

And I want to reduce used characters of this code using jsfuck (more info here) which I do by hand as follows (ignore log, comments, white chars, new lines )

console.log(
    // "truefalse"[
    ([]+!![]+![])[

    // long 'replace' word:
    []+(!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]])[+!+[]+[+[]]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]][([][[]]+[])[+!+[]]+(![]+[])[+!+[]]+((+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]

    // ]("true") 
    ]([]+!![])
);

如您所见,我将第一个代码转换为仅使用6个字符的代码: [] {}!+ (这是jsfuck的想法)

As you can see I convert first code, to code which use only 6 characters: []{}!+ (this is idea of jsfuck)

问题:可以用2个参数调用函数replace-像这样:"truefalse" [[replace"]("true","1")并以类似的方式在JSF中编写(没有任何将字符串解释为代码的"eval")?我有/看到逗号分开的问题...:(

Question: It is possible to call function replace with 2 arguments - Like that: "truefalse"["replace"]("true","1") and write it in similar way in JSF (without any kind of 'eval' which interpret string as code)? I have/see problem with comma which separate arguments... :(

PS:我提供了我的jsfuck分支的链接(它是最新的-并产生比jsfuck.com旧站点小的得多的输出)

PS: I give link to my fork of jsfuck (which is up to date - and produce much smaller output than jsfuck.com old site)

推荐答案

您可以通过玩 Array.prototype.reduce 来向函数传递2个参数.

You can pass 2 arguments to a function by playing with Array.prototype.reduce.

这个想法是在具有2个值的数组上调用 reduce ,并且仅将一个参数(回调)传递给它(即,没有用于减小起始值的参数).这样,该数组的第一个和第二个值将用作回调的参数,该回调将仅被调用一次.

The idea is to call reduce on an array with 2 values, and pass only one argument (callback) to it (i.e. no argument for the reducing starting value). That way the first and second value of that array will serve as arguments to the callback, which will only be called once.

在您的示例中,具有2个值的数组必须为:

In your example, the array with 2 values would have to be:

["true", "1"]

可以使用 concat 组成的

:

which can be formed using concat:

["true"]["concat"]("1")

然后在其上调用 reduce ,并通过 replace 作为回调函数:

Then call reduce on that, and pass replace as the callback function:

["true"]["concat"]("1")["reduce"]("truefalse"["replace"])

现在唯一要解决的问题是确保使用正确的 this 绑定调用回调,因为"truefalse"现在在回调调用的实际调用中不起作用.我们可以通过调用 .bind :

The only issue to resolve now is to ensure that the callback is called with the right this-binding, because "truefalse" does not play a role in the actual invocation of the callback call now. We can solve this with a call of .bind:

所以要评估的表达式就是这个

So the expression to evaluate is this one

console.log(
    ["true"]["concat"]("1")["reduce"](""["replace"]["bind"]("truefalse"))
);

这篇关于是否可以使用JSFuck约定调用具有2个或更多参数的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆