The WannaCry ransomware (May 2017)
In one day it encrypted more than 200,000 computers in 150 countries and disrupted hospitals. Follow the worm through a hospital network and see how one domain name stopped it.
In one day it encrypted more than 200,000 computers in 150 countries and disrupted hospitals. Follow the worm through a hospital network and see how one domain name stopped it.
12 May 2017. Red screens in the departments of Tigris Teaching Hospital (fictional): radiology, the lab and the pharmacy. You have the DNS log, the connection log, a summary of SMB packets, the host inventory and the EDR sweep.
0 of 17 · 0 of 260 points
Linux terminal
Try this room's commands on real Linux running in your browser, with the files you need.
Task 1: Introduction
Scenario: 12 May 2017. Red screens in the departments of Tigris Teaching Hospital (fictional): radiology, the lab and the pharmacy. You have the DNS log, the connection log, a summary of SMB packets, the host inventory and the EDR sweep.
What you'll learn in this room
- Understand how ransomware spread like a worm through SMB and EternalBlue
- Find patient zero and the spread path from network logs
- Understand the kill switch and why one host survived while others were encrypted
Each task has an explanation and questions you answer by typing. At the end there is a hands-on lab where you hunt for flags, then the quiz.
1.1Let's start
Task 2: What happened in the world
What happened in the world
- On 12 May 2017 the WannaCry ransomware spread and encrypted more than 200,000 computers in about 150 countries. Among the best known victims were hospitals of the UK's National Health Service (NHS).
- It asked for $300 in bitcoin, rising to $600 after 3 days, and threatened to delete the files after 7 days. Encrypted files end in
.WNCRY. - It used a flaw in SMBv1 through a tool named EternalBlue, leaked by the Shadow Brokers group in April 2017. Microsoft had released the fix, MS17-010, on 14 March 2017, two months before the attack.
- In December 2017 the United States and the United Kingdom attributed the attack to North Korea (the Lazarus group).
cd incidents/wannacry
cat hosts.csv
grep -c ',no,' hosts.csv
2.1In hosts.csv, which Microsoft bulletin number does the patch column track?
52.2How many hosts in the inventory do not have this patch installed?
52.3In ransom-note.txt, how many dollars does the ransom become after 3 days?
5Task 3: How it spread
How it spread
- WannaCry was not just ransomware, it was a worm: once it infected a machine, it scanned IP addresses on the internal network and on the internet on port 445 (SMB).
- If it found a machine with unpatched SMBv1, it exploited it with EternalBlue, planted a backdoor named DoublePulsar, copied itself over and installed a service named
mssecsvc2.0. - In the packets you see: a negotiation on
NT LM 0.12(meaning SMBv1), a connection toIPC$, unusually large NT Trans requests, and aTrans2 SESSION_SETUPrequest, a known sign of DoublePulsar. - Patched machines answer on the port, but the exploit fails on them.
cat conn.log
grep ' 445 ' conn.log | awk '{print $2}' | sort | uniq -c
cat smb.txt
3.1In conn.log, what is the IP of patient zero (the first host scanning port 445)?
103.2With how many internal hosts (10.5.x.x) did this host complete a full session (SF) on port 445?
103.3In smb.txt, which SMB version was agreed in the negotiation?
53.4What is the name of the Trans2 request that is a known sign of DoublePulsar?
5Task 4: The kill switch
The kill switch
- Before encrypting, every copy tried to reach a long, strange domain. If it did not answer (NXDOMAIN) it went on and encrypted, and if it answered it stopped.
- British researcher Marcus Hutchins registered that domain the same day, so copies that ran afterwards stopped on their own, which slowed the spread around the world.
- As an analyst: the DNS log shows every machine that asked for the domain, meaning every machine the worm reached, even if it was not encrypted.
cat dns.log
grep NXDOMAIN dns.log
4.1In dns.log, what is the kill switch domain?
104.2How many hosts asked for the domain and got the answer NXDOMAIN?
5Task 5: Lab: The day of the red screens
The day of the red screens
Link the DNS log to the host inventory and the EDR sweep: who was encrypted, who survived, and why? Then open the triage file of the host the kill switch saved.
cat edr-files.txt
awk '{s+=$2} END {print s}' edr-files.txt
ls hosts
5.1How many .WNCRY files in total did the EDR sweep find across all hosts?
105.2Which host (hostname) did the worm reach, but the exploit failed because it was patched?
105.3Which host (hostname) was infected after the kill switch domain was registered, so it was not encrypted?
105.4Find the flag in the triage file of the host saved by the kill switch, inside the hosts folder.
20Task 6: Quiz
Quiz
Answer the questions to complete the room. Go back to the tasks if you need to.
6.1What made WannaCry spread so fast between machines on the network?
506.2What would have prevented the infection in the first place?
506.3Why was a machine that reached the kill switch domain and got an answer not encrypted?
50