Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I say "love" without character or digits in JavaScript?
    text
    copied!<p>Inspired by Ryan Barnett's PPT of BlackHat DC 2011, especially the code below:</p> <pre><code>($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+ ($$=($_=!''+$)[_/_]+$_[+$])])()[__[_/_]+__ [_+~$]+$_[_]+$$](_/_) </code></pre> <p>Yesterday was special day for lovers, so I tried to write something similar. Which basically alert "I love you" without any character or digits.</p> <p>e.g. "I" can be obtained from <code>((_=-~[])/--_+[])[_]</code></p> <p>we have "[object Object]", "true", "false", "NaN", "Infinity" to use, I cannot figure out a way to get "v" this way.</p> <p>I tried to think of <code>String.fromCharCode()</code>, (Ryan already get <code>window</code> reference for us, so in theory, we can <code>window["String"]["fromCharCode"](118)</code>) however I miss "S" and "C" character here. Also think about <code>window["eval"](...)</code>, again, I have no "v".</p> <p>Just try to explain a little bit, <code>[]</code> is empty, when apply <code>+/-/~</code> operate to it, it converts to number <code>0</code>, and <code>~[]</code> gives <code>1</code>, <code>1/0</code> gives <code>Infinitey</code>. Then it comes to <code>1/0 + []</code>, they will both converted to string for the add, which gives <code>"Infinity"</code>, and <code>"Infinity"[_] == "Infinity"[0] == "I"</code>...</p> <p>The original code of Ryan is more complex, it utilized a lot more, includes scope, special return value, etc. (this is another story)</p> <p>This might not seem to be a great idea to do things, but just very interesting.</p> <p>With help with meze, I was able to produce this for Firefox:</p> <pre><code>($=($=[$=[]][(__=!$+$)[_=-~-~-~$]+(_$={}+$)[_/_]+ ($$=($_=!''+$)[_/_]+$_[+$])])())[__[_/_]+__ [_+~$]+$_[_]+$$]((_$_=(__$=-~[])/--__$+[])[__$]+_$[_+++_]+__[__$=-~-~[]]+_$[-~[]]+($[_$[$__=_+_]+_$[++$__]+_$[++$__]+_$[++$__]+_$[++$__]+_$[++$__]]+[])[ $__+$__+--_]+__[++_]+_$[$__=_+--_]+_$_[_+++_]+_$[_/_]+$_[__$]); </code></pre> <p>it basically is <code>alert("I love you")</code>, many thanks! If only I get the help yesterday, which I have not post this yet :(</p> <p>JavaScript is beautiful, some varibles for your reference:</p> <pre><code>$_ = "true" __ = "false" _$ = "[object Object]" $$ = "rt" _$_ = "Infinity" _ = 3 = 4 = 3 = 4 = 3 $ = window $__ = 8 = 13 __$ = 0 = 2 </code></pre> <p>Some variables are reused many times, will not try to leave details, it is not a fun job :) I am happy, we are finally here! This actually has lots of potential, as we now have "v", and lots of digits, we will in theory possible to <code>eval()</code> lots of... things easier. I will show this to my wife, hope she enjoys the _$-+()...</p> <p>example as your reference: <a href="http://jsfiddle.net/Y4wqw/">http://jsfiddle.net/Y4wqw/</a></p> <p>btw, we can shorten the code a bit, as we already have reference to <code>sort()</code>, which can be used instead of window["Object"] to get the "native code" => "v", here it is: </p> <pre><code>($=($_$=($=[$=[]][(__=!$+$)[_=-~-~-~$]+(_$={}+$)[_/_]+ ($$=($_=!''+$)[_/_]+$_[+$])]))())[__[_/_]+__ [_+~$]+$_[_]+$$]((_$_=(__$=-~[])/--__$+[])[__$]+_$[_+++_]+__[__$=-~-~[]]+_$[-~[]]+($_$+[])[(__$&lt;&lt;__$&lt;&lt;__$)-_+~[]]+$_[--_]+_$[$__=_+++_]+_$_[_+--_]+_$[_/_]+$_[__$]); </code></pre> <p>Again, it works only in Firefox, might not try to migrate to other browser. And I love Firefox.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload