wannacry-analysis

WannaCry From the Outside In — A Recovered Worm Payload With the Kill Switch Patched Out

This sample came to me as a file called e9c82c0f…a661.exe, labelled as WannaCry. It is WannaCry, but not the part people usually look at. It isn’t the ransomware and it isn’t the famous mssecsvc.exe dropper. It’s the small 64-bit DLL that the worm pushes into other machines over SMB, with a full copy of the worm glued to its end. In other words, it’s what one infected computer sends to the next one.

Two more things made it worth writing up. First, somebody patched the kill switch out: two bytes in the worm were replaced so that registering the famous domain no longer stops it. Second, the file is damaged. Roughly the second half of the embedded worm was overwritten with unrelated data from the disk it was recovered from, so some of the later components simply aren’t there anymore.

As with my previous writeups, everything here is static. I never ran the sample. I read the code in Ghidra, carved each stage out with dd, and only used the network to look up the Bitcoin addresses on a public blockchain explorer.

Triage

$ file e9c82c0f...a661.exe
PE32+ executable for MS Windows 5.02 (DLL), x86-64, 6 sections

$ sha256sum e9c82c0f...a661.exe
e9c82c0f40b82eb9e7fffa7600628fa5dbe6a387829ec13342bb8d75f34ea661

file says it's a 64-bit DLL The .exe extension is misleading: this is a 64-bit DLL. The name was most likely given by whoever collected it.

A few things stood out straight away:

Stage 1 — launcher.dll

DllMain does nothing interesting

The entry point is the standard Visual Studio 2010 DLL startup code. It calls the real DllMain with reason 1 (DLL_PROCESS_ATTACH), and all DllMain does is save its own module handle in a global variable. That handle comes back in a minute.

PlayGame

The only export is three lines long:

PlayGame Build the path C:\WINDOWS\mssecsvc.exe with sprintf, write a file there, run it.

The first function writes the file:

Dropping the resource FindResourceA(hModule, 101, "W"), then LoadResource, LockResource, SizeofResource, CreateFileA and WriteFile.

This is where the saved module handle is used: it tells FindResourceA to look for the resource inside the DLL itself. The resource is type "W", ID 101 (0x65).

The interesting detail is in the last two lines. The number of bytes written is not what SizeofResource returns. It is the first 4 bytes of the resource (*pDVar2), and the data is written starting right after them (pDVar2 + 1, which for a pointer to a 32-bit value means +4 bytes). So the resource is laid out like this:

[ 4-byte size ][ the actual executable ][ padding ]

Looking at the resource in Ghidra confirms it:

The start of resource W/101 00 D0 38 00 is 0x0038D000 (3,723,264) in little-endian, and right after it comes 4D 5A, the MZ of a Windows executable. The resource itself is 0x500000 bytes; the rest is zero padding that never gets written.

The second function starts what it just wrote:

Starting mssecsvc.exe with no window CreateProcessA with CREATE_NO_WINDOW (0x08000000), wShowWindow = 0 (SW_HIDE) and dwFlags = 0x81: no window and no busy cursor.

To get the executable out, I converted the resource address to a file offset with the section table (.rsrc starts at virtual address 0x180011000 and file offset 0xC800, so 0x1800110A4 becomes 0xC8A4), skipped the 4-byte size and copied exactly 0x38D000 bytes:

$ dd if=e9c82c0f...a661.exe of=mssecsvc.bin bs=1 skip=$((0xc8a4+4)) count=$((0x38D000))
$ file mssecsvc.bin
PE32 executable (GUI) Intel 80386, for MS Windows, 4 sections

So the DLL is 64-bit, but what it drops is a 32-bit program. That’s the second stage.

A Damaged Sample

The SHA256 of the extracted file (3f6fcccc…3e75) doesn’t match the well-known mssecsvc.exe hash. My first guess was a different configuration, but if that were the case the differences would be a handful of strings. The entropy graph showed something else:

Entropy of mssecsvc.bin From left to right: normal code and data, then a long flat block at maximum entropy (compressed data embedded in the program), then a sudden drop around the middle of the file to “structured data” levels, a stretch of zeros, and structured data again until the end.

The flat block is expected: it’s a compressed archive that belongs to the next stages. What isn’t expected is for it to stop in the middle. Compressed data doesn’t turn into readable data halfway through. Looking at those bytes, they don’t belong to WannaCry at all. They are fragments of Windows file paths in NT device form, such as:

\Device\HarddiskVolume2\Windows\System32\DriverStore\ru-RU\netrass.inf_loc
\Device\HarddiskVolume2\Windows\System32\ru-RU\runonce.exe.mui
\Device\HarddiskVolume2\Windows\System32\config\systemprofile\AppData\Local\Avg\av16\temp\avg-49fb6b11-....tmp

These are paths from the machine the sample was taken from (it had AVG installed and Russian language files), not from the malware. They start around offset 0x1FC000 of the original file and continue to the end of the embedded worm.

The most likely explanation is that the file was recovered imperfectly, for example carved from a disk after some of its clusters had already been reused by other files, or rebuilt from memory. The .reloc section of the DLL being entirely zeros points the same way. In any case, it isn’t encryption: the replaced bytes have lower entropy and are readable text.

It also doesn’t say anything about who wrote the malware. The Russian paths describe the victim’s system, not the author.

This damage has consequences for the rest of the analysis. The code of both stages is intact, but the archive at the end of the chain is cut short, and the module that actually encrypts files is one of the casualties. I’ll point out where this matters.

Stage 2 — mssecsvc.exe, the Worm

The kill switch that doesn’t kill anything

WinMain is the first thing the worm runs, and it starts with the most famous URL in malware history:

WinMain and the kill switch URL The URL is copied to a local buffer, then InternetOpenA (access type 1, INTERNET_OPEN_TYPE_DIRECT, so no proxy) and InternetOpenUrlA with flags 0x84000000 (INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE).

In the original WannaCry, if that request succeeded the program would close everything and quit. That’s how the outbreak was slowed down on 12 May 2017: a researcher noticed the unregistered domain in the code, registered it, and from that moment every new infection got an answer and stopped.

The decompiled code here has no if around the call that comes next. The listing shows why:

The patched check The result of InternetOpenUrlA is moved to EDI and tested, but the jump that should follow is gone: two NOPs in its place.

Offset Original WannaCry This sample
0x4081A5 75 0E — JNZ → close handles and exit 90 90 — NOP NOP

The result of the request is computed and then ignored. Whether the domain answers or not, the worm carries on. Two things tell me this is a deliberate patch and not part of the damage: the corruption is far away in the second half of the file, while this is in the code section near the start, and it’s exactly the two bytes of a conditional jump, replaced by two valid instructions, with everything around them untouched. Variants with the kill switch removed this way started circulating shortly after the domain was registered. Since the code isn’t obfuscated or integrity-checked, it only takes a hex editor.

(Even in the original, the kill switch didn’t help everywhere. Because of INTERNET_OPEN_TYPE_DIRECT, machines that could only reach the internet through a proxy never got an answer and always kept going.)

Two modes: install and service

After the check, the worm looks at its command line:

Install or run as a service With fewer than two arguments it installs itself; otherwise it starts as a service.

When started with no arguments, as launcher.dll does, it:

  1. creates a service called mssecsvc2.0, display name “Microsoft Security Center (2.0) Service”, that runs <its own path> -m security and starts automatically;
  2. drops and runs the next stage, tasksche.exe (more on that below).

When the service starts, Windows passes -m security on the command line, so the argument count is 3 and the code takes the other branch. It sets the service’s failure actions to restart it after 60 seconds if it crashes, and hands control to ServiceMain:

ServiceMain Register a control handler, report SERVICE_RUNNING, run the worm, sleep for 86400000 ms (24 hours), exit.

The control handler is ordinary service boilerplate (stop, pause, continue). The real work happens in one call:

Starting the worm threads One thread for the local network, then 128 (0x80) threads for the internet, one every 2 seconds.

Where my sample came from

Before starting the threads, the worm prepares what it will send to its victims. This is the part that explained the file I started from:

Building the payloads, part 1 Two 5 MB buffers. One gets a blob from 0x40B020 (0x4060 bytes), the other a blob from 0x40F080 (0x4060 + 0x8844 bytes).

Building the payloads, part 2 Then it opens its own executable (the path it got from GetModuleFileNameA), and writes [file size][the whole file] after each blob.

Both blobs start with MZ:

An embedded DLL in .data

I carved them out. The first is a 32-bit DLL and the second a 64-bit DLL, and both are called launcher.dll with a single export, PlayGame. The size of the second one is 0x4060 + 0x8844 = 0xC8A4, which is exactly the offset where resource W/101 started in my sample. Comparing the bytes:

$ cmp <(head -c $((0xc8a4)) e9c82c0f...a661.exe) launcher_x64.dll && echo identical
identical

So the structure is:

[ launcher.dll (x86 or x64) ][ 4-byte size ][ a copy of mssecsvc.exe ]

That’s exactly what PlayGame reads back: the size, then the executable. My sample is one of these packets, the 64-bit one, as built by an infected machine and delivered to the next. The worm sends it, the target loads the DLL, PlayGame drops mssecsvc.exe and runs it, and the cycle starts again.

Finding targets on the local network

The single local thread builds a list of addresses from the machine’s network configuration:

Reading the network adapters GetAdaptersInfo (called twice: the first call fails with 0x6F, ERROR_BUFFER_OVERFLOW, and returns the size it needs). For every IP address on every adapter it computes the network range from the IP and the subnet mask, and it also adds the /24 around each gateway.

DNS servers too GetPerAdapterInfo adds the /24 of every configured DNS server.

This is smarter than it looks. In a company network, gateways and DNS servers often sit in different segments from the workstations (server rooms, domain controllers), so the worm reaches beyond its own subnet. The list is then sorted and duplicates are removed.

The local scan loop One thread per address, at most 10 at a time (an interlocked counter, Sleep(100) while it’s full), 50 ms between addresses.

Each of those threads first checks whether port 445 (SMB) is open:

The port check A non-blocking socket (ioctlsocket with FIONBIO), connect, then select with a timeout of about a second.

A normal connect to an address that doesn’t answer can hang for 20 seconds or more. This way the worm gives up after about one second, which makes scanning much faster. If the port is open, the attack thread runs with a 10-minute limit; if it takes longer, it’s killed with TerminateThread.

All the socket functions in this binary are imported by number rather than by name, which is why Ghidra shows Ordinal_23, Ordinal_4 and so on. In WS2_32, 23 is socket, 4 connect, 19 send, 16 recv, 3 closesocket, 11 inet_addr, 9 htons, 10 ioctlsocket and 18 select.

Finding targets on the internet

The other 128 threads pick addresses at random:

Generating random IPs Each thread seeds rand with its thread handle, the tick count, the time and its thread ID. The first octet is random but never 127 (loopback) or 224 and above (multicast and reserved).

The random numbers don’t come from rand alone:

CryptGenRandom CryptGenRandom from the crypto context the worm opened at startup, protected by a critical section because 128 threads share it. Only if that fails does it fall back to rand().

That answers a question I had earlier: the worm calls CryptAcquireContextA with CRYPT_VERIFYCONTEXT at startup, and this is the only reason. It’s not encrypting anything; it just wants good random numbers.

A couple of details:

Scanning the whole /24 after a hit If a random address has port 445 open, the thread goes through the whole /24 (.1 to .254) and attacks every host that answers, with a 1-hour limit per host.

Attacking a host

Every target, local or remote, goes through the same function:

The attack sequence Check for MS17-010; if vulnerable, up to 5 rounds of “is the backdoor already there? if not, run the exploit”; then, if the backdoor answers, inject the payload.

if vulnerable to MS17-010:
    up to 5 times:
        wait 3 s
        if DoublePulsar answers → stop trying
        wait 3 s
        run EternalBlue
wait 3 s
if DoublePulsar answers → upload the launcher.dll packet

The two tools come from the April 2017 Shadow Brokers leak:

Each step is easy to recognise in the code.

The vulnerability check sends four SMB packets that are stored ready-made in the data section: Negotiate, an anonymous Session Setup, a connection to the IPC$ share, and a transaction on a named pipe (PeekNamedPipe). Then it looks at the status code in the answer:

The MS17-010 check The bytes 05 02 00 C0 are the status 0xC0000205 (STATUS_INSUFF_SERVER_RESOURCES). An unpatched server answers this request with that error; a patched one doesn’t.

The packets are pre-recorded, which is visible both in the list of old SMB dialects stored in the binary and in a few placeholders that get replaced with the real values the server sends back:

SMB dialect names The dialect list of the Negotiate packet: LANMAN1.0, Windows for Workgroups 3.1a, LM1.2X002, LANMAN2.1, NT LM 0.12.

Placeholders in the packets \\%s\IPC$ and __USERID__PLACEHOLDER__. Before sending the next packet, the worm patches in the user ID and tree ID from the server’s previous answer.

The backdoor check sends a Trans2 SESSION_SETUP packet, which is the DoublePulsar ping, and looks at the Multiplex ID field of the answer:

The DoublePulsar check If the Multiplex ID is 0x51 ('Q'), the backdoor is installed.

This means the worm doesn’t fire EternalBlue at a machine that already has the backdoor, which avoids crashing it. It also means that a machine that is already patched but still has DoublePulsar from an earlier compromise will be infected anyway, because the last step only checks for the backdoor.

The exploit itself is the long function at 0x401370: many sockets, timing with GetTickCount, large blocks of prepared data. I identified it but didn’t take it apart instruction by instruction.

EternalBlue

The injection pings the backdoor again, derives a key from its answer, and uploads the payload:

Injection through DoublePulsar Same ping, same 'Q' check, then the key is computed from the answer.

The key calculation A 32-bit value from the answer is byte-swapped and XORed with twice its original value. The result is the XOR key DoublePulsar expects for the uploaded data.

Dropping the ransomware

The last thing the installer branch does is write and start the next stage:

Dropping tasksche.exe CreateProcessA, CreateFileA, WriteFile and CloseHandle are looked up with GetProcAddress instead of being imported, so they don’t appear in the import table. The resource is FindResourceA(NULL, 0x727, "R"), i.e. type R, ID 1831.

It builds C:\WINDOWS\tasksche.exe, moves any existing copy to C:\WINDOWS\qeriuwjhrf, and writes the whole resource. This time there’s no size field in front: the resource starts directly with MZ.

Resource R/1831

Starting it with /i The path gets " /i" appended and is started with CREATE_NO_WINDOW.

$ dd if=mssecsvc.bin of=tasksche.bin bs=1 skip=$((0x320a4)) count=$((0x35a000))
$ file tasksche.bin
PE32 executable (GUI) Intel 80386, for MS Windows, 4 sections

Its compile timestamp says 20 November 2010, two minutes after the one in mssecsvc.exe. Neither is believable; the DLL’s May 2017 date is the realistic one.

Stage 3 — tasksche.exe, the Ransomware Installer

The main flow

tasksche WinMain

In order, WinMain:

  1. generates a victim ID from the computer name;
  2. if started with /i, creates a folder named after that ID (in C:\ProgramData, C:\Intel or %TEMP%, trying them in that order, with the drive taken from the Windows folder), copies itself there as tasksche.exe and starts that copy, as a service if it can (cmd.exe /c "<path>");
  3. saves its working folder in the registry;
  4. extracts an embedded password-protected archive;
  5. writes one of three Bitcoin addresses into the configuration;
  6. runs attrib +h . (hide the folder) and icacls . /grant Everyone:F /T /C /Q (give everyone full control of it), both hidden;
  7. imports an RSA key, decrypts t.wnry, loads the result in memory as a DLL and calls its export TaskStart.

The victim ID

Victim ID The characters of the computer name are multiplied together to make the seed for srand. Then 8–15 lowercase letters and 3–10 digits.

Because the seed comes from the computer name, the ID looks random but is the same every time on the same machine.

Registry

Registry key HKLM\Software\WanaCrypt0r (or HKCU if that fails), value wd = the working folder. With a different parameter, the same function reads it back and moves into that folder.

The archive

Extracting the archive FindResourceA(hModule, 0x80A, "XIA"), so type XIA, ID 2058. The archive is opened in memory with the password passed by WinMain, and every entry is written out. c.wnry is skipped if it already exists.

The password is right there in WinMain: WNcry@2ol7. It’s written to look like “2017”, but it’s “2”, lowercase “o”, lowercase “l”, “7”.

The archive is a ZIP 50 4B 03 04 (PK), flag 0x0001 (encrypted), method 8 (deflate). The first file is b.wnry.

$ dd if=tasksche.bin of=xia_2058.zip bs=1 skip=$((0x100f0)) count=$((0x349635))
$ 7z x -pWNcry@2ol7 xia_2058.zip
ERROR: Data Error in encrypted file. Wrong password? : s.wnry

The password is correct. The error is the damage catching up with us. The end of the archive, including the index that ZIP files keep at the very end, is gone. This is what could be recovered:

File Size State What it is
b.wnry 1,440,054 intact the desktop wallpaper
c.wnry 780 intact configuration: Tor C2 addresses, Tor download URL
r.wnry 864 intact FAQ text for the victim
msg/m_*.wnry 28 files intact the ransom window text in 28 languages (RTF)
s.wnry 1,501,522 cut short a ZIP with the Tor client
t.wnry — missing the encrypted module that encrypts files
u.wnry — missing @WanaDecryptor@.exe, the ransom window
taskdl.exe, taskse.exe — missing helper programs

c.wnry — the C2

c.wnry Five Tor hidden services at offset 0xE4, the Tor download URL at 0x1DE, and an empty slot at 0xB2.

The five .onion addresses are how the ransom window talks to the attackers: to check payments and to send messages. They are only reachable through Tor, so they can’t be blocked or taken over through DNS like the kill switch domain. The URL points to the official Tor Project site; it’s there in case the bundled Tor client is missing. It’s a legitimate site being used, not a malicious one.

The empty slot at 0xB2 is where the Bitcoin address goes. It’s empty in the archive because it’s filled in on the victim’s machine:

The three Bitcoin addresses Three hard-coded addresses. One is picked with rand() % 3, copied into the 780-byte configuration at offset 178 (0xB2), and the file is written back.

The other files

b.wnry is a plain 800×600 bitmap. Converted to PNG:

b.wnry The wallpaper. It’s the fallback: if the antivirus removes the ransom window, the instructions are still on the desktop.

r.wnry is a short FAQ, with %s placeholders for the amount, the Bitcoin address and the name of the decryptor:

r.wnry

The msg files are the text of the ransom window. The English one, converted from RTF:

m_english.wnry 3 days before the price doubles, 7 days before the files are “lost forever”, Bitcoin only, a “Check Payment” button with a suggested time of 9–11 am GMT Monday to Friday, and a request to disable the antivirus.

There’s no amount in any of these files; it was filled in at runtime by the ransom window, which is one of the missing files.

s.wnry is the Tor client, or what’s left of it:

s.wnry The folders and the support DLLs are there; tor.exe itself is past the point where the archive is cut. The folder date is 9 May 2017.

How the Encryption Works

This is the part that’s easiest to misunderstand, so I’ll split it into what I could see in this sample and what comes from public reporting on the missing module.

What’s in tasksche.exe

Opening the crypto provider “Microsoft Enhanced RSA and AES Cryptographic Provider”, type 0x18 (PROV_RSA_AES), temporary context.

Importing the embedded key CryptImportKey on 0x494 (1,172) bytes at 0x40EBF8.

The bytes at that address are a Windows key blob:

07 02 00 00   PRIVATEKEYBLOB, version 2
00 A4 00 00   CALG_RSA_KEYX
52 53 41 32   "RSA2" — a private key
00 08 00 00   2048 bits
01 00 01 00   public exponent 65537
...           modulus, primes and the rest

A complete 2048-bit RSA private key, in plain sight. What it’s used for:

Reading t.wnry t.wnry must start with WANACRY!. Next comes a length (0x100), then 256 bytes that are decrypted with the embedded RSA key and give an AES-128 key. A size check follows (less than 100 MB), and the rest is decrypted with AES.

WANACRY! is a magic value, eight bytes that mark the format, like MZ for executables or PK for ZIP files. The decrypted result is a DLL that gets loaded straight from memory, without ever being written to disk, and its TaskStart export is called.

So that private key doesn’t protect anything from the victim. It works like a padlock with the key hanging next to it. Its only job is to make sure the module that does the encryption sits on disk in encrypted form, where an antivirus scanning files won’t recognise it.

What TaskStart does (public reporting)

t.wnry is one of the files lost to the damage, so this part comes from published analyses of intact samples, not from this one.

There are three layers of keys, and the simplest way I found to think about them is padlocks. With RSA, the public key works like an open padlock: anyone can close it, but only the owner of the matching private key can open it again.

  1. The DLL contains the attacker’s public key. The matching private key never leaves the attacker.
  2. On the victim’s machine, a new RSA key pair is generated for that victim. The victim’s public key is saved as 00000000.pky. The victim’s private key is locked with the attacker’s public key and saved as 00000000.eky. The unlocked copy only exists in memory.
  3. For every file, a random AES-128 key is generated, the file is encrypted with it, the AES key is locked with the victim’s public key and stored in the file’s header, and the result is saved as <name>.WNCRY. The header starts with the same WANACRY! magic.
  4. A handful of files are encrypted with a separate “demo” key whose private half is included, so the ransom window can decrypt them for free as proof.

To get the files back, the ransom window sends the .eky file to the attackers through Tor. They open it with their private key and send back the victim’s private key, which opens the AES keys, which open the files. The attacker’s key never touches a single document: it only ever opens one small file, and that’s enough because that file holds the key to everything else.

This is why paying is the only way out when the scheme is used correctly. There are only two well-known exceptions. On some Windows versions, the victim’s private key could still be found in memory if the machine hadn’t been rebooted (that’s what the WanaKiwi tool did). And the way original files were deleted sometimes left them recoverable with forensic tools.

The ransom window (u.wnry, @WanaDecryptor@.exe) is also missing here. From public reporting, it shows the timers and the Bitcoin address, runs Tor to reach the .onion addresses, does the demo decryption, and is restarted with high privileges to delete shadow copies and disable Windows recovery (vssadmin, wmic shadowcopy, bcdedit, wbadmin). None of those commands are in the files I could recover.

Following the Money

Bitcoin transactions are public, so the three addresses can be looked up on any blockchain explorer. I checked them on 28 November 2026:

13AM4VW2…

12t9YDPg…

115p7UMM…

Address Received Balance today Moved out
13AM4VW2dhxYgXeQepoHkHSQuy6NgaEb94 20.0745 BTC 0.3294 BTC 19.7451 BTC
12t9YDPgwueZ9NyMgw519p7AA8isjr6SMw 19.6936 BTC 1.9224 BTC 17.7712 BTC
115p7UMMngoj1pMvkpHijcRdfJNXj6LrLn 14.8777 BTC 0.4670 BTC 14.4107 BTC
Total 54.65 BTC 2.72 BTC 51.93 BTC

The balance history of all three has the same shape: a quick climb to between 14 and 20 BTC, then a sudden drop to zero at the same moment on all three addresses. That matches the known cash-out of early August 2017. What’s left today comes from small payments made afterwards, which were never spent.

So what the attackers actually took is the money that left the addresses: received minus what’s still there, about 51.9 BTC. With Bitcoin at around $2,700 in August 2017, that was roughly $140,000. The explorer shows much bigger dollar figures, but those use today’s price, and according to public reporting the coins were converted to Monero back then. For a campaign that hit more than 200,000 computers and caused damage estimated in the hundreds of millions, it’s a remarkably small amount: as a way of making money, WannaCry failed.

All victims shared the same three addresses, so there was no way to tell from the blockchain who had paid. Together with the “check payment between 9 and 11 GMT” line in the ransom text, that suggests payments were matched by hand, if at all.

Architecture Overview

launcher.dll (x64, this sample)         ← delivered by DoublePulsar, PlayGame() called
 └─ resource W/101: [size][mssecsvc.exe] → C:\WINDOWS\mssecsvc.exe, started hidden
     └─ mssecsvc.exe (x86)
          ├─ kill switch request ── result ignored (JNZ patched to NOP NOP)
          ├─ no args → install
          │    ├─ service "mssecsvc2.0"  (-m security, auto start, restart on failure)
          │    └─ resource R/1831 → C:\WINDOWS\tasksche.exe /i
          └─ as a service → worm
               ├─ build packets: launcher.dll x86/x64 + [size][mssecsvc.exe]
               ├─ LAN: own subnets + /24 of gateways and DNS, 10 threads
               ├─ internet: 128 threads, random IPs, whole /24 on a hit
               └─ per host (TCP/445): MS17-010 check → EternalBlue → DoublePulsar upload
tasksche.exe (x86)
 ├─ /i → hidden folder named after the victim ID, copy + start
 ├─ HKLM|HKCU\Software\WanaCrypt0r  wd = folder
 ├─ resource XIA/2058 → ZIP, password WNcry@2ol7  (archive cut short by the damage)
 │    b.wnry wallpaper · c.wnry Tor C2 · r.wnry FAQ · msg/*.wnry · s.wnry Tor (partial)
 │    t.wnry · u.wnry · taskdl.exe · taskse.exe  → missing
 ├─ one of 3 BTC addresses → c.wnry
 ├─ attrib +h . · icacls . /grant Everyone:F /T /C /Q
 └─ t.wnry: RSA (embedded key) → AES key → DLL in memory → TaskStart()  [module missing]

IOCs

Type Value
SHA256 (sample, x64 launcher packet) e9c82c0f40b82eb9e7fffa7600628fa5dbe6a387829ec13342bb8d75f34ea661
MD5 (sample) 430845d1c3483f638d2d141f27ead1b6
SHA256 launcher.dll x64 (first 0xC8A4 bytes) 2f9d5e64acffc7513aec4f9d5adb5eafe5fa112eb83997ee05efaba9b12ece70
SHA256 launcher.dll x86 (from mssecsvc) 9411c59a83c8c32a925d53a902bef168ebe5b403a88ab4d8dfe807fd7435dd9e
SHA256 mssecsvc.exe (carved, damaged) 3f6fcccc786b51391ed1d713d21b607a5a461c77977d453e41e03bdf255b3e75
SHA256 tasksche.exe (carved, damaged) b7f4192797fc8625c85e6fb5e8f31ed62fda4d6615b60255fc940788de8fd3b5
SHA256 b.wnry / c.wnry / r.wnry d5e0e869…f4fa / 055c7760…5622 / 402751fa…2a7c
Family WannaCry (WanaCrypt0r 2.0), kill switch patched out
Kill switch (ignored) hxxp://www[.]iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea[.]com
Tor C2 gx7ekbenv2riucmf[.]onion, 57g7spgrzlojinas[.]onion, xxlvbrloxvriy2c5[.]onion, 76jdd2ir2embyv47[.]onion, cwwnhwhlz52maqm7[.]onion
Tor download (legitimate site) hxxps://dist.torproject[.]org/torbrowser/6.5.1/tor-win32-0.2.9.10.zip
Bitcoin 13AM4VW2dhxYgXeQepoHkHSQuy6NgaEb94, 12t9YDPgwueZ9NyMgw519p7AA8isjr6SMw, 115p7UMMngoj1pMvkpHijcRdfJNXj6LrLn
Service mssecsvc2.0 — “Microsoft Security Center (2.0) Service”, <path> -m security
Files C:\WINDOWS\mssecsvc.exe, C:\WINDOWS\tasksche.exe, C:\WINDOWS\qeriuwjhrf
Registry HKLM\Software\WanaCrypt0r (or HKCU), value wd
Mutex Global\MsWinZonesCacheCounterMutexA
Archive password WNcry@2ol7
Resources W/101 (launcher), R/1831 (mssecsvc), XIA/2058 (tasksche)
Commands attrib +h ., icacls . /grant Everyone:F /T /C /Q, tasksche.exe /i
Magic WANACRY! at the start of t.wnry and encrypted files
Embedded RSA key PRIVATEKEYBLOB, RSA2, 2048 bit, at 0x40EBF8 in tasksche.exe
Network TCP/445 scanning; SMB Trans2 SESSION_SETUP ping, Multiplex ID 0x51; status 0xC0000205 check
Names from public reporting (not in recovered files) @WanaDecryptor@.exe (shown in the wallpaper), @Please_Read_Me@.txt, .WNCRY, 00000000.pky/.eky/.res

YARA

The rules are in wannacry.yar. I tested them against the sample, the carved stages and a couple of unrelated binaries:

$ yara wannacry.yar e9c82c0f...a661.exe
WannaCry_Launcher_DLL
WannaCry_Worm_mssecsvc
WannaCry_Killswitch_Patched
WannaCry_Installer_tasksche
$ yara wannacry.yar launcher_x64.dll   → WannaCry_Launcher_DLL
$ yara wannacry.yar tasksche.bin       → WannaCry_Installer_tasksche
$ yara wannacry.yar 4633de09...exe     → (nothing)

The most specific one is the patch itself:

rule WannaCry_Killswitch_Patched
{
    meta:
        description = "mssecsvc.exe with the kill switch check removed (JNZ after InternetOpenUrlA replaced by two NOPs)"
    strings:
        $ks    = "iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea" ascii
        // mov edi,eax / push esi / mov esi,[InternetCloseHandle] / test edi,edi / nop / nop / call esi
        $patch = { 8B F8 56 8B 35 ?? ?? ?? ?? 85 FF 90 90 FF D6 }
    condition:
        uint16(0) == 0x5A4D and all of them
}

MITRE ATT&CK

Technique ID Evidence
Exploitation of Remote Services T1210 EternalBlue (MS17-010) against SMBv1
Network Service Discovery T1046 TCP/445 scan of local ranges and random internet addresses
System Network Configuration Discovery T1016 GetAdaptersInfo / GetPerAdapterInfo for subnets, gateways, DNS
Lateral Tool Transfer T1570 launcher.dll + mssecsvc.exe uploaded through DoublePulsar
Process Injection T1055 DLL loaded into a remote process by the DoublePulsar backdoor
Create or Modify System Process: Windows Service T1543.003 mssecsvc2.0; tasksche.exe registered as a service
System Services: Service Execution T1569.002 -m security service mode, cmd.exe /c service for tasksche
Modify Registry T1112 Software\WanaCrypt0r\wd
Hide Artifacts: Hidden Files and Directories T1564.001 attrib +h .
File and Directory Permissions Modification T1222.001 icacls . /grant Everyone:F /T /C /Q
Obfuscated Files or Information T1027 password-protected ZIP in a resource, RSA/AES-encrypted t.wnry
Deobfuscate/Decode Files or Information T1140 ZIP extraction, t.wnry decryption
Reflective Code Loading T1620 t.wnry DLL loaded from memory, TaskStart called
Dynamic API Resolution T1027.007 GetProcAddress for file and process functions
System Information Discovery T1082 computer name used for the victim ID
Proxy: Multi-hop Proxy T1090.003 C2 over Tor hidden services
Data Encrypted for Impact T1486 RSA + AES scheme, .WNCRY files (module missing here; public reporting)
Inhibit System Recovery T1490 vssadmin / wmic / bcdedit / wbadmin (missing here; public reporting)
Defacement: Internal Defacement T1491.001 ransom wallpaper b.wnry

Conclusion

The file I started from was neither the ransomware nor the famous dropper. It was the packet that one infected machine sends to the next: a small 64-bit launcher.dll with a full copy of the worm attached, exactly as the worm builds it in its own code. Following it inward gave the whole chain: the worm with its service, its two scanners and its EternalBlue/DoublePulsar attack, then the installer with its encrypted archive, its Tor configuration and its three Bitcoin addresses.

Two things make this copy different from the textbook one. The kill switch has been switched off by replacing a two-byte jump with two NOPs, so the domain that stopped the 2017 outbreak would not stop this one. And the file was recovered from a damaged disk or memory image: half of the worm’s embedded data is overwritten with paths from the victim’s own Windows installation, which cost the archive its last files, including the module that actually encrypts data.

The code itself is notably plain. There’s no packing and almost no obfuscation, and the only “protection” on the encryption module uses a private key stored next to it. That’s consistent with what was said about WannaCry at the time: it was put together quickly on top of leaked exploits. It also made the kill switch patch trivial. The parts that were done properly are the ones that matter for the victims: the key hierarchy that makes paying the only way back, and a propagation engine that reaches beyond the local subnet.

Limitations

I didn’t run anything, so the network behaviour is reconstructed from the code and from the pre-built packets, not observed. I identified the EternalBlue routine and the DoublePulsar key calculation but didn’t reverse the exploit or the kernel shellcode in detail. The module that encrypts files (t.wnry), the ransom window (u.wnry) and the helpers taskdl.exe / taskse.exe are not recoverable from this sample, so everything about file encryption, file extensions, ransom notes and shadow copy deletion comes from public reporting and is marked as such. The hashes of the carved stages don’t match the public ones because of the damaged region, so they’re only useful for this specific sample. I read the installer’s hidden-folder and service routines only far enough to confirm what they do.


Tools used: Ghidra, radare2, binwalk, 7-Zip, xxd, dd, YARA, ImageMagick, a public blockchain explorer