<?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>Marty Thornley &#187; malware</title>
	<atom:link href="http://martythornley.com/tag/malware/feed/" rel="self" type="application/rss+xml" />
	<link>http://martythornley.com</link>
	<description>From Photography Blogsites</description>
	<lastBuildDate>Wed, 14 Mar 2012 08:24:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://photographyblogsites.com/?v=3.2.1</generator>
		<item>
		<title>Major Security Warning for Anyone Using Ad Services</title>
		<link>http://martythornley.com/2010/04/major-security-warning-for-anyone-using-ad-service/</link>
		<comments>http://martythornley.com/2010/04/major-security-warning-for-anyone-using-ad-service/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 21:17:02 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://martythornley.com/?p=753</guid>
		<description><![CDATA[A client&#8217;s WordPress site was recently hacked by some malware, receiving the dreaded red warning screen. You know the one where it warns that a site may harm your computer? This warning comes from your browser but is triggered by Google detecting that malware is on your site. First, this is NOT a WordPress security [...]]]></description>
			<content:encoded><![CDATA[<p>A client&#8217;s WordPress site was recently hacked by some malware, receiving the dreaded red warning screen. You know the one where it warns that a site may harm your computer? This warning comes from your browser but is triggered by Google detecting that malware is on your site.</p>
<p>First, this is NOT a WordPress security issue. It is all about  malware being inserted by third party ad services. For my fellow <a href="http://wordpress.org" target="_blank">WordPress</a> folks, this is not the same issue dealt  with at that hosting company that will remain unnamed.</p>
<h2>The Red Screen of Death</h2>
<p>When Google crawls a site and detects malware, they issue a warning which results in that red screen. They also add a warning within their search results right under the link to your site that says &#8216;This site may harm your computer&#8217;. All pretty scary stuff for a visitor finding your site for the first time.</p>
<p>So,assuming at the time that it came from Google, it seemed strange to me that Google could stick a red screen on a site. How could they do that? Well, they can&#8217;t of course. So I looked into the code of the warning itself and saw that it was coming from mozilla.org, the company that makes Firefox, meaning it was something in the browser itself.</p>
<p>Checking the security settings, I saw a check box for &#8216;Block reported attack sites&#8217;. So I unchecked that and tried the site again. It loaded just fine. No warning. Same in Safari. They have a setting to block sites and send a warning. Problem was these were defaults, so essentially everyone is seeing these red screens.</p>
<h2>Removing the Red Screen</h2>
<p>The only way to get rid of the warning screen is to remove all the malware, and get Google to re-crawl your site. You can either wait for that or re-submit your site using <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=35843" target="_blank">Webmaster Tools Reconsideration</a>. Even with both myself and the client submitting for reconsideration, the process took about 18 hours which I feel is pretty quick form stories I have heard. In fact we were getting ready to redirect the domain to a clean url if the warning hadn&#8217;t gone away within another hour or two.</p>
<p>All said, it was about 48 hours of the site being blocked with this red screen.</p>
<p>Then after it was fixed, we had to clear the cache in our own browsers to make the warning go away, meaning that anyone who saw the site in the last day or two was most likely STILL seeing the warning even though Google had removed the warning and the site had been totally clean for close to 24 hours. And who knows when everyone&#8217;s cache would reload the cleaned pages?</p>
<h2>The Hypocrisy of Google</h2>
<p>Here is the problem&#8230; The malware appeared after a third party ad  service started using Adsense of all things. The stunning thing to me is the possible hypocrisy of Google Adsense sending malware and then using its malware warning to essentially shut down a site for close to 48 hours.</p>
<p>When you see that red screen do you ever click ignore? Probably not since it warns you that your computer may be harmed. After I fixed the problem, the warning was still there and I still felt cautious about clicking, feeling that maybe it was still detecting something I didn&#8217;t find.  This is when I figured out that it was the browser settings I described above.</p>
<p>So&#8230; The timeline went something like this:</p>
<ul>
<li>Site is infected with malware at some point. This could have gone undetected for a while. Hard to tell.</li>
<li>Google detects it and adds the warning.</li>
<li>Browsers see that warning and visitors get the warning screen.</li>
<li>Regular readers of the site start sending emails and tweets to the client.</li>
<li>About 24 hours AFTER all this, the client gets an email from Google telling them about the problem.</li>
<li>Client contacts me and within a number of hours we clean the site and submit for reconsideration. This is only because I was out at the time. The actual process of fixing took about an hour.</li>
<li>18 hours later the site is recrawled and put back to normal.</li>
<li>Visitors whose cache is not emptied are still receiving the warning.</li>
</ul>
<p>So&#8230;</p>
<ul>
<li>24-36 hours &#8211; site is down before being able to fix it.</li>
<li>1 hour &#8211; fixing time</li>
<li>18 hours &#8211; re-crawl and remove the warning.</li>
</ul>
<h2>Ignore Bad advice from the Hosting Company</h2>
<p>The client&#8217;s host was saying that the process might be 2-3 weeks! Not only that&#8230; They recommended removing the URL from Google because of that little warning, suggesting that people shouldn&#8217;t see that because it made the site look bad.</p>
<p>Remove the URL form Google? That would lose all search ranking and everything, I have never heard of worse advice. The site was back up within an hour or tow of getting that advice and if the client had listened they could have lost all their search rankings.</p>
<h2>How to fix it</h2>
<p>As with any changes to a site &#8211; <strong>BACKUP EVERYTHING</strong> first.</p>
<ul>
<li>Export your WordPress content from the backend.</li>
<li>Backup your database.</li>
<li>Backup you wp-content folder</li>
</ul>
<h2>Finding the Malware</h2>
<p>This can come in a few forms:</p>
<ul>
<li>It can be added to files you already have.</li>
<li>It can be added as new files that were not there before.</li>
<li>It can be injected into the database.</li>
</ul>
<p>But is actually fairly easy to spot once you know what to look for. It is almost always something known as obfuscated javascript or something embedded in an iframe. Obfuscated javascript looks like a bunch of random letters, numbers and symbols, like this: &#8216;JGs9MTQzOyRtPWV4cGxvZGUoIjsiLCIyMzQ7MjUzOzI1MzsyMjQ&#8217;. It is totally meaningless until decoded. An iFrame is used to embed another page into a site. It is used by Facebook and any other number of legitmate sites, so iFrames are not by themselves bad. On the other hand any apperance of that obfuscated javascript is cause for concern, especially in an open source project like WordPress where all code must be readable.</p>
<p>To find the bad code:</p>
<ul>
<li>Search your files for the word &#8216;base64_decode&#8217; where you find something like this &#8216;&lt;?eval(base64_decode(&#8220;JGs9MTQzOyRtPWV4cGxvZG&#8230;&#8217; and that string of characters will go on for a while and end with something like &#8216;==&#8221;));?&gt;&#8217;</li>
<li>Delete all occurances from the opening &#8216;&lt;?&#8217; to the closing &#8216;?&gt;&#8217;</li>
<li>Search your database for &#8216;base64_decode&#8217;</li>
<li>Delete that same line (it will probably not have the &#8216;&lt;?&#8217; or &#8216;?&gt;&#8217;, just the &#8216;eval(base64_decode)&#8217;</li>
<li>Search all your pages for &#8216;iframe&#8217;</li>
<li>Search the database for &#8216;iframe&#8217;</li>
<li>Before deleting any iframes, look at the content and see if it is something you recognize. It might be fine.</li>
</ul>
<p>Specifically in this case, there was a series of files that were somewhat easy to spot, since they were in the main directory and not part of the core WordPress files. Here are the names:</p>
<ul>
<li>A folder called &#8216;.files&#8217; which will be hard to spot unless you are able to view hidden files because of the &#8216;.&#8217; at the beginning of the folder name.</li>
<li>The folder contained a huge number of files, all ending in .html, all with spammy search titles.</li>
<li>A file called &#8216;hobard_ebeneser.php&#8217; whose only contents were the javascript described above.</li>
<li>A file called &#8216;spite_kerk.php&#8217; whose only contents were the  javascript described above.</li>
<li>A file called &#8216;vhfjp.php&#8217; whose only contents were the   javascript described above.</li>
</ul>
<p>Another post about a similar set of files they called the <a href="http://www.wewatchyourwebsite.com/wordpress/?p=344" target="_blank">&#8216;Movie Review&#8217; infection and how to fix it</a>. Essentially the same as here.</p>
<h2>After the Malware is Gone</h2>
<p>So the malware is gone and 18 hours later Google has approved the site again. According to Webmaster Tools no malware was found.</p>
<p>BUT&#8230; we are still getting the warning until emptying our browser&#8217;s cache and refreshing a few times. This is a problem since most people who saw the site with the warning will still see the warning but would not bother refreshing or deleting their cache. So there needs to be a way to FORCE the visitor to load a new version of the page.</p>
<p>I used the <a href="http://php.net/manual/en/function.header.php" target="_blank">php function called header()</a> which must be called before anything is output to the screen. To make sure of this I placed it right in &#8216;index.php&#8217;. Not the one in the WordPress theme, the main index.php of the whole site, the one contains about 3 lines of code and opens WordPress itself. I wanted to make sure this was the very first thing a browser saw when opening the page.</p>
<p>Here is exactly what I used:<br />
[sourcecode lang="php"]<br />
header(&#8220;Cache-Control: no-cache, must-revalidate&#8221;); // HTTP/1.1<br />
header(&#8220;Expires: Sat, 26 Jul 1997 05:00:00 GMT&#8221;); // Date in the past<br />
[/sourcecode]</p>
<p>I pasted that right above the line:<br />
[sourcecode lang="php"]<br />
define(&#8216;WP_USE_THEMES&#8217;, true);<br />
[/sourcecode]</p>
<p>Now eventually we will remove this. Pages are cached for a reason. It speeds up page load time, etc. So we don&#8217;t want to make everyone lodd a new version indefinitely, but for a couple days we are going to make sure everyone gets the clean version.</p>
<h2>Final Note &#8211; AVOID AD SERVICES that use javascript</h2>
<p>There have been a HUGE number of ad services compromised by these attacks lately. Unless you are making enough to justify going through this, I would recommend not using these ad services that place javascript on your site. The same goes for affiliate links that use javascript. Most will offer an HTML version that is just an image and a link. If you see the word &#8216;javascript&#8217; in the line of code they want you to copy, I would stay away.</p>
]]></content:encoded>
			<wfw:commentRss>http://martythornley.com/2010/04/major-security-warning-for-anyone-using-ad-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

