这些 JavaScript 混淆器如何生成实际的工作代码?

发布于 2024-12-27 05:10:37 字数 3183 浏览 6 评论 0 原文

这个这个,它们都生成完全不可读的代码,其中一个比另一个更可爱。

现在,我不是 Javascript 专家,但我不明白

゚ω゚ノ= /`m´)ノ ~┻━┻   //*´∇`*/ ['_']; o=(゚ー゚)  =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o -(゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];(゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];(゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\'; (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o];(゚Д゚) [゚o゚]='\"';(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+(゚Д゚)[゚o゚]+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) - (゚Θ゚))+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚Θ゚)+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) +(o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((o^_^o) +(o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚o゚]) (゚Θ゚)) ('_');

并且

$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+$.$_$_+(![]+"")[$._$_]+$.$$$_+"\\"+$.__$+$.$$_+$._$_+$.__+"(\\\"\\"+$.__$+$._$_+$._$$+$.__+$.$_$_+$.$$__+"\\"+$.__$+$.$_$+$._$$+"\\"+$.__$+$.__$+$.$$$+"\\"+$.__$+$.$$_+$.$$_+$.$$$_+"\\"+$.__$+$.$$_+$._$_+$.$$$$+(![]+"")[$._$_]+$._$+"\\"+$.__$+$.$$_+$.$$$+"\\\")"+"\"")())();

javascript 是如何按预期执行的, 是实际有效的。说真的,运行它们。它们都是alert("StackOverflow")。我可以理解混淆一些逻辑或字符串混淆,但没有可见的控制语句。这个混淆器是否以不得命名的语言的风格施展了一些魔法?我对我的代码看起来也很满意,但我完全不理解它背后的魔力。

我尝试过浏览这两个页面的源代码,它们对我来说和它们生成的代码一样令人困惑。

这是如何运作的?

There's this one and this one and they both generate completely unreadable code, one being more adorable than the other.

Now, I'm no expert in Javascript, but I fail to see how

゚ω゚ノ= /`m´)ノ ~┻━┻   //*´∇`*/ ['_']; o=(゚ー゚)  =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o -(゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];(゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];(゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\'; (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o];(゚Д゚) [゚o゚]='\"';(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+(゚Д゚)[゚o゚]+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) - (゚Θ゚))+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚Θ゚)+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) +(o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((o^_^o) +(o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚o゚]) (゚Θ゚)) ('_');

and

$=~[];$={___:++$,$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$:({}+"")[$],$_$:($[$]+"")[$],_$:++$,$$_:(!""+"")[$],$__:++$,$_$:++$,$__:({}+"")[$],$_:++$,$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$=($.$+"")[$.__$])+((!$)+"")[$._$]+($.__=$.$_[$.$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$=$.$+(!""+"")[$._$]+$.__+$._+$.$+$.$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$+"\""+$.$_$_+(![]+"")[$._$_]+$.$$_+"\\"+$.__$+$.$_+$._$_+$.__+"(\\\"\\"+$.__$+$._$_+$._$+$.__+$.$_$_+$.$__+"\\"+$.__$+$.$_$+$._$+"\\"+$.__$+$.__$+$.$$+"\\"+$.__$+$.$_+$.$_+$.$$_+"\\"+$.__$+$.$_+$._$_+$.$$+(![]+"")[$._$_]+$._$+"\\"+$.__$+$.$_+$.$$+"\\\")"+"\"")())();

are actual valid javascript that do as expected. Seriously, run them. They're both alert("StackOverflow"). I could understand obfuscating some logic or string obfuscation, but there's no visible control statements. Is this obfuscator pulling some magic in the style of The Language Which Shall Not Be Named? I'm happy with my code looking happy too, but I'm completely not understanding the magic behind it.

I've tried picking through the sourcecode of both pages, and they're as confusing for me as the code they generate.

How does this work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

舟遥客 2025-01-03 05:10:37

多有趣啊!这是我的尝试。基本上这里发生的事情是一堆数字和字符串被分配给变量。这些变量被连接起来形成一个编码字符串。该编码字符串被解码以形成 JavaScript 代码字符串。该代码被设置为函数体,然后执行。

让我们逐行来看:

第 1 行:

゚ω゚ノ = /`m´)ノ ~┻━┻   //*´∇`*/['_'];

゚ω゚ノ - 全局变量
/`m´)ノ ~┻⁄┻ / - 正则表达式
/*´∇`*/ - 多行注释
['_'] - 获取正则表达式的属性_

由于 RegExp 没有 _ 属性,因此变量 ゚ω゚ノ 包含值 undefined

第 2 行:

o = (゚ー゚) = _ = 3;

定义变量 o゚ー゚_,并将它们的每个值设置为<代码>3

第 3 行:

c = (゚Θ゚) = (゚ー゚) - (゚ー゚);

定义变量 c゚θ゚ 并将其值设置为 0。 (゚ー゚3,因此 (゚ー゚) - (゚ー゚)゚ー゚ 相同- ゚ー゚3 - 3 相同,现在 c 和。 ゚θ゚ 都包含1

第4行:

(゚Д゚) = (゚Θ゚) = (o ^ _ ^ o) / (o ^ _ ^ o);

定义变量゚Д゚ 并重新定义变量 >゚θ゚^按位异或运算符o_都是3
o ^ _ ^ o3 ^ 3 ^ 3 相同。
3 ^ 303 ^ 03
那么 3 / 3 就是 1
゚Д゚゚Θ゚ 现在都包含 1

第5行:

(゚Д゚) = { ゚Θ゚: '_', ゚ω゚ノ: ((゚ω゚ノ == 3) + '_')[゚Θ゚], ゚ー゚ノ: (゚ω゚ノ + '_')[o ^ _ ^ o - (゚Θ゚)], ゚Д゚ノ: ((゚ー゚ == 3) + '_')[゚ー゚] };

带有换行和缩进:

(゚Д゚) = {
    ゚Θ゚: '_',
    ゚ω゚ノ: ((゚ω゚ノ == 3) + '_')[゚Θ゚],
    ゚ー゚ノ: (゚ω゚ノ + '_')[o ^ _ ^ o - (゚Θ゚)],
    ゚Д゚ノ: ((゚ー゚ == 3) + '_')[゚ー゚]
};

゚Д゚重新定义为对象文字,具有属性゚Θ゚゚ω゚ノ゚ー゚ノ゚Д゚ノ
゚Д゚.゚θ゚ 是“_”。
゚Д゚.゚ω゚ノ((undefined == 3) + "_")[1] ,即 "false_"[1]< /code> 是“a”
゚Д゚.゚ー゚ノ(undefined + "_")[3 ^ 3 ^ 3 - 1] 也就是 "undefined_"[2] “d”
゚Д゚.゚Д゚ノ((3 == 3) + "_")[3] ,即 "true_"[3]< /code> 是“u”

第 6 行:

(゚Д゚)[゚Θ゚] = ((゚ω゚ノ == 3) + '_')[c ^ _ ^ o];

等同于:

゚Д゚.゚Θ゚ = ((undefined == 3) + "_")[1 ^ 3 ^ 3];

等同于:

゚Д゚.゚Θ゚ = "false_"[1];

所以 ゚Д゚.゚θ゚"a"

第 7 - 16 行:

继续,将字符串和数字分配给变量和对象属性。直到最后一行:

第 17 行:

(゚Д゚)['_']((゚Д゚)['_'](゚ε゚ + (゚Д゚)[゚o゚] + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + ((゚ー゚) + (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (゚ー゚) + (゚Д゚)[゚ε゚] + ((゚ー゚) + (゚Θ゚)) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚ー゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚Θ゚) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + ((゚ー゚) + (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + ((゚ー゚) + (o ^ _ ^ o)) + (゚Д゚)[゚ε゚] + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚ー゚) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚Θ゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (o ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (o ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚ー゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + ((゚ー゚) + (゚Θ゚)) + (゚Θ゚) + (゚Д゚)[゚o゚])(゚Θ゚))('_');

此时,我们有以下变量:

゚ω゚ノ    // undefined
o       // 3
゚ー゚     // 4
_       // 3
c       // 0
゚Θ゚     // 1
゚Д゚     /* {
            "1": "f",
            ゚Θ゚: "_",
            ゚ω゚ノ: "a",
            ゚ー゚ノ: "d",
            ゚Д゚ノ: "e",
            c: "c",
            o: "o",
            return: "\\",
            ゚Θ゚ノ: "b",
            constructor: "\"",
            _: Function
        } */
゚o゚     // "constructor"
゚ε゚     // "return"
o゚ー゚o   // "u"

该行主要是一个大字符串连接。我们可以通过删除不必要的括号并添加换行符来使其稍微更具可读性:

゚Д゚['_'](
    ゚Д゚['_'](
        ゚ε゚ + 
        ゚Д゚[゚o゚] + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        (゚ー゚ + ゚Θ゚) + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚ー゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚Θ゚ + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        (゚ー゚ + (o ^ _ ^ o)) + 
        ゚Д゚[゚ε゚] + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚ー゚ + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        (o ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        (o ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚ー゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Θ゚ + 
        ゚Д゚[゚o゚]
    )(゚Θ゚)
)("_");

该连接字符串的值为:

return"\141\154\145\162\164\50\42\110\145\154\154\157\54\40\112\141\166\141\123\143\162\151\160\164\42\51"

因此,用文字替换所有变量,我们最终得到以下 JavaScript在最后一行执行:

Function(Function("return\"\\141\\154\\145\\162\\164\\50\\42\\110\\145\\154\\154\\157\\54\\40\\112\\141\\166\\141\\123\\143\\162\\151\\160\\164\\42\\51\"")(1))("_")

打破该行,在中间我们看到连接的字符串被传递给 Function 构造函数,使该字符串成为函数体:

Function("return\"\\141\\154\\145\\162\\164\\50\\42\\110\\145\\154\\154\\157\\54\\40\\112\\141\\166\\141\\123\\143\\162\\151\\160\\164\\42\\51\"")

因此,该字符串被评估为 JavaScript,并且这Function 构造函数返回此函数:

function () {
    return"\141\154\145\162\164\50\42\110\145\154\154\157\54\40\112\141\166\141\123\143\162\151\160\164\42\51";
}

该函数立即执行:

Function("return\"\\141\\154\\145\\...\\51\"")(1)

并返回字符串:

alert("Hello, JavaScript")

嘿,这看起来像 JavaScript!但现在还没有。它只是一个字符串。但是该字符串被传递给另一个 Function 构造函数,为我们提供了一个将字符串作为 JavaScript 执行的函数:

Function("alert(\"Hello, JavaScript\")")

这与以下内容相同:

function () {
    alert("Hello, JavaScript");
}

该函数立即执行:

Function("alert(\"Hello, JavaScript\")")("_")

最终调用我们未混淆的代码。

What fun! Here's my go at it. Basically what is happening here is a bunch of numbers and strings are being assigned to variables. Those variables are being concatenated to form an encoded string. That encoded string is decoded to form a string of JavaScript code. That code is set as the body of a function, which is then executed.

Let's take it line by line:

Line 1:

゚ω゚ノ = /`m´)ノ ~┻━┻   //*´∇`*/['_'];

゚ω゚ノ - a global variable
/`m´)ノ ~┻━┻ / - a regular expression
/*´∇`*/ - a multi-line comment
['_'] - get the property _ of the regular expression.

Since a RegExp does not have a _ property, the variable ゚ω゚ノ contains the value undefined.

Line 2:

o = (゚ー゚) = _ = 3;

Define the variables o, ゚ー゚, and _, and set each of their values to 3.

Line 3:

c = (゚Θ゚) = (゚ー゚) - (゚ー゚);

Define the variables c and ゚Θ゚ and set their values to 0. (゚ー゚ is 3, so (゚ー゚) - (゚ー゚) is the same as ゚ー゚ - ゚ー゚ is the same as 3 - 3. Now c and ゚Θ゚ both contain 1;

Line 4:

(゚Д゚) = (゚Θ゚) = (o ^ _ ^ o) / (o ^ _ ^ o);

Define the variable ゚Д゚ and redefine the variable ゚Θ゚. ^ is the bitwise XOR operator and o and _ are both 3.
o ^ _ ^ o is the same as 3 ^ 3 ^ 3.
3 ^ 3 is 0, 3 ^ 0 is 3.
Then 3 / 3 is 1.
゚Д゚ and ゚Θ゚ both now contain 1.

Line 5:

(゚Д゚) = { ゚Θ゚: '_', ゚ω゚ノ: ((゚ω゚ノ == 3) + '_')[゚Θ゚], ゚ー゚ノ: (゚ω゚ノ + '_')[o ^ _ ^ o - (゚Θ゚)], ゚Д゚ノ: ((゚ー゚ == 3) + '_')[゚ー゚] };

With line breaks and indentation:

(゚Д゚) = {
    ゚Θ゚: '_',
    ゚ω゚ノ: ((゚ω゚ノ == 3) + '_')[゚Θ゚],
    ゚ー゚ノ: (゚ω゚ノ + '_')[o ^ _ ^ o - (゚Θ゚)],
    ゚Д゚ノ: ((゚ー゚ == 3) + '_')[゚ー゚]
};

Redefine ゚Д゚ as an object literal, with properties ゚Θ゚, ゚ω゚ノ, ゚ー゚ノ, and ゚Д゚ノ.
゚Д゚.゚Θ゚ is "_".
゚Д゚.゚ω゚ノ is ((undefined == 3) + "_")[1] which is "false_"[1] which is "a".
゚Д゚.゚ー゚ノ is (undefined + "_")[3 ^ 3 ^ 3 - 1] which is "undefined_"[2] which is "d".
゚Д゚.゚Д゚ノ is ((3 == 3) + "_")[3] which is "true_"[3] which is "u".

Line 6:

(゚Д゚)[゚Θ゚] = ((゚ω゚ノ == 3) + '_')[c ^ _ ^ o];

Is the same as:

゚Д゚.゚Θ゚ = ((undefined == 3) + "_")[1 ^ 3 ^ 3];

Which is the same as:

゚Д゚.゚Θ゚ = "false_"[1];

So ゚Д゚.゚Θ゚ is "a".

Lines 7 - 16:

And so it continues, assigning strings and numbers to variables and object properties. Until the last line:

Line 17:

(゚Д゚)['_']((゚Д゚)['_'](゚ε゚ + (゚Д゚)[゚o゚] + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + ((゚ー゚) + (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (゚ー゚) + (゚Д゚)[゚ε゚] + ((゚ー゚) + (゚Θ゚)) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚ー゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚Θ゚) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + ((゚ー゚) + (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + ((゚ー゚) + (o ^ _ ^ o)) + (゚Д゚)[゚ε゚] + ((゚ー゚) + (゚Θ゚)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚ー゚) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚Θ゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (o ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + (゚ー゚) + (o ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((゚ー゚) + (゚Θ゚)) + (゚Θ゚) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (c ^ _ ^ o) + (゚Д゚)[゚ε゚] + (゚Θ゚) + ((o ^ _ ^ o) + (o ^ _ ^ o)) + (゚ー゚) + (゚Д゚)[゚ε゚] + (゚ー゚) + ((o ^ _ ^ o) - (゚Θ゚)) + (゚Д゚)[゚ε゚] + ((゚ー゚) + (゚Θ゚)) + (゚Θ゚) + (゚Д゚)[゚o゚])(゚Θ゚))('_');

By this time, we have the following variables:

゚ω゚ノ    // undefined
o       // 3
゚ー゚     // 4
_       // 3
c       // 0
゚Θ゚     // 1
゚Д゚     /* {
            "1": "f",
            ゚Θ゚: "_",
            ゚ω゚ノ: "a",
            ゚ー゚ノ: "d",
            ゚Д゚ノ: "e",
            c: "c",
            o: "o",
            return: "\\",
            ゚Θ゚ノ: "b",
            constructor: "\"",
            _: Function
        } */
゚o゚     // "constructor"
゚ε゚     // "return"
o゚ー゚o   // "u"

That line is mostly one big string concatenation. We can make it slightly more readable by removing the unnecessary parentheses and adding line breaks:

゚Д゚['_'](
    ゚Д゚['_'](
        ゚ε゚ + 
        ゚Д゚[゚o゚] + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        (゚ー゚ + ゚Θ゚) + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚ー゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚Θ゚ + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        (゚ー゚ + (o ^ _ ^ o)) + 
        ゚Д゚[゚ε゚] + 
        (゚ー゚ + ゚Θ゚) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚ー゚ + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        (o ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ゚ー゚ + 
        (o ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Θ゚ + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        (c ^ _ ^ o) + 
        ゚Д゚[゚ε゚] + 
        ゚Θ゚ + 
        ((o ^ _ ^ o) + (o ^ _ ^ o)) + 
        ゚ー゚ + 
        ゚Д゚[゚ε゚] + 
        ゚ー゚ + 
        ((o ^ _ ^ o) - ゚Θ゚) + 
        ゚Д゚[゚ε゚] + 
        (゚ー゚ + ゚Θ゚) + 
        ゚Θ゚ + 
        ゚Д゚[゚o゚]
    )(゚Θ゚)
)("_");

The value of that concatenated string is:

return"\141\154\145\162\164\50\42\110\145\154\154\157\54\40\112\141\166\141\123\143\162\151\160\164\42\51"

So, replacing all the variables with literals, we end up with the following JavaScript which gets executed on that last line:

Function(Function("return\"\\141\\154\\145\\162\\164\\50\\42\\110\\145\\154\\154\\157\\54\\40\\112\\141\\166\\141\\123\\143\\162\\151\\160\\164\\42\\51\"")(1))("_")

Breaking that line down, in the middle we see the concatenated string is passed to a Function constructor, making the string the function body:

Function("return\"\\141\\154\\145\\162\\164\\50\\42\\110\\145\\154\\154\\157\\54\\40\\112\\141\\166\\141\\123\\143\\162\\151\\160\\164\\42\\51\"")

So, that string is evaluated as JavaScript, and the Function constructor returns this function:

function () {
    return"\141\154\145\162\164\50\42\110\145\154\154\157\54\40\112\141\166\141\123\143\162\151\160\164\42\51";
}

That function is immediately executed:

Function("return\"\\141\\154\\145\\...\\51\"")(1)

And returns the string:

alert("Hello, JavaScript")

Hey, that looks like JavaScript! But it's not yet. It's just a string. But that string is passed to another Function constructor, giving us a function that executes the string as JavaScript:

Function("alert(\"Hello, JavaScript\")")

That is the same as:

function () {
    alert("Hello, JavaScript");
}

That function is immediately executed:

Function("alert(\"Hello, JavaScript\")")("_")

And our unobfuscated code is finally called.

执手闯天涯 2025-01-03 05:10:37

作为我今天的 javascript 练习,逐行分解。请注意,我用 alert("Hello")

$ = ~[];   // var $ = -1
$ = 
    {
    ___ : ++$,              // ++(-1) == 0
    $$:(![]+"")[$],       // ![] == false, false + "" == "false", "false"[0] == "f"
    __$:++$,                // ++(0) == 1    
    $_$_:(![]+"")[$],       // ![] == false, false + "" == "false", "false"[1] == "a"
    _$_:++$,                // ++(1) == 2
    $_$:({}+"")[$],        // {} + "" == "[object Object]", "[object Object]"[2] == "b"
    $_$:($[$]+"")[$],      // 2[2] == undefined + "" == "undefined", "undefined"[2] == "d"
    _$:++$,                // ++(2) == 3
    $$_:(!""+"")[$],       // !"" == true + "" == "true", "true"[3] == "e"
    $__:++$,                // ++(3) == 4
    $_$:++$,                // ++(4) == 5
    $__:({}+"")[$],        // ({} + "") == [object Object]", "[object Object]"[5] == "c"
    $_:++$,                // ++(5) == 6
    $$:++$,                // ++(6) == 7
    $___:++$,               // ++(7) == 8
    $__$:++$                // ++(8) == 9
};

$.$_ = 
    ($.$_=$+"")[$.$_$] +        // "[object Object]"[5] == "c" +  (also $.$_ = "[object Object]")
    ($._$=$.$_[$.__$]) +        // "[object Object]"[1] == "o" + (also $._$ = "o")
    ($.$=($.$+"")[$.__$]) +    // $.$+"" == "undefined", "undefined"[1] == "n" + (also $.$ = "n")
    ((!$)+"")[$._$] +          // !$ == false, false+"" == "false", "false"[3] == "s" +
    ($.__=$.$_[$.$_]) +        // "[object Object]"[6] == "t" (also $.__ = "t") +
    ($.$=(!""+"")[$.__$]) +     // !"" == true, true + "" == "true", "true"[2] == "r" +(also $.$="r")
    ($._=(!""+"")[$._$_]) +     // !"" == true, true + "" == "true", "true"[3] == "u" +(also $._="u")
    $.$_[$.$_$] +               // "[object Object]"[5] == "c" +
    $.__ +                      // "t" +
    $._$ +                      // "o" +
    $.$;                        // "r"

// $.$_ = "constructor"

$.$ = 
    $.$ +                       // "r" +
    (!""+"")[$._$] +           // "true"[3] == "e" +
    $.__ +                      // "t" +
    $._  +                      // "u" +
    $.$ +                       // "r" +
    $.$;                       // "n" 
// $.$ = "return"

$.$ = ($.___)[$.$_][$.$_];      // (0)["constructor"]["constructor"]
// $.$ = Function

// This is the part that changes when you change the input string.

$.$(                            // Function( 
    $.$(                        // Function (
        $.$ +                  // "return"+
        "\""+                   // '"' +
        $.$_$_ +                // "a" + 
        (![]+"")[$._$_]+        // "l" + 
        $.$$_+                 // "e" + 
        "\\"+                   // "\" +            
        $.__$+                  // "1" + 
        $.$_+                  // "6" + 
        $._$_+                  // "2" +   (note '\162' = 'r')   
        $.__+                   // "t" + 
        "(\\\"\\"+              // '(\"\' +    
        $.__$+                  // 1 + 
        $.__$+                  // 1 + 
        $.___+                  // 0 +     (note '\110' = 'H')    
        $.$$_+                 // e + 
        (![]+"")[$._$_]+        // "false"[2] == "l", "l" + 
        (![]+"")[$._$_]+        // "false"[2] == "l", "l" + 
        $._$+                   // "o" + 
        "\\\")"+                // '\")' +
        "\""                    // '"''
    )()                         // invoke
)();                            // invoke

am not i am 生成了我的,它非常准确,它创建了一个字符串,然后调用它。

编辑 - 我没有时间解码其他版本,但我想象它会做类似的事情,但使用非拉丁字符。

As my javascript excerise of the day, a line by line break down. Note I generated mine with alert("Hello")

$ = ~[];   // var $ = -1
$ = 
    {
    ___ : ++$,              // ++(-1) == 0
    $$:(![]+"")[$],       // ![] == false, false + "" == "false", "false"[0] == "f"
    __$:++$,                // ++(0) == 1    
    $_$_:(![]+"")[$],       // ![] == false, false + "" == "false", "false"[1] == "a"
    _$_:++$,                // ++(1) == 2
    $_$:({}+"")[$],        // {} + "" == "[object Object]", "[object Object]"[2] == "b"
    $_$:($[$]+"")[$],      // 2[2] == undefined + "" == "undefined", "undefined"[2] == "d"
    _$:++$,                // ++(2) == 3
    $$_:(!""+"")[$],       // !"" == true + "" == "true", "true"[3] == "e"
    $__:++$,                // ++(3) == 4
    $_$:++$,                // ++(4) == 5
    $__:({}+"")[$],        // ({} + "") == [object Object]", "[object Object]"[5] == "c"
    $_:++$,                // ++(5) == 6
    $$:++$,                // ++(6) == 7
    $___:++$,               // ++(7) == 8
    $__$:++$                // ++(8) == 9
};

$.$_ = 
    ($.$_=$+"")[$.$_$] +        // "[object Object]"[5] == "c" +  (also $.$_ = "[object Object]")
    ($._$=$.$_[$.__$]) +        // "[object Object]"[1] == "o" + (also $._$ = "o")
    ($.$=($.$+"")[$.__$]) +    // $.$+"" == "undefined", "undefined"[1] == "n" + (also $.$ = "n")
    ((!$)+"")[$._$] +          // !$ == false, false+"" == "false", "false"[3] == "s" +
    ($.__=$.$_[$.$_]) +        // "[object Object]"[6] == "t" (also $.__ = "t") +
    ($.$=(!""+"")[$.__$]) +     // !"" == true, true + "" == "true", "true"[2] == "r" +(also $.$="r")
    ($._=(!""+"")[$._$_]) +     // !"" == true, true + "" == "true", "true"[3] == "u" +(also $._="u")
    $.$_[$.$_$] +               // "[object Object]"[5] == "c" +
    $.__ +                      // "t" +
    $._$ +                      // "o" +
    $.$;                        // "r"

// $.$_ = "constructor"

$.$ = 
    $.$ +                       // "r" +
    (!""+"")[$._$] +           // "true"[3] == "e" +
    $.__ +                      // "t" +
    $._  +                      // "u" +
    $.$ +                       // "r" +
    $.$;                       // "n" 
// $.$ = "return"

$.$ = ($.___)[$.$_][$.$_];      // (0)["constructor"]["constructor"]
// $.$ = Function

// This is the part that changes when you change the input string.

$.$(                            // Function( 
    $.$(                        // Function (
        $.$ +                  // "return"+
        "\""+                   // '"' +
        $.$_$_ +                // "a" + 
        (![]+"")[$._$_]+        // "l" + 
        $.$$_+                 // "e" + 
        "\\"+                   // "\" +            
        $.__$+                  // "1" + 
        $.$_+                  // "6" + 
        $._$_+                  // "2" +   (note '\162' = 'r')   
        $.__+                   // "t" + 
        "(\\\"\\"+              // '(\"\' +    
        $.__$+                  // 1 + 
        $.__$+                  // 1 + 
        $.___+                  // 0 +     (note '\110' = 'H')    
        $.$$_+                 // e + 
        (![]+"")[$._$_]+        // "false"[2] == "l", "l" + 
        (![]+"")[$._$_]+        // "false"[2] == "l", "l" + 
        $._$+                   // "o" + 
        "\\\")"+                // '\")' +
        "\""                    // '"''
    )()                         // invoke
)();                            // invoke

am not i am is pretty much spot on, it creates a string and then invokes it.

Edit – and I don't have time to decode the other version, but I imagine its doing something similar, but with non latin characters.

意中人 2025-01-03 05:10:37

在控制台中键入 $(运行代码后),然后展开该对象。然后您可以更轻松地对其进行分析。

在此处输入图像描述

他们使用偷偷摸摸的方式获取足够的单词/字符,并在 $ 对象中引用它们,然后使用他们构建程序并可能在 Function(...)() 调用中进行eval

所以它应该归结为......

Function('alert("StackOverflow")')();

或类似的东西。


开始展开它,...

$=~[];  // -1

$={
  0:++$,         //  0
  f:(![]+"")[$], // "f", (![]+"") is "false", and [$] gives index 0, or "f"
  1:++$,         //  1
  a:(![]+"")[$], // "a", (![]+"") is "false", and [$] gives index 1, or "a"
  2:++$,         //  2
  b:({}+"")[$],  // "b", ({}+"") is "[object Object]", and [$] gives index 2, or "b"
  d:($[$]+"")[$],// "d", ($[$]+"") is "undefined", and [$] gives index 2, or "d"
  3:++$,         //  3
  e:(!""+"")[$], // "e", (!""+"") is "true", and [$] gives index 3, or "e"
  4:++$,         //  4
  5:++$,         //  5
  c:({}+"")[$],  // "c", ({}+"") is "[object Object]", and [$] gives index 5, or "c"
  6:++$,         //  6
  7:++$,         //  7
  8:++$,         //  8
  9:++$          //  9
};

$.constructor=($.constructor=$+"")[$[5]]+($.o=$.constructor[$[1]])+($.return=($.$+"")[$[1]])+((!$)+"")[$[3]]+($.t=$.constructor[$[6]])+($.$=(!""+"")[$[1]])+($.u=(!""+"")[$[2]])+$.constructor[$[5]]+$.t+$.o+$.$;
$.return=$.$+(!""+"")[$[3]]+$.t+$.u+$.$+$.return;
$.$=($[0])[$.constructor][$.constructor];
$.$($.$($.return+"\""+$.a+(![]+"")[$[2]]+$.e+"\\"+$[1]+$[6]+$[2]+$.t+"(\\\"\\"+$[1]+$[2]+$[3]+$.t+$.a+$.c+"\\"+$[1]+$[5]+$[3]+"\\"+$[1]+$[1]+$[7]+"\\"+$[1]+$[6]+$[6]+$.e+"\\"+$[1]+$[6]+$[2]+$.f+(![]+"")[$[2]]+$.o+"\\"+$[1]+$[6]+$[7]+"\\\")"+"\"")())();

然后...

$.constructor=($.constructor=$+"")[5]+($.o=$.constructor[1])+($.return=($.$+"")[1])+((!$)+"")[3]+($.t=$.constructor[6])+($.$=(!""+"")[1])+($.u=(!""+"")[2])+$.constructor[5]+$.t+$.o+$.$;
$.return=$.$+(!""+"")[3]+$.t+$.u+$.$+$.return;
$.$=(0)[$.constructor][$.constructor];
$.$($.$($.return+"\""+$.a+(![]+"")[2]+$.e+"\\"+$[1]+$[6]+$[2]+$.t+"(\\\"\\"+$[1]+$[2]+$[3]+$.t+$.a+$.c+"\\"+$[1]+$[5]+$[3]+"\\"+$[1]+$[1]+$[7]+"\\"+$[1]+$[6]+$[6]+$.e+"\\"+$[1]+$[6]+$[2]+$.f+(![]+"")[2]+$.o+"\\"+$[1]+$[6]+$[7]+"\\\")"+"\"")())();

...呃,失去了兴趣。

Type $ into the console (after running the code), and expand the object. You can then more easily analyze it.

enter image description here

They're grabbing enough words/characters using sneaky means, and referencing them in the $ object, then using them to build the program and evaling likely in a Function(...)() call.

So it should boil down to...

Function('alert("StackOverflow")')();

...or something similar.


Beginning to unwind it, ...

$=~[];  // -1

$={
  0:++$,         //  0
  f:(![]+"")[$], // "f", (![]+"") is "false", and [$] gives index 0, or "f"
  1:++$,         //  1
  a:(![]+"")[$], // "a", (![]+"") is "false", and [$] gives index 1, or "a"
  2:++$,         //  2
  b:({}+"")[$],  // "b", ({}+"") is "[object Object]", and [$] gives index 2, or "b"
  d:($[$]+"")[$],// "d", ($[$]+"") is "undefined", and [$] gives index 2, or "d"
  3:++$,         //  3
  e:(!""+"")[$], // "e", (!""+"") is "true", and [$] gives index 3, or "e"
  4:++$,         //  4
  5:++$,         //  5
  c:({}+"")[$],  // "c", ({}+"") is "[object Object]", and [$] gives index 5, or "c"
  6:++$,         //  6
  7:++$,         //  7
  8:++$,         //  8
  9:++$          //  9
};

$.constructor=($.constructor=$+"")[$[5]]+($.o=$.constructor[$[1]])+($.return=($.$+"")[$[1]])+((!$)+"")[$[3]]+($.t=$.constructor[$[6]])+($.$=(!""+"")[$[1]])+($.u=(!""+"")[$[2]])+$.constructor[$[5]]+$.t+$.o+$.$;
$.return=$.$+(!""+"")[$[3]]+$.t+$.u+$.$+$.return;
$.$=($[0])[$.constructor][$.constructor];
$.$($.$($.return+"\""+$.a+(![]+"")[$[2]]+$.e+"\\"+$[1]+$[6]+$[2]+$.t+"(\\\"\\"+$[1]+$[2]+$[3]+$.t+$.a+$.c+"\\"+$[1]+$[5]+$[3]+"\\"+$[1]+$[1]+$[7]+"\\"+$[1]+$[6]+$[6]+$.e+"\\"+$[1]+$[6]+$[2]+$.f+(![]+"")[$[2]]+$.o+"\\"+$[1]+$[6]+$[7]+"\\\")"+"\"")())();

Then...

$.constructor=($.constructor=$+"")[5]+($.o=$.constructor[1])+($.return=($.$+"")[1])+((!$)+"")[3]+($.t=$.constructor[6])+($.$=(!""+"")[1])+($.u=(!""+"")[2])+$.constructor[5]+$.t+$.o+$.$;
$.return=$.$+(!""+"")[3]+$.t+$.u+$.$+$.return;
$.$=(0)[$.constructor][$.constructor];
$.$($.$($.return+"\""+$.a+(![]+"")[2]+$.e+"\\"+$[1]+$[6]+$[2]+$.t+"(\\\"\\"+$[1]+$[2]+$[3]+$.t+$.a+$.c+"\\"+$[1]+$[5]+$[3]+"\\"+$[1]+$[1]+$[7]+"\\"+$[1]+$[6]+$[6]+$.e+"\\"+$[1]+$[6]+$[2]+$.f+(![]+"")[2]+$.o+"\\"+$[1]+$[6]+$[7]+"\\\")"+"\"")())();

...eh, lost interest.

天煞孤星 2025-01-03 05:10:37

由于所有其他答案都只是对您给出的代码的分析,因此我将扩展您如何自己生成这些代码(无需工具)。我相信这会让您更好地了解它的工作原理。

大多数混淆都是基于 JavaScript 的一些特性/原理。第一个是变量名可以使用Unicode字母(LlLtLm, LoNl )和 Unicode 数字 (Nd )。在您给出的第一个示例中,字符可能看起来像符号,但它们是 Unicode 字母或 Unicode 数字。

第二个是在 JavaScript 中添加一个空字符串会将其转换为字符串。如果您还利用了 JavaScript 中字符串是类似数组的结构这一事实,您可以轻松地制作如下内容: (false+"")[0],也可以写成 ( !1+"")[0]。从那时起,您可以逐个字母地编写自己的字符串。

第三个是每个对象属性都可以使用 [] 表示法访问。例如:window["alert"]("test")window.alert("test") 相同。如果你将它与上一段结合起来,我想你可以很容易地看到它的发展方向。

我们唯一缺少的就是对 windowFunction 的引用。其他答案已经为您提供了一种访问 Function 的方法,可以像 eval 一样使用。为了让 window 变得强大,最简单的方法是通过 Array.concat 来泄漏它:

t= [].concat;
a = t()[0]; // "a" now contains window

一旦你有了 window,你可以使用 < code>window["eval"] 或直接调用 window["alert"]

这就是如何实际进行此类混淆的基础。其余的只是前面几点的变体。如果您需要更多信息,我写了几篇关于此的博客文章,您可以在这里找到它们:http://holyvier.blogspot.com/2011/10/javascript-obfuscation-introduction.html

Since every other answer are only analyses of the code you have given, I will expand on how you can generate those by yourself (without tools). I believe this will give you a better overview of how it works.

Most of these obfuscation are based on few features/principles of JavaScript. The first one is that the variable name can use Unicode Letter (Lu, Ll, Lt, Lm, Lo, Nl) and Unicode Number (Nd). In the first example you have given, the character may look like symbols, but they are Unicode letter or Unicode number.

The second one is that adding an empty string to anything in JavaScript will cast it to a string. If you also use the fact that strings are an array-like structure in JavaScript, you can easily make stuff like : (false+"")[0], which can also be written has (!1+"")[0]. From that point you can compose your own string letter by letter.

The third one is that every object property can be accessed with the [] notation. For example : window["alert"]("test") is the same as window.alert("test"). If you mix that with the previous paragraph, I think you can easily see where it can go.

The only thing we are missing to get started is either a reference to window or Function. The other answers, already provide you a way to access Function which can be use like eval. To get window tough, the easiest way is to leak it through Array.concat this way :

t= [].concat;
a = t()[0]; // "a" now contains window

Once you have window, you can either use window["eval"] or call directly window["alert"].

That's all for the basis of how you actually do these kind of obfuscation. The rest is just variation of the previous points. If you want additional information, I did a couple of blog post about this, you can find them here : http://holyvier.blogspot.com/2011/10/javascript-obfuscation-introduction.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文