1. Symantec/
  2. Security Response/
  3. Ransom.Wannacry

Ransom.Wannacry

Risk Level 2: Low

Discovered:
May 12, 2017
Updated:
May 24, 2017 1:46:26 PM
Type:
Trojan, Worm
Infection Length:
Varies
Systems Affected:
Windows
WannaCry is a threat composed of two main parts, a worm module and a ransomware module. The ransomware module is spread by a companion worm module. The worm module uses the Microsoft Windows SMB Server Remote Code Execution Vulnerability (CVE-2017-0144) and the Microsoft Windows SMB Server Remote Code Execution Vulnerability (CVE-2017-0145) to spread.


WORM MODULE
The worm module is the component responsible for the propagation of the threat. It uses the Microsoft Windows SMB Server Remote Code Execution Vulnerability (CVE-2017-0144) and the Microsoft Windows SMB Server Remote Code Execution Vulnerability (CVE-2017-0145) to spread.

The vulnerabilities impact all versions of the Windows operating system running SMBv1. Patches were released by Microsoft on March 14, 2017.

The vulnerability known as EternalBlue was part of a cache of secret tools, documents, and files that was released by the Shadow Brokers back in April 2017. Shadow Brokers released the cache after several failed attempts to sell the leaked materials.

Technical details
When the worm module is executed, it attempts to contact one of the following remote locations:
  • iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com
  • ifferfsodp9ifjaposdfjhgosurijfaewrwergwea.com

If the remote location is reachable, the worm module will exit immediately. This functionality acts as a kill-switch enabling the threat to be stopped. When the threat was first released, the domains were not registered or active, which meant that the worm continued to spread. Security researchers have now sinkholed the domains meaning that versions of the worm that contained the kill-switch will no longer infect computers or spread.

Note: Subsequent versions of the worm have the kill-switch removed, meaning that newer versions will work as intended.

Service creation
When the worm executes, it registers itself as a service with the following details:

Service name: mssecsvc2.0
Display name: Microsoft Security Center (2.0) Service
Binary path: [PATH_TO_WORM] -m security
Start type: SERVICE_AUTO_START

Dropping the ransomware module
The ransomware module is embedded as a resource in the worm itself.

After successful startup of the worm module, it attempts to drop the ransomware module. It first clears a space for the file by renaming the existing tasksche.exe to C:\WINDOWS\qeriuwjhrf.

It then drops the ransomware module as the following file to replace the existing tasksche.exe:
  • %Windir%\tasksche.exe

Installing and accessing Tor
The worm module then tries to download and install Tor. It tries to download a copy of Tor from the following locations:
  • www.dropbox.com/s/yw3rvyotvb4gcnh/t1.zip?dl=1
  • dist.torproject.org/torbrowser/6.5.1/tor-win32-0.2.9.10.zip

Note: Some versions of the worm contain a copy of Tor and do not need to download it.

Once the .zip file is downloaded, the tor.exe file is extracted and saved as taskhosts.exe and then executed to establish access to the Tor network.

The worm may attempt to connect to the following Tor domains:
  • gx7ekbenv2riucmf.onion
  • 57g7spgrzlojinas.onion
  • xxlvbrloxvriy2c5.onion
  • 76jdd2i r2embyv47.onion
  • cwwnhwhlz52maqm7.onion

The Tor domains do not provide attacker command and control. The Tor domains are intended to track infections and provide a unique Bitcoin payment address and decryption keys if the victim pays. However, due to a bug this does not execute correctly.

Propagation routine
The worm module then attempts to spread by scanning for IP addresses of other computers.

It scans for open TCP port 445 on the following IP addresses:
  • IP addresses within the same subnet as the compromised computer (spreading within the same network)
  • Randomly generated IP addresses (spreading to any computer)



    Once it establishes contact with another computer, it will attempt to use the Microsoft Windows SMB Server Remote Code Execution Vulnerability (CVE-2017-0144) and the Microsoft Windows SMB Server Remote Code Execution Vulnerability (CVE-2017-0145) to spread.


    RANSOMWARE MODULE
    The ransomware module is the part of the threat responsible for performing the extortion-related activities and is installed by the worm module.

    Files
    When it is first executed, it copies itself to the following locations:
    • %SystemDrive%\ProgramData\[RANDOM_STRING]\tasksche.exe
    • %SystemDrive%\Intel\[RANDOM_STRING]\tasksche.exe

    It may then create the following files:
    • [PATH_TO_RANSOMWARE]\!WannaDecryptor!.exe
    • [PATH_TO_RANSOMWARE]\c.wry
    • [PATH_TO_RANSOMWARE]\f.wry
    • [PATH_TO_RANSOMWARE]\m.wry
    • [PATH_TO_RANSOMWARE]\r.wry
    • [PATH_TO_RANSOMWARE]\t.wry
    • [PATH_TO_RANSOMWARE]\u.wry
    • [PATH_TO_RANSOMWARE]\TaskHost
    • [PATH_TO_RANSOMWARE]\00000000.eky
    • [PATH_TO_RANSOMWARE]\00000000.pky
    • [PATH_TO_RANSOMWARE]\00000000.res
    • %Temp%\0.WCRYT
    • %Temp%\1.WCRYT
    • %Temp%\2.WCRYT
    • %Temp%\3.WCRYT
    • %Temp%\4.WCRYT
    • %Temp%\5.WCRYT
    • %Temp%\hibsys.WCRYT
    • %UserProfile%\Desktop\!WannaCryptor!.bmp
    • C:\Intel\zirjvfpqmgcm054\TaskData\Tor\taskhsvc.exe
    • C:\Intel\zirjvfpqmgcm054\TaskData\Tor\tor.exe
    • C:\Intel\zirjvfpqmgcm054\taskdl.exe
    • C:\Intel\zirjvfpqmgcm054\tasksche.exe
    • C:\Intel\zirjvfpqmgcm054\taskse.exe
    • C:\Intel\zirjvfpqmgcm054\@WanaDecryptor@.exe
    • C:\Intel\zirjvfpqmgcm054\msg\m_bulgarian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_chinese (simplified).wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_chinese (traditional).wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_croatian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_czech.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_danish.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_dutch.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_english.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_filipino.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_finnish.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_french.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_german.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_greek.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_indonesian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_italian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_japanese.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_korean.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_latvian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_norwegian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_polish.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_portuguese.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_romanian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_russian.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_slovak.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_spanish.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_swedish.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_turkish.wnry
    • C:\Intel\zirjvfpqmgcm054\msg\m_vietnamese.wnry
    • C:\Intel\zirjvfpqmgcm054\b.wnry (copy of @WanaDecryptor@.bmp)
    • C:\Intel\zirjvfpqmgcm054\c.wnry
    • C:\Intel\zirjvfpqmgcm054\f.wnry
    • C:\Intel\zirjvfpqmgcm054\r.wnry (copy of @Please_Read_Me@.txt)
    • C:\Intel\zirjvfpqmgcm054\s.wnry
    • C:\Intel\zirjvfpqmgcm054\t.wnry
    • C:\Intel\zirjvfpqmgcm054\u.wnry

    Registry modifications

    The ransomware module may create the following registry entries:
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"Microsoft Update Task Scheduler" = ""[PATH_TO_RANSOMWARE]\[RANSOMWARE_EXECUTABLE]" /r"
    • HKEY_LOCAL_MACHINE\SOFTWARE\WannaCryptor\"wd" = "[PATH_TO_RANSOMWARE]"
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"zirjvfpqmgcm054" = ""C:\Intel\zirjvfpqmgcm054\tasksche.exe""
    • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\zirjvfpqmgcm054\Security\"Security" = "[HEXADECIMAL VALUE]"
    • HKEY_LOCAL_MACHINE\SOFTWARE\WannaCryptor\"wd" = "[PATH_TO_RANSOMWARE ]"

    The ransomware module also sets the following registry entry to change the desktop background image:
    • HKEY_CURRENT_USER\Control Panel\Desktop\"Wallpaper" = "%UserProfile%\Desktop\!WannaCryptor!.bmp"

    Service creation
    It then creates the following service which will enable it to be restarted whenever the computer starts:

    Service name: [RANDOM_STRING]
    Display name: [RANDOM_STRING]
    Binary path: cmd.exe /c [PATH_TO_RANSOMWARE]
    Start type: SERVICE_AUTO_START

    End processes
    It attempts to end the following processes:
    • sqlwriter.exe
    • sqlserver.exe
    • Microsoft.Exchange.*
    • MSExchange*



      Ending the processes releases the lock on the associated data files so that they can be encrypted or overwritten

      Encryption routine
      After successful installation, the ransomware module will then search for files to encrypt. It looks for files with the following file extensions:
      • .123
      • .3dm
      • .3ds
      • .3g2
      • .3gp
      • .602
      • .7z
      • .ARC
      • .PAQ
      • .accdb
      • .aes
      • .ai
      • .asc
      • .asf
      • .asm
      • .asp
      • .avi
      • .backup
      • .bak
      • .bat
      • .bmp
      • .brd
      • .bz2
      • .cgm
      • .class
      • .cmd
      • .cpp
      • .crt
      • .cs
      • .csr
      • .csv
      • .db
      • .dbf
      • .dch
      • .der
      • .dif
      • .dip
      • .djvu
      • .doc
      • .docb
      • .docm
      • .docx
      • .dot
      • .dotm
      • .dotx
      • .dwg
      • .edb
      • .eml
      • .fla
      • .flv
      • .frm
      • .gif
      • .gpg
      • .gz
      • .hwp
      • .ibd
      • .iso
      • .jar
      • .java
      • .jpeg
      • .jpg
      • .js
      • .jsp
      • .key
      • .lay
      • .lay6
      • .ldf
      • .m3u
      • .m4u
      • .max
      • .mdb
      • .mdf
      • .mid
      • .mkv
      • .mml
      • .mov
      • .mp3
      • .mp4
      • .mpeg
      • .mpg
      • .msg
      • .myd
      • .myi
      • .nef
      • .odb
      • .odg
      • .odp
      • .ods
      • .odt
      • .onetoc2
      • .ost
      • .otg
      • .otp
      • .ots
      • .ott
      • .p12
      • .pas
      • .pdf
      • .pem
      • .pfx
      • .php
      • .pl
      • .png
      • .pot
      • .potm
      • .potx
      • .ppam
      • .pps
      • .ppsm
      • .ppsx
      • .ppt
      • .pptm
      • .pptx
      • .ps1
      • .psd
      • .pst
      • .rar
      • .raw
      • .rb
      • .rtf
      • .sch
      • .sh
      • .sldm
      • .sldx
      • .slk
      • .sln
      • .snt
      • .sql
      • .sqlite3
      • .sqlitedb
      • .stc
      • .std
      • .sti
      • .stw
      • .suo
      • .svg
      • .swf
      • .sxc
      • .sxd
      • .sxi
      • .sxm
      • .sxw
      • .tar
      • .tbk
      • .tgz
      • .tif
      • .tiff
      • .txt
      • .uop
      • .uot
      • .vb
      • .vbs
      • .vcd
      • .vdi
      • .vmdk
      • .vmx
      • .vob
      • .vsd
      • .vsdx
      • .wav
      • .wb2
      • .wk1
      • .wks
      • .wma
      • .wmv
      • .xlc
      • .xlm
      • .xls
      • .xlsb
      • .xlsm
      • .xlsx
      • .xlt
      • .xltm
      • .xltx
      • .xlw
      • .zip

      Encrypted files
      Files that are encrypted will be renamed with .WCRY appended to the file name. For example:
      • Original file name: readme.txt
      • Encrypted file name: readme.txt.WCRY

      The following files are dropped inside every folder where files are encrypted:
      • Please_Read_Me@.txt
      • @WanaDecryptor@.exe.lnk
      • !WannaDecryptor!.exe.lnk
      • !Please Read Me!.txt

      Encryption keys
      Each file is encrypted with a separate AES (symmetric) encryption key. Each AES encryption key is separately encrypted using 2048 bit RSA (public key encryption).

      Delete shadow copies

      The ransomware module attempts to delete the shadow copies of encrypted files to try prevent users from being able to restore files to their original state.

      Ransom note
      Once the encryption routine is completed, the ransomware module displays a window containing the ransom demand.


      The ransomware module has been designed to support multiple languages.


      OTHER FUNCTIONALITY
      The ransomware module creates the following mutexes so that only one instance of the ransomware can run:
      • Global\WINDOWS_TASKOSHT_MUTEX0
      • Global\WINDOWS_TASKCST_MUTEX
      • Global\MsWinZonesCacheCounterMutexA

      Ransom payment
      The WannaCry payment logic is as follows:
      1. WannaCry will create a file named 00000000.res which contains information including a unique user ID, total encrypted file count, and total encrypted file size etc.
      2. WannaCry sends the user data in 00000000.res to the C&C servers which are hidden in the Tor network.
      3. The WannaCry C&C server returns a new Bitcoin address which is linked to the user. The new Bitcoin address will be saved to the configuration file c.wnry to replace the old address (which is hardcoded in the sample).
      4. Once the "Check Payment" button is clicked, WannaCry will send the user data in 00000000.res and the encrypted private key in 00000000.eky to the C&C servers.
      5. If the payment is confirmed, the C&C servers will return the decrypted private key.
      6. WannaCry then saves the decrypted private key to 00000000.dky and the decryption process uses the key in 00000000.dky to decrypt the files.

      Due to a race condition bug, the above code fails and defaults to three bitcoin addresses:

      As these Bitcoin addresses are shared among all victims as the method of payment, the attacker will be unable to determine whether a victim has paid.

      Recommendations

      Symantec Security Response encourages all users and administrators to adhere to the following basic security "best practices":

      • Use a firewall to block all incoming connections from the Internet to services that should not be publicly available. By default, you should deny all incoming connections and only allow services you explicitly want to offer to the outside world.
      • Enforce a password policy. Complex passwords make it difficult to crack password files on compromised computers. This helps to prevent or limit damage when a computer is compromised.
      • Ensure that programs and users of the computer use the lowest level of privileges necessary to complete a task. When prompted for a root or UAC password, ensure that the program asking for administration-level access is a legitimate application.
      • Disable AutoPlay to prevent the automatic launching of executable files on network and removable drives, and disconnect the drives when not required. If write access is not required, enable read-only mode if the option is available.
      • Turn off file sharing if not needed. If file sharing is required, use ACLs and password protection to limit access. Disable anonymous access to shared folders. Grant access only to user accounts with strong passwords to folders that must be shared.
      • Turn off and remove unnecessary services. By default, many operating systems install auxiliary services that are not critical. These services are avenues of attack. If they are removed, threats have less avenues of attack.
      • If a threat exploits one or more network services, disable, or block access to, those services until a patch is applied.
      • Always keep your patch levels up-to-date, especially on computers that host public services and are accessible through the firewall, such as HTTP, FTP, mail, and DNS services.
      • Configure your email server to block or remove email that contains file attachments that are commonly used to spread threats, such as .vbs, .bat, .exe, .pif and .scr files.
      • Isolate compromised computers quickly to prevent threats from spreading further. Perform a forensic analysis and restore the computers using trusted media.
      • Train employees not to open attachments unless they are expecting them. Also, do not execute software that is downloaded from the Internet unless it has been scanned for viruses. Simply visiting a compromised Web site can cause infection if certain browser vulnerabilities are not patched.
      • If Bluetooth is not required for mobile devices, it should be turned off. If you require its use, ensure that the device's visibility is set to "Hidden" so that it cannot be scanned by other Bluetooth devices. If device pairing must be used, ensure that all devices are set to "Unauthorized", requiring authorization for each connection request. Do not accept applications that are unsigned or sent from unknown sources.
      • For further information on the terms used in this document, please refer to the Security Response glossary.
      Writeup By: Symantec Security Response
      Summary| Technical Details| Removal

      Search Threats

      Search by name
      Example: W32.Beagle.AG@mm
      STAR Antimalware Protection Technologies
      2016 Internet Security Threat Report, Volume 21
      • Twitter
      • Facebook
      • LinkedIn
      • Google+
      • YouTube