The ransomware was a modified version of the WannaCrypt0r toolkit, one of those released by a group called Shadow Brokers in April. Security firms gave it the arbitrary name WannaCry or Wanna Decrypt0r.
A 22-year-old British researcher, who has chosen to remain unknown and only identifiable by his Twitter handle, MalwareTech, was examining the massive attack when he looked at the source code of the malware and found a domain name within.
Graphic courtesy Cisco's Talos blog.
He reasoned that this could be a command and control server and promptly registered the domain (seen in the screenshot above) which appeared to be a random name, comprising letters from the top two rows of a keyboard. It cost him just US$10.69.
But his action unwittingly stopped the malware from spreading as it had been programmed to check this domain, and continue spreading if it could not access the domain. Once MalwareTech registered the domain, it was accessible, and once this happened the attacks gradually slowed down.
It appears that the attackers had put in this domain name so that they would have a means of stopping attacks when they deemed fit, by registering the same.
Explaining what the code was doing, he wrote: "All this code is doing is attempting to connect to the domain we registered and if the connection is not successful it ransoms the system, if it is successful the malware exits (this was not clear to me at first from the screenshot as I lacked the context of what the parent function may be doing with the results)."
But by then, nearly 100 countries had been affected. Britain bore the brunt of attacks on essential services with hospitals belonging to the National Health Service being hit and patients having to be diverted to other hospitals. Russia, India, Germany, Spain, the US and Turkey.
I will confess that I was unaware registering the domain would stop the malware until after i registered it, so initially it was accidental.— MalwareTech (@MalwareTechBlog) May 13, 2017
However, a researcher from Kaspersky Lab told the Motherboard website that a version of WannaCry without the domain name had now surfaced. Hence if new attacks were launched, then they would succeed.
While some security companies like CrowdStrike — which came under a cloud last year after providing security to the Democratic National Committee during the email leaks and then failed to call in the FBI to check the servers after the compromise — claimed that the "targeting was likely in bulk, via massive phishing campaigns", there was no evidence of this.
Analysts from other companies noted that there appeared to be two dimensions to the infections: initially, there were probes by the malware to see if ports 445 and 139 on Windows machines were open externally and whether the Windows operating systems in question were vulnerable.
If this condition was satisfied, then the actual ransomware was downloaded and executed on the server in question.
In a detailed blog post about the incident — modestly headlined "How to accidentally stop a global cyber attack" — MalwareTech wrote that a standard model of looking for wayys to track and stop malware went like this:
- "Look for unregistered or expired C2 domains belonging to active botnets and point it to our sinkhole (a sinkhole is a server designed to capture malicious traffic and prevent control of infected computers by the criminals who infected them).
- "Gather data on the geographical distribution and scale of the infections, including IP addresses, which can be used to notify victims that they’re infected and assist law enforcement.
- "Reverse engineer the malware and see if there are any vulnerabilities in the code which would allow us to take-over the malware/botnet and prevent the spread or malicious use, via the domain we registered.
"In the case of WannaCrypt, step 1, 2 and 3 were all one and the same, I just didn’t know it yet," he wrote..
MalwareTech, who works for a small security firm known as Kryptos Logic, said initially he heard from others that registering the domain had triggered the malware to continue. But later he heard the opposite from a researcher at security firm ProofPoint.