<?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>Web App Security &#187; CAPTCHA</title>
	<atom:link href="http://www.idontplaydarts.com/tag/captcha/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.idontplaydarts.com</link>
	<description>PHP &#38; LAMP Stack Security</description>
	<lastBuildDate>Mon, 23 Jan 2012 09:54:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Extending Burp Suite to solve reCAPTCHA</title>
		<link>http://www.idontplaydarts.com/2012/01/extending-burp-suite-to-solve-recaptcha/</link>
		<comments>http://www.idontplaydarts.com/2012/01/extending-burp-suite-to-solve-recaptcha/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 11:44:29 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Burp]]></category>
		<category><![CDATA[Burp Extender]]></category>
		<category><![CDATA[CAPTCHA]]></category>

		<guid isPermaLink="false">http://www.idontplaydarts.com/?p=717</guid>
		<description><![CDATA[By extending the Burp Suite and integrating it with a CAPTCHA solving farm you can enable the automated bypassing of CAPTCHA within all burp tools; seamlessly replacing all CAPTCHA with their correct solutions. This post will show how I&#8217;ve extended &#8230; <a href="http://www.idontplaydarts.com/2012/01/extending-burp-suite-to-solve-recaptcha/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">By extending the <a href="http://portswigger.net/burp/help/" rel="nofollow">Burp Suite</a> and integrating it with a <a href="http://www.blackhat-seo.com/2009/captcha-farms/" rel="nofollow">CAPTCHA solving farm</a> you can enable the automated bypassing of CAPTCHA within all burp tools; seamlessly replacing all CAPTCHA with their correct solutions. This post will show how I&#8217;ve extended Burp and integrated it with the <a href="http://www.deathbycaptcha.com" rel="nofollow">DeathByCaptcha API</a> to solve reCAPTCHA.</p>
<p style="text-align: justify;">Several services exist for decoding CAPTCHA, although DeathByCaptcha seems pretty good and from the initial tests I&#8217;m seeing a 99.7% accuracy rate (with reCAPTCHA at least) &#8211; The premise for most of these services is simple, upload your CAPTCHA to the API and poll for a response until it is solved by someone at the other end. DeathByCaptcha currently charges $13.90 per 10,000 solutions. The API is a simple REST interface and it normally takes only a few seconds to decode the image.</p>
<p style="text-align: justify;"><strong>The concept:</strong><br />
<a href="http://portswigger.net/burp/extender/" rel="nofollow">Burp Extender</a> allows you to hook and modify all HTTP responses before they are used by any of the tools in the Burp Suite. The idea behind the Burp Extender extension I&#8217;ve written is to intercept all of the HTTP responses, examine them for the reCAPTCHA script and replace the input fields with the solution from DeathByCaptcha. This will effectively turn reCAPTCHA into a nonce or one-time-token which <a href="http://blog.portswigger.net/2011/03/burp-v14-preview-macros.html">Burp 1.4 macros</a> can easily handle in a similar way to CSRF tokens.</p>
<p><span id="more-717"></span></p>
<p style="text-align: justify;"><strong>How it works:</strong><br />
I&#8217;ve chosen <a href="http://www.recaptcha.org" rel="nofollow">reCAPTCHA</a> as the target as its widely used – it also has the advantage that the solution can be directly validated against Google servers so you can check that the solution is correct before you post it to the target domain. The general structure of my Burp Extension looks like this:</p>
<p><a href="http://www.idontplaydarts.com/wp-content/uploads/2012/01/HSRA.png"><img class="size-full wp-image-718 alignnone" title="Burp Extender Flow Chart" src="http://www.idontplaydarts.com/wp-content/uploads/2012/01/HSRA.png" alt="" width="742" height="562" /></a></p>
<p>To summarise the above the main steps are:</p>
<ul>
<li>Extract the reCAPTCHA site key from the Intercepted Server Response – these match the expression “6[A-Za-z\-_]{39}”</li>
<li>Use the site key to request the Iframe that contains a link to a CAPTCHA image.</li>
<li>Extract the reCAPTCHA JPEG location and reCAPTCHA challenge field from the Iframe HTML source.</li>
<li>Post the JPEG to DeathByCaptcha for solving.</li>
<li>Post the solution to the Iframe location.</li>
<li>Obtain the challenge response from the reply from the previous post and modify the initial HTTP Response to contain the challenge/response codes.</li>
</ul>
<p><strong>Compiling:<br />
</strong>To compile ensure you have the Java SDK installed and issue the following commands:</p>
<p style="padding-left: 30px;"><em>javac.exe BurpExtender.java</em><br />
<em>jar.exe -cf BurpExtender.jar BurpExtender.class</em></p>
<p>This should generate a burpExtender.jar file in the working directory.</p>
<p style="text-align: justify;"><strong>Running:<br />
</strong>The extension takes two command line arguments. The username and password for the DeathByCaptcha API (so if you want to run the extension you&#8217;ll need to sign up to the service). To run the extension make sure the extension is located in the same directory as the Burp Suite and run:</p>
<p style="padding-left: 30px;"><em>java -Xmx512m -classpath &#8220;*&#8221; burp.StartBurp &#8220;myusername&#8221; &#8220;mypassword&#8221;</em></p>
<p style="text-align: justify;">When you now browse through the Burp Proxy to sites such as <a href="http://www.google.com/recaptcha/learnmore" rel="nofollow">http://www.google.com/recaptcha/learnmore</a> you should see the reCAPTCHA replaced with a challenge and response input box. Generally the API can take anywhere from 5 to 20 seconds to translate the CAPTCHA, while this is happening the page will not load. Once its decoded the image you should see something similar to below:</p>
<div id="attachment_740" class="wp-caption aligncenter" style="width: 631px"><a href="http://www.idontplaydarts.com/wp-content/uploads/2012/01/beforeafter.png"><img class="size-full wp-image-740" title="Before and After" src="http://www.idontplaydarts.com/wp-content/uploads/2012/01/beforeafter.png" alt="" width="621" height="185" /></a><p class="wp-caption-text">(Before / After - When browsing through the Burp Proxy)</p></div>
<p style="text-align: justify;">The code isn&#8217;t pretty &#8211; its been hacked together &#8211; its more proof of concept. There isn&#8217;t a great deal of error handling and not being a Java Developer I may have used entirely the wrong methods in certain places.</p>
<p style="text-align: center;"><strong><a href="http://www.idontplaydarts.com/wp-content/uploads/2012/01/BurpExtender-reCAPTCHA.zip">Download the reCAPTCHA Burp Extension here</a></strong></p>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://www.idontplaydarts.com/2012/01/extending-burp-suite-to-solve-recaptcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exploit: PHPCaptcha / Securimage is not secure.</title>
		<link>http://www.idontplaydarts.com/2011/05/exploit-phpcaptcha-securimage/</link>
		<comments>http://www.idontplaydarts.com/2011/05/exploit-phpcaptcha-securimage/#comments</comments>
		<pubDate>Wed, 25 May 2011 10:00:20 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Exploits]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CAPTCHA]]></category>
		<category><![CDATA[Design Flaw]]></category>
		<category><![CDATA[Exploit]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.idontplaydarts.com/?p=307</guid>
		<description><![CDATA[Recently I discovered an easy way to bypass PHPCaptcha also known as SecurImage. The method described below will break the CAPTCHA every time, without fail and affects versions 1.0.4 and above. Previous versions are also probably vulnerable tho only exploit &#8230; <a href="http://www.idontplaydarts.com/2011/05/exploit-phpcaptcha-securimage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Recently I discovered an easy way to bypass <a href="http://www.phpcaptcha.org/" rel="nofollow">PHPCaptcha also known as SecurImage</a>. The method described below will break the CAPTCHA every time, without fail and affects versions 1.0.4 and above. Previous versions are also probably vulnerable tho only exploit code for the MP3 file format (implemented as default since version 2.0.0) is provided.</p>
<p style="text-align: justify;">The flaw in the CAPTCHA stems from the way MP3 and WAV audio codes, intended for use by by the visually impaired, are generated. It is worth noting that even when the user of the site has removed the audio functionality from their displayed CAPTCHA the functionality can still be accessed via <a href="https://www.owasp.org/index.php/Forced_browsing" rel="nofollow">forceful browsing</a> to the file called &#8220;/securimage_play.php&#8221;. This means that unless the administrator of the site has removed the securimage_play.php file that their site is vulnerable to attack.</p>
<p style="text-align: justify;">The audio codes that are generated by PHPCaptcha are created by concatenating a set of audio files (that are publicly accessible in /audio directory). To prevent simple binary analysis of the output the author randomly changes the value of every 64th byte in the generated audio file starting from an initial offset that is also defined by a random integer in the range 1-64. The effect of the mutation means that when you listen to the audio its very hard to determine what letters are being heard. The code used for the mutation is shown below:</p>
<pre class="brush: php; title: ; notranslate">
    function scrambleAudioData(&amp;$data, $format)
    {
        if ($format == 'wav') {
            $start = strpos($data, 'data') + 4;
            if ($start === false) $start = 44;
        } else { // mp3
            $start = 4;
        }

        $start  += rand(1, 64);
        $datalen = strlen($data) - $start - 256;

        for ($i = $start; $i &lt; $datalen; $i += 64) {
            $ch = ord($data{$i});
            if ($ch &lt; 9 || $ch &gt; 119) continue;

            $data{$i} = chr($ch + rand(-8, 8));
        }
    }
</pre>
<p style="text-align: justify;">While this prevents simple binary analysis of the generated audio it does not prevent an attacker from building a list of 64 byte strings from the publicly accessible audio samples and using these in comparison against the concatenated audio file. By determining where in the file these strings occur its possible to decode the CAPTCHA with a 100% success rate. The decision by the author to change only the 64th byte of the final audio file is a fatal design flaw.</p>
<p style="text-align: justify;">You can <a href='http://www.idontplaydarts.com/wp-content/uploads/2011/05/POC-explot.zip'>download the PHPCaptcha exploit</a> capable of decoding the MP3 CAPTCHA format. It is currently configured to run against the &#8220;sample_form.php&#8221; script that comes by default with SecurImage / PHPCaptcha. Below is a video of the exploit running:</p>
<p><object style="height: 390px; width: 640px"><param name="movie" value="http://www.youtube.com/v/qqfk_Jt-pnw?version=3"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><embed src="http://www.youtube.com/v/qqfk_Jt-pnw?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"></object></p>
<p style="text-align: justify;">No fix is currently available from the author. The only current solution is to remove the securimage_play.php script from your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.idontplaydarts.com/2011/05/exploit-phpcaptcha-securimage/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

