

A few weeks ago I blogged about hacked sites where malicious scripts used Twitter API to generate domains of new attack sites and trigger “drive-by” downloads.
As you might remember, I mentioned that the script was buggy (failed to work on certain days) and the approach didn’t look viable in the long term since it required that hackers manually register one new domain name every day. As a result, in November, this vector looked abandoned (I couldn’t find active and even registered malicious domains).
However, hackers seem to be die-hard fans of Twitter and don’t want to give up on the idea.
A few days ago I found a blacklisted site, where search.twitter.com was mentioned as an intermediary in malware distribution. Safe Browsing diagnostic pages also mentioned fresh (beginning of December) malicious domains that were definitely generated by the above-mentioned script. No wonder, on the infected site I found the familiar script. Actually, it was not the same script. It was an improved version of that script.
The malicious scripts are no longer injected directly into web pages. To make the initial detection harder, hackers inject their scripts into external .js files.
$a="Z64zZ3dZ22Z2566uZ256ecZ2574ionZ2520Z2564w...<removed part>...}return unescape(r);}eval(z($a));
The idea remains the same. Malicious scripts on hacked sites request trending topics from Twitter (using their API) and then use this information to generate a pseudo-random domain name of a currently active attack site on the fly, and finally inject a hidden iframe that silently loads malware from that site.
However, this time they use two consecutive calls to Twitter (was one).
The first request goes to
http://search.twitter.com/trends/daily.json?callback=callback
The response contains a timestamp (current time) and hackers use it to calculate a date (2 or 3 days before the current date) for the next API request.
http://search.twitter.com/trends/daily.json?date=yyyy-mm-dd"&callback=callback2
where yyyy-dd-mm is the calculated date. This request returns the top 20 trending topics for each hour in a given day.
The algorithm of the domain name generator has changed. In the previous version, as a key of the cypher, they used the second character of the most popular Twitter search on the calculated date (using the trends/weekly API). The algorithm generated one new domain every day.
Now they use
And in this version, they have fixed the bug that I noticed last time. (As far I as know, this was at least the second attempt to fix the bug, but the previous fix intoduced a similar bug in another place. This time they seem to have finally done it right.)
I won’t bother you with the technical details of this algorithm. Instead, I created a front-end to this algorithm where anyone can see the current and upcoming malicious domains.
It is called “Torpig Domain Generator” as some people believe that the Torpig(Sinowal/Mebroot) botnet is behind this attack.
This simple online tool is based on the scripts that I found on compromised web sites. I just deobfuscated it, removed the malicious part and slightly refactored. The core of the script is the same: two twitter API calles and the domain name generator, – so until hackers change the algorithm once again, at any given moment my online generator should produce correct information about active and upcoming malicious domains.
The implementation of the generator is JavaScript-base, so, if you are interested in the algorithm, you can find it in the HTML code the web page. As since it is JavaScript based, in order to see it working, you’ll need to allow scripts from UnmaskParasites.com and twitter.com.
You can easily distinguish domain generated for this attack. In any given month their names end with the same 3-letter string. E.g in December they all end with “twe” (gabtibbgtwe .com, wghfqlmwtwe .com, etc)
Right now the attack is active and hackers register a couple of new domains every day. Here are just a few of them (mainly for webmasters of blacklisted compromised sites who can spot these domains on Google’s Safe Browsing diagnostic pages)
For more, check my online domain generator
As you can see Google is pretty good at detecting and blacklisting such short-lived malicious sites.
When I check the whois records for those domains I see that most of them have been registered with Register.com using fake (or stolen?) identities (addresses from all over the US) and probably stolen credit cards.
One interesting detail is they always use toll-free “+1.800…” and “+1.866…” phone numbers.
Sometimes I see a strange behavior when those throw-away domain names change their owners several days in a row, still pointing to the same IPs.
The domain names are really throw-aways. Many of them have already been canceled just after 2-3 days of use.
When I started to investigate this incarnation of the attack, all generated domains pointed to a server hosted by CariNet. However, on December 7 I noticed that the server went down (probably because of an abuse report). A couple of hours later, the domains moved to a new server (216.245.219.178) on the Limestone Networks. It looks like not only do those guys have creative programmers, they also have a decent maintenance team.
Anyway, with their current approach of open domain name generating algorithm, the viability of the attack in the long term is questionable.
It looks like hackers are aware of theses downside and they are currently testing a new approach with intermediary servers that redirect requests to pseudo-random domains generated using the Twitter API. This way they can gradually hide the domain generator logic on their proxy servers so that we won’t be able to predict new malicious domains when they change the algorithm. More about the new approach with proxy server in the upcoming blogpost. Stay tuned…
If Google blacklists your sites check the diagnostics page (there is a link from the warning page). If it mentions search.twitter.com as an intermediary or you see any other domains that end with “…twe.com“, most likely this article describes your case.
To find the malicious script that caused the malware warning, scan all your web pages and external .js files for code that starts with “$a=”Z64zZ3dZ22Z2566u…” or “$a=”Z64dZ3dZ22q…”
I still don’t have any reliable information about how this code is injected into legitimate web site. However, after analysis of the hacked sites, I’m almost sure that vulnerabilities in popular web applications are not to blame (many sites used only static HTML pages).
This can be yet another attack that uses stolen FTP credentials:
so it’s always a good idea to change all site passwords and keep them secure. At the same time you shouldn’t forget to scan your own computer for malware.
Another hypothesis is this can be an infection that spreads across websites (probably with insufficient security settings) on shared servers. As I tweeted a few days ago, for some reason many known infected web sites are hosted by Aruba.it (but because of their distributed DNS configuration (every domain points to 8 IP addresses) I can’t say for sure if the infected sites physically reside on the same server.)
Once you clean up your site, you should request a malware review via Google’s Webmaster Tools to remove the warning from Google’s search results and from web browsers that use Google’s database of malicious sites. (You can find more information about dealing with Google’s malware warnings in my guide.)
To help webmasters protect their websites from this infection we should identify the vulnerabilities used by hackers in this attack. It would be great to hear from webmasters of the compromised sites and from their hosting providers – any additional internal information (e.g. server logs, file permissions, backdoor scripts) is welcome. You can leave your comments here or contact me directly.
P.S. In the next post I’ll talk about the modification of this attack where hackers use intermediary servers to redirect unsuspecting visitors to the same throw-away domains that were generated using Twitter API.
Related 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 post was mentioned on Twitter by Denis, ak1010 and Malware Domain List, Old Mac Donald. Old Mac Donald said: Twitter API Still Attracts Hackers | Unmask Parasites. Blog.: As of December 2009, hackers more intensively use Twitter http://url4.eu/u6XF [...]
Denis,
I’ve some other code that uses this type of strategy, however it starts with:
$a=”Z6fpZ3dZ22Z2524aZ253dZ2522dw…”
Slightly different but it is still using the Twitter API. I have decoded this part:
Let me know if you’d like the file, although you probably already have it. :)
Nice job on the write-up.
Denis,
Thanks for the great work.
Do you know if any of this malware is proxy-aware? For example, will it use a proxy server if one is configured on the host with Internet Explorer to access search.twitter.com?
The script works in a browser. So it uses the browser’s settings.
Sorry, I was referring to Torpig malware itself. I have searched and not been able to determine this. Thanks again.
I doubt that the malware itself works with twitter.
Domain generation algorithm seems to have changed at the beginning of May 2010. Any news/info on this ?
I don’t follow this attack now.
It worked for a few months. If I come across a new working algorithm, I’ll publish the update.