<?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>habdas.org &#187; HTTP</title>
	<atom:link href="http://www.habdas.org/tag/http/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.habdas.org</link>
	<description>The technical blog of Josh Habdas</description>
	<lastBuildDate>Thu, 02 Sep 2010 02:06:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Anatomy of a Google 302 Redirect Hijack</title>
		<link>http://www.habdas.org/2009/10/18/google-302-redirect-hijack/</link>
		<comments>http://www.habdas.org/2009/10/18/google-302-redirect-hijack/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 00:48:07 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Digital Security]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[proxies]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[social engineering]]></category>
		<category><![CDATA[user agent]]></category>

		<guid isPermaLink="false">http://www.habdas.org/?p=921</guid>
		<description><![CDATA[Recently while Googling &#8220;Olla de Carne&#8221; (Costa Rican beef stew) my browser was hijacked after taking a search results link. Rather than receiving a list of ingredients, the link redirected the browser to a bogus antivirus site that mimicked Windows and faked an integrated Explorer virus scan (see screenshot below or watch the video). After a few [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: normal; font-size: 13px;">Recently while Googling &#8220;Olla de Carne&#8221; (Costa Rican beef stew) my browser was <a href="http://en.wikipedia.org/wiki/Page_hijacking">hijacked</a> after taking a search results link. Rather than receiving a list of ingredients, the link redirected the browser to a bogus antivirus site that mimicked Windows and faked an integrated Explorer virus scan (see screenshot below or <a class="youtube" href="http://www.youtube.com/v/gnZSOMdp9oI">watch the video</a>).</span></p>
<p><span style="font-weight: normal; font-size: 13px;"><span id="more-921"></span></span></p>
<div id="attachment_1017" class="wp-caption alignright" style="width: 310px"><a class="youtube" href="http://www.youtube.com/v/gnZSOMdp9oI"><img class="size-medium wp-image-1017" title="Fake Scan" src="http://www.habdas.org/wp-content/uploads/2009/10/totalscam-fauxdialog-300x248.png" alt="Fake virus scan running in Google Chrome" width="300" height="248" /></a><p class="wp-caption-text">Fake virus scan running in Google Chrome</p></div>
<p>After a few seconds on the page the following occurred:</p>
<ul>
<li>Result page successfully hijacked and a faux Windows Explorer interface loaded.</li>
<li>A fake virus scan ran in the look-alike Explorer window, conveniently uncovering trojans and other malware.</li>
<li>Alerts, dialogs and phony windows displayed in an attempt to execute a little <a href="http://en.wikipedia.org/wiki/Social_engineering_(security)">social engineering</a>.</li>
</ul>
<p>After attempting to interact with the document the following occurred:</p>
<ul>
<li>A potentially threatening program file download initiated if you clicked on anything in the page.</li>
<li>Additional warning dialog and pop-up window displayed on attempting to unload the page (e.g. hit the back button).</li>
<li>Intermittently, the Google Chrome 3.0 back-button and tab [x] icon stopped functioning as expected.</li>
</ul>
<p>The last point was of particular interest at first, as it is not like modern browsers to allow websites to modify browser functionality. But after some additional research, it was clear the hijack was more complex than a page titled with search engine optimization in mind. This article will study the hijacking in some technical detail, discuss the <a href="http://en.wikipedia.org/wiki/Black_hat_SEO">black hat SEO</a> likely used to get the rogue application listed on Google and how the app was able modify the expected functionality of browser controls in Chrome 3.0.</p>
<h3>The bait and switch</h3>
<p>How does activating a seemingly innocuous (and tasty) link from Google land someone on a potentially dangerous page? 302. <a href="http://en.wikipedia.org/wiki/HTTP_302">HTTP 302</a> that is.</p>
<p>After locating the offending link on Google, I used a client-side proxy to trap the HTTP headers for a play-by-play review:</p>
<pre>GET http://woodstockfolkmusic.com/bftwe/tiijy/carne.php HTTP/1.1
HTTP/1.1 302 Found
GET http://goodstats1.net/in.cgi?2 HTTP/1.1
HTTP/1.1 302 Found
GET http://sunstats1.net/in.cgi?default HTTP/1.1
HTTP/1.1 302 Found
GET http://sunstats1.net/redirect3/ HTTP/1.1
HTTP/1.1 302 Found
GET http://bookletantcars.cn/?pid=283s01&amp;sid=2a15a0 HTTP/1.1
HTTP/1.1 302 Found
GET http://wwwantispyware10.com/scan1/?pid=283s1&amp;engine=%3D3W59jDuNTIuMTUxLjE1MyZ0aW1lPTEyNTE2NYcMOAkN HTTP/1.1
HTTP/1.1 200 OK</pre>
<p>Stepping through the sequence we can see the initial GET request followed by a 302 redirect response. Several redirects later and the browser successfully arrives at destination malware, beef stew long forgotten.</p>
<h3>Black hat inside</h3>
<p>The next thing I tried was to analyze the <a href="http://www.habdas.org/wp-content/uploads/2009/10/carne.php">source of the PHP file</a> cataloged by Google, which was not difficult for two reasons:</p>
<ol>
<li>Directory listing was enabled on the web server, and</li>
<li>Navigating directly to the PHP file caused the page to load without redirect.</li>
</ol>
<p>The PHP file was stowed away on <a href="http://woodstockfolkmusic.com/">woodstockfolkmusic.com</a> (which appears to be a legitimate folk music site based out of Illinois) along with some 300 similar PHP files, covering a range of topics from Alba to Wisconsin. The files found contained mostly deprecated HTML markup (remember the &lt;marquee&gt; tag anyone?) and no PHP script or META tags. The files were <a href="http://en.wikipedia.org/wiki/Keyword_stuffing">stuffed with hundreds of keywords</a>, a form of <a href="http://en.wikipedia.org/wiki/Spamdexing">spamdexing</a> I thought was no longer practiced. Nevertheless the result still appeared on Google, possibly with a little help from <a href="http://en.wikipedia.org/wiki/Cloaking">cloaking</a>.</p>
<h3>Engage the cloaking device</h3>
<p>Curious as to why the PHP files (with no PHP script or META tags, mind you) would redirect links coming from Google, but not when loaded directly, I again pulled up a client-side proxy for closer investigation. Below are the results of several slightly modified HTTP requests for the file initially requested by Google. Each request contains a modified Referer <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">request-header field</a>.</p>
<p><strong>First request</strong><br />
Hacked the Referer field to point to the Google domain.</p>
<pre>GET http://woodstockfolkmusic.com/bftwe/tiijy/carne.php HTTP/1.1
Host: www.google.com
Proxy-Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0 Paros/3.2.13
Referer: http://www.google.com/
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3</pre>
<p><strong>First response</strong><br />
Hijack successful; browser redirected to bogus antivirus page.</p>
<pre>HTTP/1.1 200 OK
Date: Sun, 18 Oct 2009 22:33:31 GMT
Server: Apache
X-Powered-By: PHP/5.2.8
Connection: close
Content-Type: text/html</pre>
<p><strong>Second request</strong><br />
Hacked the Referer field to a domain other than Google.</p>
<pre>GET http://woodstockfolkmusic.com/bftwe/tiijy/carne.php HTTP/1.1
Host: woodstockfolkmusic.com
Proxy-Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0 Paros/3.2.13
Referer: http://www.habdas.org/
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3</pre>
<p><strong>Second response</strong><br />
No hijack; browser sent directly to indexed page.</p>
<pre>HTTP/1.1 200 OK
Date: Sun, 18 Oct 2009 22:31:36 GMT
Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.6
X-Powered-By: PHP/5.2.6
Content-Type: text/html</pre>
<p><strong>Additional testing</strong><br />
Additional testing revealed page redirection would occur only when the Referer field was included in the HTTP request header, and only when the field value contained certain phrases. Two phrases found to trigger the hijack include &#8220;google&#8221; and &#8220;yahoo&#8221; (case insensitive) while other likely phrases such as &#8220;bing&#8221;, &#8220;msn&#8221;, &#8220;aol&#8221; and &#8220;ask&#8221; did not.</p>
<p><strong>Note:</strong> I am I not currently aware if Yahoo is susceptible this particular brand of page hijacking. If you&#8217;ve seen it on Yahoo or know of any examples, please comment and let us know.</p>
<p>Testing for the presence of phrases &#8220;Googlebot&#8221;, &#8220;googlebot&#8221; or &#8220;google&#8221; and &#8220;bot&#8221; (separated) all resulted in the 302 redirects, which leaves some of the following possibilities:</p>
<ul>
<li>The 302 redirect (likely of the .htaccess kind found in the <a href="http://blog.javacoolsoftware.com/2008/12/anti-virus-2009-search-engine-redirect-hacks/">Antivirus 2009 approach</a>) was turned on after the page was indexed.</li>
<li>The web crawler that originally accessed the page did not pass the phrases &#8220;google&#8221; or &#8220;yahoo&#8221; in the Referer [<em>sic</em>] field in the HTTP request header.</li>
</ul>
<p>Monitoring over a several day period landed the browser on some of the following domains, each with their own similar virus scan or some derivation:</p>
<ul>
<li>wwwantispyware10.com</li>
<li>topantimalwarescan7.com</li>
<li>top-antispyware-scan8.com</li>
<li>computer-protection11.com</li>
<li>webprosecurity.com</li>
<li>guardpconline.com</li>
</ul>
<h3>The Chrome 3.0 Browser Button Issue</h3>
<p>The Chrome button issues are happening on and off. Some of the changes in behavior I have witnessed using Chrome v3.0.195.27 (Win):</p>
<ul>
<li>Browser unable to navigate backwards in history;</li>
<li>Navigation backwards in history only after several tries; and</li>
<li>Tab hangs and cannot be closed, and Windows clocks, until the pop-up notification window is closed.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.habdas.org/2009/10/18/google-302-redirect-hijack/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Analyzing User Agent Strings</title>
		<link>http://www.habdas.org/2009/07/22/analyzing-user-agent-strings/</link>
		<comments>http://www.habdas.org/2009/07/22/analyzing-user-agent-strings/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 02:28:23 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[user agent]]></category>

		<guid isPermaLink="false">http://www.habdas.org/?p=710</guid>
		<description><![CDATA[The user agent string, a piece of data transmitted in the HTTP header during a web request, contains information valuable in determining browser type and often basic system information. Example user agent string sent from a web browser during an HTTP request: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5 [...]]]></description>
			<content:encoded><![CDATA[<p>The user agent string, a piece of data transmitted in the HTTP header during a web request, contains information valuable in determining browser type and often basic system information.</p>
<p><strong>Example user agent string sent from a web browser during an HTTP request:</strong><br />
<code>Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5</code></p>
<p>The above example, for instance, provides information such as browser and browser version, user locale (language), OS, system architecture and the layout engine used. When authoring documents for the Web, information from the user agent string can be valuable in determining how best to mark-up documents.</p>
<p>Getting the information is easy.</p>
<p><span id="more-710"></span></p>
<h3>Collecting user agent strings</h3>
<p>Two methods for accessing the user agent string include:</p>
<ol>
<li>From the HTTP request header&#8217;s User-Agent field; and</li>
<li>Using DOM and JavaScript.</li>
</ol>
<h4>Reading from the User-Agent field</h4>
<p>A benefit of using the HTTP header to gather data is simplicity of design.</p>
<p>HTTP request header showing the User-Agent field (in bold):</p>
<p><code>GET / HTTP/1.1<br />
Host: livehttpheaders.mozdev.org<br />
<strong>User-Agent:</strong> Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5<br />
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br />
Accept-Language: en-us,en;q=0.5<br />
Accept-Encoding: gzip,deflate<br />
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br />
Keep-Alive: 300<br />
Connection: keep-alive</code></p>
<p>Using the HTTP header the user agent is transmitted directly to the HTTP server on page request, making it possible for servers to output the user agent string to a log file for later analysis. The user agent string alone provides enough information  to implement on websites valuable browser support strategies such as <a href="http://developer.yahoo.com/yui/articles/gbs/">graded browser support</a>.</p>
<h4>User agent retrieval using DOM and JavaScript</h4>
<p>Using DOM and JavaScript, on the other hand, add additional development complexity, but provide more detailed and valuable analytic data, in addition to the user agent string alone. Tools like <a href="http://en.wikipedia.org/wiki/Urchin_(software)">Urchin</a> (now Google Analytics) utilize JavaScript and the DOM to gather analytic data about visitors.</p>
<p>Bookmark the following link to create a bookmarklet that will retrieve the user agent from a browser: <code><a onclick="alert(navigator.userAgent); return false; pageTracker._trackPageview('/click/link/analyzing-user-agent-strings'); " href="#">javascript:alert(navigator.userAgent)</a></code>.</p>
<p>Regardless of the collection approach used, methods for extracting data from the string remain similar.</p>
<h3>Data extraction methods</h3>
<p>Once the user agent string(s) are collected, data extraction may take place. Two methods for reading and extracting information from the user agent string include brute force and pattern recognition:</p>
<ul>
<li>Under the <strong>brute force</strong> approach the user agent string is compared programmatically to a database of known strings. Though it offers a relatively simple implementation, the brute force approach can be difficult to maintain and becomes increasingly inefficient as comparison data sets grow larger.</li>
<li>Thanks to <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616</a> and preceding RFCs, and de facto standards for formatting user agent strings, another method known as <strong>pattern recognition</strong> is possible. Using pattern recognition the user agent string is broken into its component pieces and heuristics applied to gather information. Though more complex to implement than the brute force approach, pattern recognition does not suffer from the same problems in efficiency and maintainability in the long-run.</li>
</ul>
<p>Due to its drawbacks in the application of extracting data form user agent strings, the brute force approach will not be discussed further in this article.</p>
<h4>Pattern recognition on the user agent string</h4>
<p>Check out <a href="http://www.texsoft.it/index.php?c=software&amp;m=sw.php.useragent&amp;l=it">Identify User Agent by string format recognition</a> for an example of user agent pattern recognition. Though a little outdated, the article provides additional depth, in addition to some useful programming techniques and lax copyright restrictions.</p>
<h3>User agent spoofing</h3>
<p>Impersonating browsers and mobile devices is simple with Firefox. Just download <a href="https://addons.mozilla.org/en-US/firefox/addon/59">User Agent Switcher</a> plug-in and put it to the test at <a href="http://www.useragentstring.com/">useragentstring.com</a>. See <a href="http://www.habdas.org/2009/01/10/useful-web-development-and-debugging-tools/">Web Development and Debugging Tools</a> for a list of tools useful for front end development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.habdas.org/2009/07/22/analyzing-user-agent-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Development and Debugging Tools</title>
		<link>http://www.habdas.org/2009/01/10/useful-web-development-and-debugging-tools/</link>
		<comments>http://www.habdas.org/2009/01/10/useful-web-development-and-debugging-tools/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 14:37:21 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[browser compatibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[debugging tools]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[proxies]]></category>
		<category><![CDATA[web standards]]></category>

		<guid isPermaLink="false">http://www.habdas.org/?p=234</guid>
		<description><![CDATA[Following is a  list of cross-browser/platform web development and debugging tools useful for client-side developers. Depending on the application, one or all of these tools can be valuable in completing work on a website front-end. Tools for Firefox Build for standards. Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you [...]]]></description>
			<content:encoded><![CDATA[<p>Following is a  list of cross-browser/platform web development and debugging tools useful for client-side developers. Depending on the application, one or all of these tools can be valuable in completing work on a website front-end.</p>
<p><span id="more-234"></span></p>
<h3>Tools for Firefox</h3>
<p>Build for standards.</p>
<div id="attachment_1295" class="wp-caption alignright" style="width: 303px"><a href="http://www.habdas.org/wp-content/uploads/2009/01/firebug-logo.png"><img class="size-full wp-image-1295" title="Firebug Logo" src="http://www.habdas.org/wp-content/uploads/2009/01/firebug-logo.png" alt="Product Logo" width="293" height="89" /></a><p class="wp-caption-text">Firebug &gt; *</p></div>
<ul>
<li><a href="http://getfirebug.com/">Firebug</a> integrates with Firefox to put a wealth of development tools at your fingertips while you browse.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/249">HTML Validator</a> is a Mozilla extension that adds HTML validation inside Firefox and Mozilla.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer</a> adds a menu and a toolbar with various web developer tools.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/1419">IE Tab</a>, an extension from Taiwan, embeds Internet Explorer in a Mozilla/Firefox tab.</li>
<li><a href="http://www.colorzilla.com/">ColorZilla</a> provides Advanced Eyedropper, Color Picker, Palette Viewer and other colorful goodies for your Firefox.</li>
<li><a href="http://developer.yahoo.com/yslow/">YSlow</a> analyzes web pages and tells you why they&#8217;re slow.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/6647">HttpFox</a> monitors and analyzes all incoming and outgoing HTTP traffic between the browser and the web servers.</li>
<li><a href="http://davemartorana.com/multifirefox/">MultiFirefox </a>is a small launcher utility that allows you to run multiple versions of Firefox side-by-side.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/59">User Agent Switcher</a> to spoof user agent strings for browser support testing.</li>
<li><a href="http://www.google.com/toolbar/">Google Toolbar</a> to visualize Page Rank.</li>
</ul>
<h3>Tools for Internet Explorer</h3>
<p>Ensure application compatibility.</p>
<ul>
<li><a href="http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&amp;displaylang=en">Internet Explorer Developer Toolbar</a> provides a variety of tools for quickly creating, understanding, and troubleshooting Web pages. It also allows for the inspection of the MSIE-specific CSS passed in through the use of <a href="http://msdn.microsoft.com/en-us/library/ms537512.aspx">Conditional Comments</a>.</li>
<li>A look-alike is just that, not the real thing. Here are the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=21eabb90-958f-4b64-b5f1-73d0a413c8ef&amp;displaylang=en">Internet Explorer Application Compatibility VPC Images,</a> made available by Microsoft for use in testing browser compatibility with MSIE.</li>
</ul>
<h3>Other tools</h3>
<p>Polish it to a bright shine.</p>
<ul>
<li><a href="http://seleniumhq.org/projects/ide/">Selenium IDE</a> for automated testing, helping unlock the potential for test-driven development in the UI layer.</li>
<li><a href="http://www.parosproxy.org/">Paros</a> is a simplistic proxy tool that allows you to trap raw HTTP request and response headers for analysis and testing.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.habdas.org/2009/01/10/useful-web-development-and-debugging-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
