<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Xblog: Tag browser</title>
    <link>http://xblog.xman.org/articles/tag/browser</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>hey, if it has a capital X in it, it has to be great!</description>
    <item>
      <title>Anatomy of Javascript Hack</title>
      <description>&lt;p&gt;NOTE: Several of the links in this article point to the original Javascript of this exploit or transformations of the original Javascript. If you actually execute the Javascript you will be performing the exploit. I suggest readers download the links and &lt;em&gt;then&lt;/em&gt; look at the source in an editor, rather than clicking on the link and risking their browser attempting to execute the Javascript. I&amp;#8217;ve set the content types of these links to &amp;#8220;text&amp;#8221; in order to minimize the risk of this, and I&amp;#8217;m sorry if that creates an inconvenience.&lt;/p&gt;

&lt;p&gt;One of the user groups I participate in is the &lt;a href="http://uuasc.org/" title="UUASC"&gt;UUASC&lt;/a&gt;. Recently, one of the &lt;strike&gt;BOFH&lt;/strike&gt;SysAdmins in the group posted a rather cryptic bit of Javascript that they saw flowing over their network. Their question was pretty simple. What does &lt;a href="/files/exploit.js" title="the raw exploit source, don't execute this"&gt;this&lt;/a&gt; do?&lt;/p&gt;

&lt;p&gt;So starting with the outer bits of the code first, it is pretty clear that the bulk of the message is escaped Javascript which is fed in to eval. Not exactly a good sign, but not necessarily a bad thing. The first step I took was to unescape the relevant data (without performing the eval of course), which yielded &lt;a href="/files/exploit2.js" title="the unescaped exploit"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The source was clearly obfuscated, so I went through it, cleaned up the formatting and attempted to assign more meaningful names to variables and functions. This yielded &lt;a href="/files/exploit3.js" title="deobfuscated exploit"&gt;this&lt;/a&gt;. The transform1 function included a use of eval(someString.replace(/blah/, &amp;#8221;)), which was clearly just a way of obfuscating how myCallee was computed, so I performed the replace and substituted the result, yielding &lt;a href="/files/exploit4.js" title="exploit plainly using arguments.callee"&gt;this much clearer source&lt;/a&gt;, which shows that myCallee is actually the function itself!&lt;/p&gt;

&lt;p&gt;So, it now becomes clear that the obfuscation of transform1 was not entirely random in nature, as the source itself was used as part of the key to decode the &amp;#8220;payload&amp;#8221; (the string passed in to transform1 after its definition). The easiest way to accurately decode this was to create both the original fpTu function in all its obfuscated glory, then set myCallee to fpTu in transform1, and then see &lt;a href="/files/exploit5.js"&gt;what we got back from transform1 when we passed it the payload&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Not surprisingly, we have another somewhat obfuscated chunk of Javascript. After reformatting it (thank you Steve Yegge for &lt;a href="http://code.google.com/p/js2-mode/" title="yes, it is safe to just follow this link"&gt;js2-mode&lt;/a&gt; and providing some more meaningful function and variable names, the payload now looks like &lt;a href="/files/exploit6.js"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are still a bunch of places where the replace(/blah/, &amp;#8221;) idiom is being used to obfuscate things, and another place where a variant is used where all alphanumeric values are being replaced with a period, and then all instances of multiple periods are replaced with a single one. After unraveling those, the intent of the code becomes clear and we can attach more meaningful names to the functions and variables. Thus I ended up with &lt;a href="/files/exploit71.js"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We can now see that the code points to 3traff.cn (don&amp;#8217;t you feel safer already? ;-), and it cleverly embeds an iframe pointing to 3traff.cn in to each document as it is loaded. I&amp;#8217;m not up on my browser exploits, but it looks like the intent of all this is to at the very least track users as they go off site, and also might be hoping to confuse a browser about which domain a document came from, and therefore potentially cause cookies to leak to 3traff. Either way, this isn&amp;#8217;t the kind of code I like running in my browser.&lt;/p&gt;</description>
      <pubDate>Fri, 02 May 2008 11:28:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c2549042-a538-415f-801e-a5f0c5e199f2</guid>
      <author>Christopher Smith</author>
      <link>http://xblog.xman.org/articles/2008/05/02/anatomy-of-a-javascript-exploit</link>
      <category>Programming</category>
      <category>Security</category>
      <category>security</category>
      <category>javascript</category>
      <category>browser</category>
      <category>hack</category>
      <enclosure type="application/x-javascript" url="http://xblog.xman.org/files/exploit71.js" length="1348"/>
    </item>
    <item>
      <title>Once again, Safari makes the world look better.</title>
      <description>&lt;p&gt;So, if you&amp;#8217;ve been reading this blog much, you&amp;#8217;ve undoubtedly been noticing its completely lack luster performance. I&amp;#8217;ve been trying to isolate the problem, and frankly I&amp;#8217;ve been getting frustrated enough that I&amp;#8217;ve considered just writing my own blogging software that merely shares &lt;a href="http://typosphere.org/" title="Typo"&gt;Typo&lt;/a&gt;&amp;#8217;s database back end.&lt;/p&gt;

&lt;p&gt;Instead of doing that, I noticed that despite updates to the software on my system, I was still running an old version of Typo. It turns out you have to explicitly upgrade each deployment of Typo (not necessarily a bad thing). As always, there is an easy way to do this&amp;#8230;. and it didn&amp;#8217;t work for me (probably &lt;a href="http://ars.userfriendly.org/cartoons/?id=19980506" title="PEBKAC - User Friendly"&gt;PEBKAC&lt;/a&gt;, but nonetheless frustrating). Anyway, after several false starts, I managed to upgrade to Typo 4.1.1.&lt;/p&gt;

&lt;p&gt;There are a number of improvements that have come with upgrade that look to make life better on xblog. Oddly though, the new theming seems to be completely broken &amp;#8211;except for on Safari. Yup, if you are looking at this with anything other than &lt;a href="http://www.apple.com/safari/" title="Safari"&gt;Safari&lt;/a&gt; (actually, I haven&amp;#8217;t tested with Opera yet), you are probably seeing a pretty ugly looking site. &lt;a href="http://www.mozilla.com/firefox/" title="Firefox"&gt;Firefox&lt;/a&gt; shows the site as broken on Linux, Mac, and Windows. &lt;a href="http://www.microsoft.com/windows/products/winfamily/ie/default.mspx" title="Internet Explorer 7"&gt;IE7&lt;/a&gt; looks the same.&lt;/p&gt;

&lt;p&gt;I haven&amp;#8217;t diagnosed the how and the why behind all this, because I&amp;#8217;ve been stunned by the downright awesomeness of this. The problem seems likely related to stylesheets, but for the life of me I am trying to figure out what is so different about my setup from a typical Typo configuration, and more importantly just look in awe at Safari.&lt;/p&gt;</description>
      <pubDate>Mon, 27 Aug 2007 08:06:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:41b0ed24-4444-4b4b-82db-b3dd65207671</guid>
      <author>Christopher Smith</author>
      <link>http://xblog.xman.org/articles/2007/08/27/once-again-safari-makes-the-world-look-better</link>
      <category>Errata</category>
      <category>typo</category>
      <category>safari</category>
      <category>browser</category>
      <category>themes</category>
    </item>
  </channel>
</rss>
