<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Guy Rutenberg &#187; JavaScript</title>
	<atom:link href="http://www.guyrutenberg.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A JavaScript DOS Attack</title>
		<link>http://www.guyrutenberg.com/2007/11/23/a-javascript-dos-attack/</link>
		<comments>http://www.guyrutenberg.com/2007/11/23/a-javascript-dos-attack/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 21:30:29 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/2007/11/23/a-javascript-dos-attack/</guid>
		<description><![CDATA[In this post I will present a way of creating a JavaScript based DOS attack that utilizes the bad implementation of tabs in most (if not all) web-browsers. The attack will make the browser unresponsive and force the user to kill its process. This attack is based on the following JavaScript code:


&#60;script type=&#34;text/javascript&#34;&#62;
while&#40;1&#41; &#123;
  [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I will present a way of creating a JavaScript based DOS attack that utilizes the bad implementation of tabs in most (if not all) web-browsers. The attack will make the browser unresponsive and force the user to kill its process. This attack is based on the following JavaScript code:<br />
<span id="more-29"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;DOS&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This simple attack, can be much more annoying then it looks, due to the popularity of tab enabled web-browsers such as Firefox and IE7.<br />
In todays web-browsers, if a JavaScript alert pops-up the user must dismiss it before doing anything else. That includes things like switching tabs, closing the open tab, opening menus and etc. If you want to see how annoying this little code can be, just go to <a href="/wp-content/uploads/2007/11/alertloop.html">this page</a> (warning: this will turn your browser unresponsive and will force you to kill it).</p>
<p>As you can see this small script will turn your web-browser completely unresponsive and thus force you to kill it. The first instinct will be restore the crashed session, but it won&#8217;t be possible, as it will reopen the page with the malicious code. So you will have to start your a new session and reopen each tab manually. This small script allowed a malicious user, to force you to crash your own web-browser, while loosing data (unsent email, blog post, or any kind of unsaved form data), without you having any option to prevent it. </p>
<p>When I say you don&#8217;t have any option to prevent it, I say because this code might be in a link a friend send you as a way to annoy you, or in a legitimate web-site which been a victim of JavaScript injection attack. Yes, you can completely protect your self from this by surfing with JavaScript turned off, but many modern website won&#8217;t work, turning this option useless (you would deny yourself any service from many AJAX enabled sites).</p>
<p>To solve this situation we need to take a look at what caused it. Let&#8217;s say the malicious site has been open in its own web-browser instance. In this case you would just kill this instance and continue browsing in the other open windows. But when you open several other sites in the same instance using tabs, you will have to close all of them. This happened because there isn&#8217;t enough separation between tabs. In this case a page loaded in one effects all other opened tabs.</p>
<p>In order to fix and prevent this kind of DOS attack, browser developers need to take a new approach of separation between tabs.</p>
<ul>
<li> In under no circumstances one tab should be able to effect other tabs&#8217; status.</li>
<li> Also tab shouldn&#8217;t be able to prevent the user from closing it or switching to another tab.</li>
<li> JavaScript alerts shouldn&#8217;t be modal. They could be implemented in a way so they prevent any action within the tab until they are dismissed, but in no way they should be able to prevent actions in other tabs.
<li>
</ul>
<p>I&#8217;m no web-browser developer, but this shouldn&#8217;t be too hard to implement in order to fix such old, yet annoying problem, which becomes much more annoying in a tabbed web-browsing environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2007/11/23/a-javascript-dos-attack/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Tracking MediaWiki External Links Statistics using Google Analytics</title>
		<link>http://www.guyrutenberg.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/</link>
		<comments>http://www.guyrutenberg.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 16:06:44 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MediaWiki]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://guy.sikumuna.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/</guid>
		<description><![CDATA[When you track MediaWiki statistics, you usually track only internal page statistics, but tracking external links which leads out of your site is not some thing you can ignore. Unfortunately we probably can&#8217;t put actual tracking code in the pages linked to by our site&#8217;s external links. Fortunately we can track the actual clicks on [...]]]></description>
			<content:encoded><![CDATA[<p>When you track MediaWiki statistics, you usually track only internal page statistics, but tracking external links which leads out of your site is not some thing you can ignore. Unfortunately we probably can&#8217;t put actual tracking code in the pages linked to by our site&#8217;s external links. Fortunately we can track the actual clicks on those links that lead out of the site, and it&#8217;s quite easy to do when tracking statistics with Google Analytics. If you don&#8217;t already use Google Analytics with your MediaWiki site, open a new account in Google Analytics and see my previous post: <a href="/2007/07/13/track-mediawiki-statistics-using-google-analytics/">Track MediaWiki Statistics using Google Analytics</a>.</p>
<p><span id="more-7"></span>Now we two possible ways to add the tracking code to each external link. The first one is to hack the MediaWiki internal parser for wiki code to generate additional code for each link. While this way will probably work the best it&#8217;s pretty complicated and not straightforward. The other way, which is the one will follow, is to use a small JavaScript snippet which will will iterate through the links in every page and add an &#8220;onClick&#8221; attribute to them with the tracking code.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> links <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> links.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;external text&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                addtrackcode<span style="color: #009900;">&#40;</span>links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addtrackcode<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        obj.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onClick'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;javascript:urchinTracker('/outgoing/&quot;</span><span style="color: #339933;">+</span> obj.<span style="color: #660066;">href</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;://&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;');&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This code snippet should go between you Google Analytics code and the<code> &lt;/body&gt;</code> tag, meaning you can add it to <code>/wiki/skins/monobook.php</code> if you haven&#8217;t changed the default skin for your MediaWiki. After the code is in place it may take up to 48 hours (usually you don&#8217;t have to wait at all) for the external links statistics to show up in the Google Analytics. In the Google Analytics the statistics for clicking on an external link which leads to <a href="http://www.google.com">http://www.google.com</a> will show up as view of the page /outgoing/www.google.com. This script will also track download statistics of files which are linked from the wiki pages (like pdf&#8217;&#8217;s and such).</p>
<p>While this code does the job, it has a drawbacks. It only tracks the external links created by wiki code (e.g. <code>[http://example.com]</code>) as it uses CSS classes to determine what is external link. However this drawback isn&#8217;t very important and overall the script does a decent job tracking the external links in MediaWiki using Google Analytics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.450 seconds -->
