

Showing impossible to understand Javascript: Obfuscated Quine - vshlos
http://oim.ae/nL9Yie

======
dhbanes
Why does it only work in Chrome?

~~~
DCoder
1\. Function to String conversion produces different results in different
browsers.

    
    
      var f = []['concat']; (f + ''); 
      // Chrome
      "function concat() { [native code] }"
      // IE (9)
      "
      function concat() {
        [native code]
      }
      "
    

This script tries to extract letters from that string representation, which
fails if the string is different. (This is also used as an anti-debugging
measure in some JS malware, to prevent researchers from replacing
document.write with alert() or similar.)

2\. Iterating over the window object doesn't work the same way in IE:
[http://blogs.msdn.com/b/ericlippert/archive/2005/05/04/41468...](http://blogs.msdn.com/b/ericlippert/archive/2005/05/04/414684.aspx)

In particular, this script tries to extract strings 'sessionStorage',
'getComputedStyle', 'onchange' by iterating over the window object, all of
whom fail in IE.

~~~
vshlos
Good job on figuring it out! Thanks for spending the time.

------
DCoder
Nice trick!

    
    
      var f = []['concat']; // Array.prototype.concat
      f()[0]; // returns the global window
    

The rest of the script appears to mostly be old tricks - convert stuff to
strings, combine characters in strings to compose expressions, pass them to
eval...

