Friday, October 22, 2010

Command and Control in the Cloud

In "Shadows in the Cloud: An investigation into cyber espionage 2.0" my co-authors and I analyzed the command and control infrastructure of a network that extracted secret, confidential and restricted documents from the Indian government and military. The Shadow Network used a complex and tiered command and control infrastructure that leveraged Twitter, Google Groups, Blogspot, Baidu Blogs, blog.com and Yahoo! Mail in order to maintain persistent control over the compromised computers. As we noted in the report, the use of these services as elements of command and control is certainly not new:

The use of social networking sites as elements of command and control for malware networks is not novel. The attackers leverage the normal operation of these systems in order to maintain control over compromised system. In 2009, researchers found that Twitter, Jaiku, Tumblr, Google Groups, Google AppEngine and Facebook had all been used as the command and control structure for malware. In August 2009, Arbor Networks’ Jose Nazario found that Twitter was being used as a command and control component for a malware network. In this case, the malware was an information stealer focused on extracting banking credentials from compromised computers located mostly in Brazil. Twitter was not the only channel being used by the attackers. They also used accounts on Jaiku and Tumblr (Nazario 2009a). Furthermore, Arbor Networks found another instance of malware that used the Google AppEngine to deliver malicious URLs to compromised computers (Nazario 2009b). The Unmask Parasites blog found that obfuscated scripts embedded in compromised web sites used the Twitter API to obscure their activities. While the method was clever, the code was unreliable and appeared to have been abandoned by the attackers (Unmask Parasites 2009). Symantec found that Google Groups were being used as command and control for another instance of malware. In this case, a private Google group was used by the attackers to send commands to compromised computers which then uploaded their responses to the same Group (Symantec 2009a) Symantec also found an instance of malware that used Facebook status messages as a mechanism of command and control. (Symantec 2009b). The use of these social networking and Web 2.0 tools allows the attackers to leverage the normal operation of these tools to obscure the command and control functions of malware.


Earlier this year, Sunbelt found a Twitter botnet creator and Trend Micro reports that the "Here You Have" worm used GMail accounts. As we found with the Shadow Network malware authors learn from each other. And in the case of the Shadow Network they didn't just use one service they used six of them, including Yahoo! Mail. And while indiscriminate malware may be rather noisy, the malware used in targeted attacks tends to be (but is certainly not always) more discrete.

A recent sample posted at contagiodump.blogspot.com caught my attention for this very reason. The sample, "Conference Information_2010 IFANS Conference on Global Affairs (1001).pdf" (which was sent from 221.9.247.17 and was detected by 14 /43 (32.6%) AV products at Virustotal) arrived with the subject line "Nuclear Challenges and Responses in the Century" and exploited a vulnerability in Adobe Reader/Acrobat (CVE-2010-2883) to drop malware on the targets' computers. For those of you who follow Mila's awesome blog, this scenario is hardly surprising.

But a few things caught my attention. There were references in the strings dumped from a file the malware created (syschk.ocx) that referenced GMail (mail.google.com) and DriveHQ (drivehq.com), which describes itself as a "cloud based storage, backup, group sharing and collaboration service." When you look at the traffic generated by the malware you'll see connections to these locations.

There is nothing about these locations that is very suspicious -- everyone checks their GMail right? Moreover, the connection to GMail is SSL encrypted.



Using Burp (which made the process very simple) I MITM'd the traffic between the malware and GMail. The malware logs in to the GMail account and sends an email to another GMail address. The content of this email is encrypted. However, I believe that what it is sending -- although this is just a hunch -- is the content of another file the malware generates: form.ocx. This file contains what appears to be a unique ID assigned by the malware, the hostname and IP address, the default home page of the default browser and a listing of installed programs on the computer. The end of the file contains information about executables the malware has impacted. In addition to the encrypted message sent through the GMail account, the Unique ID in form.ocx appears at the beginning of the message.


IEXPLORE.EXE done
CHROME.EXE done
FIREFOX.EXE done

C:\WINDOWS\system32\form.ocx
Infect OK!


I have not looked into what exactly the malware does to these applications, but it basically disables the operation of FireFox and Chrome and instead connect to the Gmail account when you try to start these applications. Internet Explorer seems to function normally.

The connection to fuechei.chang.drivehq.com results in the download of an additional file rename.ocx which appears to be very similar, when its strings are compared with, syschk.ocx. It then renames syschk.ocx to syschk.ocx1. You can see that this correlates with text in the strings dumped from syschk.ocx.


%s\rename.ocx
http://%s/rename
%s\syschk.ocx1


After the initial connections to GMail and DriveHQ the malware went quiet. I never did get it to connect again.

As network defenses continue to include traffic analysis, I believe that we will continue to see a move toward using popular services, especially web mail as command and control elements. Unlike connections to well-known dynamic DNS services like 3322.org or abnormal connections to geographic regions, connections to GMail and other popular services do not necessarily stand out. Moreover, the connections to the services, such as GMail are encrypted, further obfuscating the malicious activity that is occurring.

Saturday, October 16, 2010

Malware Diversification

There are wide varieties of malware, many of which have similar functionality. As a result there is a tendency to portray them as being in competition with on another. In some ways this is true, especially when it comes to malware authors, however, I prefer to see it as less of a rivalry and more of an opportunity for diversification on the part of the botnet operators. Recently there have been some articles that suggest that Zeus may be "dethroned" ("New threat set to dethrone Zeus", "Online criminals are moving on from Zeus") thanks to Bugat and Carberp.

Well, despite the recent arrests of over 150 individuals associated with Zeus-related bank fraud and the decline in the number of active Zeus command and control servers Zeus is still "going strong" and demonstrating its resilience.

However, this is not a property of the malware, but of the wide base of criminals that use it. While there may be a core of Zeus activity, anyone can use the Zeus toolkit to setup his or her own botnet. An additional factor to include is the fact that criminals make use of multiple malware kits, even rival malware kits.

The relationship between SpyEye (see two great SpyEye posts here and here) and ZeuS has been described as a rivalry -- largely based on SpyEye's ability to remove ZeuS from compromised computers -- but botnet operators make use of both.

Here are two command and control server domain names that have hosted both Zeus and SpyEye. The domain coolparts31.tw was a known Zeus (see MDL) command and control, but I found that it was also hosting SpyEye. More recently, I have been monitoring mir-krossover.com that was a known Zeus command and control (see MDL) but is also hosting SpyEye.

http://mir-krossover.com/mirspy/mainadmin/bin/bd.exe
b911f40ff9573f33e73055b2267a5cd7 bd.exe
VT: 36/ 43 (83.7%)

http://mir-krossover.com/mirspy/mainadmin/bin/id.exe
e8091d2099a8472b27a62c5ae57be5e9 id.exe
VT: 37/ 43 (86.0%)

Malware diversification allows the botnet operators to run multiple botnets, increasing their resilience to countermeasures aimed at taking down one particular strain. In addition, they can capitalize on new features and functionality available across various toolkits. To counter such operations we need to look beyond the toolkit and and investigate the operators as well.

Thursday, October 14, 2010

Clustering Zeus Command and Control Servers

Recently, more than 150 individuals around the world have been arrested on bank fraud related charges after using the Zeus malware to acquire credentials that enabled the criminals to steal more than $70 million dollars. Those arrested include five Ukrainian individuals that are believed to be the masterminds behind the operation. Brian Krebs notes that there is a correlation between the decreasing number of active Zeus command and control servers and the timing of the arrests.

This is interesting because while "the media" often portrays Zeus as "a botnet" the security community rightly points out that Zeus is a malware toolkit not "a" botnet and that there are multiple Zeus botnets. However, what explains the decrease in Zeus command and control servers with the disruption of just one Zeus operation? While it is certainly true that any aspiring criminal can acquire Zeus and begin his or her own operation, is there a Zeus "core" that is organized and connected through links the criminal underground? Having just returned from Palantir's Govcon feeling inspired I imported Zeus data from the MalwareDomainList and the ZeusTracker to explore the links between Zeus command and control servers.

While there are definitely more indicators, I focused on three: IP addresses, domain names, and email addresses used to register domain names. The IP addresses represent the servers that are used to host command and control servers. One such server may host multiple command and control servers allowing one to cluster malicious domain names that are hosted on the same server. Domain names are useful indicators but essential have a one-to-one relationship so it is more valuable to cluster them by the email address used to register the domain name. Using these indicators the Zeus command and control domain names can be clustered based on co-hosting (on the same IP address) and mutual registration (same email address). This may provide some indication if there is a "core" or Zeus activity.

However, there are significant limitations to bear in mind. Malicious hosting services are available in the criminal underground, so while a single server may be a hotspot of malware activity, it may not be directly related. On the other hand, some command and control servers may be using fast flux which would negate clustering by IP address altogether. Some command and control servers are based on IP addresses only and do not have domain names associated with them. On the other hand, a single domain name may be used for a variety of purposes. (For example, I have found a domain name that hosts both a Zeus and a SpyEye command and control server, despite the reported rivalry between them). In addition, the botnet operators may register a variety of domain names from a variety of email addresses. In such cases, clustering by email addresses would not yield significant links. Finally, there may be suppliers of domain names in them malware underground that register domain names with email addresses under their control, but sell the domains names to other criminals. In such cases, while the email address may be the same, the operators of botnets may not be directly related.



The data set used contains 5,907 domain names (control servers) and 4,505 IP addresses (servers) drawn from ZeusTracker and MalwareDomainList (where the activity on MDL contains "zeus"). Here, 4,505 IP addresses have been geocoded (not all were successfully geocoded) and displayed using Palantir's heatmap. While there is Zeus activity hosted all over the world, there are noticeable concentrations in Europe, the Unites States and China.



This cluster on the Palantir graph represents the relationship between 5,907 domain names (control servers) and 4,505 IP addresses (servers). This initial display highlights a few interesting indicators. There are several clusters that are visually apparent which show multiple domain names hosted on one server (there are three prominent "star" clusters and several smaller ones) and there is a discernible "tree" structure in the center indicating relationships between single domain names that have been hosted on multiple IP addresses. And we can see thaht there are some familiar IP addresses used to register multiple domain names, the most notable being "hilarykneber@yahoo.com" which is the email addresses behind the Kneber botnet.



Zooming in to some of the clusters reveals some interesting behaviors. In this example, one server is hosting 60 domain names. These 60 domain names were registered with 17 different email addresses. And when some additional information from MDL is brought in, we see that most of the domains are hosting a Zeus executable with the same name "patch.exe" and that there is a naming convention. For example, "1-adm.com/patch.exe" was registered with "obeys@infotorrent.ru" while "1-adm.net/patch.exe" was registered with "yam@ml3.ru". These domain names were all added to MDL around the same time and despite the multiple email addresses it does appear as if this is a single campaign.



In order to explore the question of whether or not there is a Zeus "core" of some sort, I filtered the domain names and IP addresses to those registered with the top five appearing email addresses (with the exception of contact@privacyprotect.org which is the email address given for those who have used this domain privacy service). Domain names registered with these five email addresses account for 6.09% (360/5907) of the Zeus command and control servers. However, this number increases to 17.9% (360/2004) when the number of control servers is restricted to those that contain email data. In addition to several "star" clusters as well a "tree" in the middle of the graph, we see that these email addresses have been actively propagating Zeus for approximately one year. (The time is derived from when the domain is added to either the MDL or ZeusTracker lists, which is used a rough indicator of when a domain became active).



When the selection is restricted to only those domain names registered by "hilarykneber@yahoo.com" we can see that these domains are represented across most of the clusters indicating that many of these domain are co-hosted on the same IP addresses with those registered by our other top email addresses. In addition, the "kneber" domain names are active through this year long period of data.

While a wide variety of criminals may set up disparate Zeus operations, clustering the Zeus command and control infrastructure in this way indicates that there is some evidence to support claims of a "core" set of Zeus operations. This may be one explanation for the observed decrease in active Zeus command and control servers.

However, this data only reflects only the relationships between IP addresses, domain names and the email addresses used to register the domain names. There are a variety of additional factors, especially those related to analysis of Zeus malware binaries that may support these linkages, provide additional linkages or challenge these linkages. Historical data showing coordinated movements to new IP addresses and name servers would provide additional means to cluster command and control servers with a higher degree of accuracy.

In Part 2 of this post I will broaden the analysis in order to see if the tentative conclusion hold with the introduction of additional data.

Friday, October 8, 2010

Black Hat SEO, PPC & RogueAV Part 2

Part 1 of "Black Hat SEO, PPC & RogueAV" focused on the type and amount of incoming traffic generated through BlackHat SEO methods. This traffic is monetized through the use of RogueAV, Pay-Per-Click and Pay-Per-Install affiliates. This post continues the analysis of this campaign by providing a inside look at this BHSEO operation.

The attackers acquired lists of thousands of FTP server credentials. The attackers may have purchased the compromised accounts from others in the cybercrime underground or harvested them from other operations. The attackers use several scripts to login to the FTP servers and upload their SEO scripts. The initial script uploaded to the compromised servers performs the following functions:


  • downloads the latest version of a redirection script

  • downloads a list of search queries

  • creates the files "tpl.txt", "folders.txt" and ".htaccess"

  • creates a directory "wp-blog" that contains the files "go.php" (the downloaded redirection script), "keys.txt", "nishe.txt", "pages.txt" and ".htaccess"



The list of search queries are paired with random file paths in order to create pages on demand based on the search queries. When a request comes in, the redirection script check to see if the "referer" is from a search engine and if the the request appears to have been made by a "bot". The latter function is performed by parsing the "user agent" header to check, for example, for indicators of a search engine crawler. If the "referer" is a search engine and the request is not made by a "bot", the request is redirected to the SEO server. If either of these checks fail, the script will lookup the requested path to retrieve the search query it has been paired with.


http://127.0.0.1/eQikAjL8uovt/||chakra labels printable
http://127.0.0.1/eQpu8kNxWSo/||t mobile rebate printable
http://127.0.0.1/eQWiaZsv/||printable instructions for sand castles
http://127.0.0.1/eQouHA8/||printable hanukkah song lyrics
http://127.0.0.1/eQzVWiZjIpoh/||4tth of july printable crown



Then the script will take the search query and retrieve the results for the query from Google and display the content using the "tpl.txt" file, which is a template based on the look and feel of the compromised website. The links in the page point to the additional search query / file path pairings.



These pages are indexed by search engines and the search queries become associated with the malicious pages. In addition, when a user queries a search engine, and lands on the malicious page, the user's request is redirected to the SEO server along with the query that the user searched for. These queries are collected and feed into the search query lists used by the attackers.

At last count the attackers had uploaded their SEO scripts to 11,978 servers, and although the server appears to have been abandoned on 2010-09-20 the figures from earlier in the campaign indicate that the attackers were able to attract significant amounts of traffic.



The attackers recorded the referring domain name as well as the search query used to arrive at the compromised domain. These records along with the number of hist were recorded by the attackers and available from an unprotected web interface.

In order to monetize their operation, the attackers used several affiliates. Users that the attackers detected were running non-Windows operating systems were redirected to pay-per-click affiliates at these domain names: www.rivasearchpage.com and www.offersfair.com. Windows users were redirected to RogueAV landing pages.

The Rogue AV affiliates supply "landing page" URLs to their fake scanning pages that attempt to trick the user into installing the fake security software. These URL's change over time, and the attackers maintain scripts that update these URLs so that user are redirected to fresh URLs that are less likely to have been identified and blocked by the security community.



RogueAV_1:

url: http://ed2aa7.robertodefeaternow.com/ren/?2737=caeo&ca0f394=bc7oe7eea8&945aa=bc86zzo8za
file: db2d504abeedce8b404a1f5514989689 powersecure_2049_emr7.exe
VT: 3 /43 (7.0%)

RogueAV_2:

url 1: http://www3.sobaka-kaka.com/?[...]
url 2: http://www1.highguardsoftat.net/?[...]
file: 90245bf674ff3b16653fc6f7d191dead packupdate107_289.exe
VT: 18 /43 (41.9%)

Pay-Per-Install (PPI)

file: 02e62d95997b7db323175910bf14e19c file.1.exe
VT: 10/ 43 (23.3%)



This affiliate provides a URL that produces dynamic malware binaries. The attackers attempt to trick users into installing the malware by pretending that it is Adobe's Flash player. The attackers script periodically queries the affiliate's distribution point to receive a new binary, each new binary has a different hash value.

In addition, the attackers used malware detection services to scan the binaries to see how AV products detected them. The attackers used scan4you.biz, which Brian Krebs documented earlier this year, as well as ghostbusters.cc.



When executed this trojan attempt to connect to intromem.com and imagehut4.cn along with several other domains (murambus.net, aboutkayndu.net, officialgigaify.net, kataburglary.net, ftuny.com, 2youg.com) followed by numerous connections to ad servers.

In summary, this is not a complicated operation and is largely automated. The system collects what users search for and then creates fake pages based on those queries. search engines are fed these bogus pages and users are redirected to the SEO server that collects statistical information and the forward the user on to a monetization strategy either RogueAV, PPI or PPC. All the attackers need is a fresh supply of compromised FTP credentials which can be purchased in the cybercrime underground.