Skip to main content

How can I say "love' without character or digits in JavaScript?


Inspired by Ryan Barnett's PPT of BlackHat DC 2011, especially the code below:




($=[$=[]][(__=!$+$)[_=-~-~-~$]+({}+$)[_/_]+ ($$=($_=!''+$)[_/_]+$_[+$])])()[__[_/_]+__ [_+~$]+$_[_]+$$](_/_)



Yesterday was special day for lovers, so I tried to write something similar. Which basically alert "I love you" without any character or digits.



e.g. "I" can be obtained from ((_=-~[])/--_+[])[_]



we have "[object Object]", "true", "false", "NaN", "Infinity" to use, I cannot figure out a way to get "v" this way.



I tried to think of String.fromCharCode() , (Ryan already get window reference for us, so in theory, we can window["String"]["fromCharCode"](118) ) however I miss "S" and "C" character here. Also think about window["eval"](...) , again, I have no "v".



Just try to explain a little bit, [] is empty, when apply +/-/~ operate to it, it converts to number 0 , and ~[] gives 1 , 1/0 gives Infinitey . Then it comes to 1/0 + [] , they will both converted to string for the add, which gives "Infinity" , and "Infinity"[_] == "Infinity"[0] == "I" ...



The original code of Ryan is more complex, it utilized a lot more, includes scope, special return value, etc. (this is another story)



This might not seem to be a great idea to do things, but just very interesting.



With help with meze, I was able to produce this for Firefox:




($=($=[$=[]][(__=!$+$)[_=-~-~-~$]+(_$={}+$)[_/_]+ ($$=($_=!''+$)[_/_]+$_[+$])])())[__[_/_]+__ [_+~$]+$_[_]+$$]((_$_=(__$=-~[])/--__$+[])[__$]+_$[_+++_]+__[__$=-~-~[]]+_$[-~[]]+($[_$[$__=_+_]+_$[++$__]+_$[++$__]+_$[++$__]+_$[++$__]+_$[++$__]]+[])[
$__+$__+--_]+__[++_]+_$[$__=_+--_]+_$_[_+++_]+_$[_/_]+$_[__$]);



it basically is alert("I love you") , many thanks! If only I get the help yesterday, which I have not post this yet :(



JavaScript is beautiful, some varibles for your reference:




$_ = "true"
__ = "false"
_$ = "[object Object]"
$$ = "rt"
_$_ = "Infinity"
_ = 3 = 4 = 3 = 4 = 3
$ = window
$__ = 8 = 13
__$ = 0 = 2



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 eval() lots of... things easier. I will show this to my wife, hope she enjoys the _$-+()...



example as your reference: http://jsfiddle.net/Y4wqw/



btw, we can shorten the code a bit, as we already have reference to sort() , which can be used instead of window["Object"] to get the "native code" => "v", here it is:




($=($_$=($=[$=[]][(__=!$+$)[_=-~-~-~$]+(_$={}+$)[_/_]+ ($$=($_=!''+$)[_/_]+$_[+$])]))())[__[_/_]+__ [_+~$]+$_[_]+$$]((_$_=(__$=-~[])/--__$+[])[__$]+_$[_+++_]+__[__$=-~-~[]]+_$[-~[]]+($_$+[])[(__$<<__$<<__$)-_+~[]]+$_[--_]+_$[$__=_+++_]+_$_[_+--_]+_$[_/_]+$_[__$]);



Again, it works only in Firefox, might not try to migrate to other browser. And I love Firefox.


Source: Tips4allCCNA FINAL EXAM

Comments

  1. Well at least in Firefox, JavaScript native objects return function Object() { [native code] }, which has 'v'. So if we have window and Object, then i suppose we could do:

    (window["Object"]+0)[29];

    ReplyDelete
  2. Same message, but different spelling.

    // "I <3 u"
    _= +~[]; // 1
    __= -[]; // 0
    ___= +(-~[] -~[] -~[]); // 3
    $=''
    +(''+(_/__))[__] // i
    +' ' // space
    +'<'+___ // <3
    +' ' // space
    +(''+(_<__))[+(-~[] -~[])]; // u
    alert($);


    jsfiddle link

    ReplyDelete
  3. try this code:

    $=(Å='',[Ç=!(µ=!Å+Å)+{}][Ç[È=++Å-~Å]+Ç[È+È]+µ[Å]+µ[Å-Å]])();
    _=$[Ç[È+È+Å]+µ[Å-Å]+Ç[È+È]+Ç[Å]]("¾");
    console.info( _[+[]] ); // concole is used just to show result ;)


    if you run it, on the console you will get "v" :), more info about it can be found there

    there is a way to avoid "¾", but result will be "V" (actually nothing bad for such a word like love :):

    $=(Å='',[Ç=!(µ=!Å+Å)+{}][Ç[È=++Å-~Å]+Ç[È+È]+µ[Å]+µ[Å-Å]])(); // we get window object
    _=$[Ç[È+È+Å]+µ[Å-Å]+Ç[È+È]+Ç[Å]]( $ ); // we use btoa function with argument "[object Window]",
    // and it returns "W29iamVjdCBXaW5kb3dd" - as you see there is V
    $$=-~!''; // 2
    $$$=-~$$; // 3
    console.info( _[$$*$$$] ); // "V";


    btoa creates encoded data from the given string, using base-64 encoding. Actually playing with that function and changing arguments you can get different characters :)

    ReplyDelete
  4. alert("\u2665"); // results in ♥

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex