Nyatya Wiper Malware

Nyatya – a Wiper Malware disguised as Ransomware

Nyatya Wiper Malware

A new malware Nyetya (combination of words from Nye Petya, meaning NOT Petya), also known as Petrwrap and GoldenEye has been spreading globally over the last 24 hours.

This virus is distinct from WannaCry and other initially suspected variants, it has some unique new features which makes it harder to detect and defend against, clearly showing that today’s malware landscape is an evolving space. This rapidly changing threat landscape has a number of factors including; leaked tools from government agencies, more advanced security controls that require advanced malware (the cat and mouse game) or just because attackers are more determined and more capable.

Other popular researchers (links below) say Nyetya is more of a nation (state) attack towards a specific country (Ukraine) that is disguised as ransomware so its true nature would remain hidden in the shadow of recent WannaCry ransomware.

Some Characteristics of Nyetya and why it is different

  1. There is recent research that showed Nyetya, despite having major resemblance to Petya ransomware, in fact does not keep a copy of the encrypted MTL (Master File Table) and MBR (Master Boot Record) that it replaces with the random note. That means that even in the case that the user gets its decryption keys there is nothing to decrypt. This behavior resembles specific type of malware called Wiper Malware. All machines that are infected cannot be recovered. Also, the email for contract with the attackers is now disabled so there is no possibility for getting the decryption keys. Obviously, the attackers have not intended to milk the ransom and get rich for their efforts.
  2. It encrypts the master boot record, which makes the whole system unusable and causes more damage. Previous crypto viruses (ransomware) were encrypting specific file extensions
  3. It does not use a common attack vector from the Internet

It does not infect by scanning ports for vulnerable services, nor uses phishing (mails with crafted content with specific covert malware links), nor file attachments or web sites that host malicious content. Instead the initial way in was via an update in a polular accounting software in Ukraine (called MeDoc). The software was tricked into auto-updating with a malicious file (Perfc.dat). Once it is inside it uses the Eternal Blue (SMBv1) exploit to spread (same as WannaCry) but also two other administrative tools (PSexec and WMI) which in general are valid and legitimate tools used inside a network. The use of these tools would not raise any alarms on network security controls. The malware is capable of stealing the current user’s token and use it to distribute itself to other devices via PSexec (still unclear how it is able to steal the token) or again to steal the current user credentials and use them via WMI.

  1. No external Internet scans

There is no evidence of external scans (from the internet) in order to locate unpatched SMB services. The only scans that the virus conducts are horizontal, once it is inside the protected network. That makes the virus very hard to detect as most organisations do not have visibility within their network for such activity

  1. No Command and Control functionality

The virus does not use C&C so any reputation based security controls cannot detect it. IP addresses/domains reputation is widely used to detect zero-day attacks and to monitor the spread of the virus. That does not seem feasible protection from Nyetya

  1. Special attention has been paid to cleaning up any remaining data and logs

All of these unique characteristics point to the fact that cyber criminals have changed their tactics (after the failure of WannaCry due to the incidental but timely discovery of the killswitch) and want the malware spread to be as stealthy as possible.

Protecting yourself from the attack

A short summary of techniques necessary to protect against the attacks are listed below. These cannot be undertaken in isolation and it is assumed that good security practices are already in place such as disaster recovery strategy as well security control such anti-malware controls.

  1. Patch your systems (MS17-010 should be applied), close off any SMBv1 services (disable)
  2. Do not use admin/elevated privileged accounts for normal users
  3. Monitor your network and endpoints for PSexec and WMI communication and try to establish if that is valid communication (could be based on which one the administrators use and also the time of the day)
  4. Monitor your internal network segments using an IDS/IPS

Which type of network security controls are best suited to discover and prevent malware spread?

While other forms of malware attack may have been stopped by reputation based or email and web security controls, neither would have been effective in this instance. An essential tool in the armoury of security controls is endpoint security such as Cisco AMP for Endpoints, which actively analyse the behaviour of executable files on the system and perform sandboxing.

IDS/IPS network controls are able to catch lateral scans and spread via SMBv1 exploit only if they can see the traffic (actively monitoring traffic on the same logical domain).  The most common IDS/IPS deployment model is on the Internet edge, as this malware does not use external scans or gets distributed via normal Internet related channels (mail and web) these controls are not effective.

Following general security best practises is also beneficial – having backup of important systems/files, having proper application visible monitoring on the network and trying to detect unusual behavior, that of course requires both the tools and the people (analyst).

Used materials:

Person typing on laptop showing the Wannacry virus on screen

WannaCry crypto virus outbreak

Person typing on laptop showing the Wannacry virus on screen

As you might be aware this Friday (12th of May 2017) there was a massive outbreak of a new type of crypto virus dubbed WannaCrypto aka WannaCry. The UK was hit the hardest, especially in the Health Sector, with Spanish Telecom – Telefonica, along with Portuguese & Argentinian telecoms and Russia.

How does that affect the UK? – The NHS is badly crippled (more than 30 hospitals reported malware spread), patients are being turned away, important data such as scans and personal test results are lost and planned surgeries are cancelled. We could easily say that lives are at stake as sometimes more critical operations had to be postponed or done without important tests/scan results.

About the attack:

The WannaCry outbreak is the quickest spread of malware ever (over 100 countries with many affected endpoints in a matter of hours).

This link shows the spread over time. The animation was made possible because the authors of MalwareTech, could hack into one of the Command and Control domains and gain control over it so they can trace the incoming call home requests from the hacked machines (keep in mind that this does not depict the whole spread of the virus as MalwareTech operated in EST time and the spread in Europe and Asia was already going for some hours).

Another unique thing – the virus exploited a vulnerability in Windows OS systems that was used for years by the NSA and GCHQ government agencies but only revealed for the public a couple of months ago (by the ShadowBroker dump on the 14th of April)

Here the Security Industry in the world are divided in their opinions.

One opinion is that the vulnerability should have never been leaked so bad guys would not be aware of it and hence would not be able to exploit it. This is usually the opinion of non-hardened security guys since it loudly shouts – Security through Obscurity or the ostrich effect.

The second opinion is that not a single discovered vulnerability should remain hidden, the more people are aware of the threat, the more people can react to it. General security admins had more than two months to patch their systems as official patch from Microsoft was released quickly after the leak (official patch was released on the March 14th). One important note was that many government, slow and big organization (due their sheer size and bureaucracy) are still running Windows XP and since XP is out of life and support, there was no patch for it – An example for such organization was the NHS.

Kill switch

The virus had a kill switch designed by its creators, a hidden nonsense long domain that if alive will make the virus stop spreading. A researcher found it by looking at the malware (reverse engineering it) and he was not sure why is was there, so he registered the domain and luckily helped in stopping the spread (the malware checks if that domain is alive before attempting worm like spread in the same L2 network)

The Onion Router

Botnet Command and Control centres are located in TOR (the onion router)

OK, that has been done before so not quite unique but very hard to implement as the malware needs to download a whole lot of files to the end user device to make this work. The technique is adding anonymity to the guys running the botnet (hence the creators of the malware). CC is very important for Crypto Viruses as these are usually created not to destroy but to extort money out of people who want their files recovered and recovery is done via this backchannel by supplying the key. If people pay and their files do not get recovered the rumour spreads and people accept their losses and do not pay anything. The current estimation for infected systems with encrypted files is more than $55 000 and attackers want an average of £300 for endpoint recovery, that amounts to a hefty ransom sum (if 20 000 users pay, that is over 6 million dollars).

Ransom Note

Heavily customised and detailed interaction user/victim – The information displayed to the user explains in detail what has happened and what needs to be done (how to pay) to recover your files and it is translated and shown in 28 languages. The presentation (ransom note below) is done via an executable file and offers many options.

Wannacry crypto virus on screen image

How does the attack work?

The malware uses a vulnerability in the SMBv2 remote code execution in Microsoft Windows. The exploit (codenamed “EternalBlue”) has been made available on the internet through the Shadowbrokers dump on April 14th, 2017 and patched by Microsoft on March 14. Usually, SMB’s are not directly connected to the outside world, the attack point was via email as well as the spread or a quick vertical scan for port TCP 445. After initial infection, the virus spread like a worm, probing all hosts within the subnet for open SMB ports and trying to infect them. Also, quite unique for this virus is that it uses different services for performing different tasks, aka Modular Service approach – for example, it uses different services for file dumping, for finding files with particularly important extensions and encrypting them, for disabling the shadow copy/system restore, for presenting the screen with the note/demands/payment information – yes that is a separate executable file.

Protection techniques

  • Patch – regular/automated patching of windows systems would have prevented the malware to do any damage by removing the vulnerability that should be exploited
  • Security Training – organisation employees should be aware of the dangers of executing files from emails or clicking on links
  • Advanced malware protection on the endpoints – could stop the execution of the malware in the first stage or downloading and installation of the malware in the second stage
  • Email security – strong email security would have greatly reduced the spread of the malware or disabled any executable files from being delivered to the users (depends on tuning, but even files with unknown status should be held back and guaranteed before further analysis can be done) or will check URLs in mails and you determine if you able to click on them (more modern Email protection systems have built in Web URL protections)
  • Web security controls – would help in cases when the infection point happens by URL link in email
  • Advanced IPS with Command and Control botnet detection – would not be effective in the first minutes of the spread but will quickly update itself (depending on vendor) and will detect/drop outgoing CC connections. Traditional firewalls with stateful technology would not help except by blocking SMB traffic based on TCP 139/445 ports (however traditional firewall deployment does not scan east to west traffic and traffic in the same L2 network)
  • Backup your important information in a separate secure location – a reactive approach but very effective towards crypto viruses

Mitigation techniques (after the attack)

Unfortunately, after files are encrypted, it is close to impossible to decrypt them without having the proper key. Most endpoint protection companies give you a list of things to do to remove the virus, hinder its spread, and be immune in the future but not to recover files. General recommendation varies between different vendors but most of them follow these steps.

  • Make sure your endpoint protection software is running and not disabled by virus.
  • Download latest signatures
  • Install the PATCH from Microsoft (MS17-010) which fixed the SMBv2 vulnerability
  • Scan all systems, the virus is detected (usually by the name MEM: Trojan.Win64.EquationDrug.gen), and reboot the system (before that make sure you have the patch installed).

Indicators of compromise

How to check if your network has the malware. Typical indications are listed in the link below

Basically, you must request certain IPs on the Internet and you have seen a file transfer with the mentioned SHA-256 fingerprint (keep in mind there is small variations of the virus so there is multiple fingerprints)