19

Where does ransomware such as the recent wannacry variant store the key it uses to encrypt the files on the victim's disk?

Is this hard coded in the program itself? Or does it call into a server to obtain a key? If either of these are the case, the application could be reverse engineered or traffic sniffed to obtain the key and decrypt the files, so why is this not the case? Or does the virus generate a key per infection?

  • 3
    A key per file, wich is then cyphered by a hardcoded public key within the ransomware for the wannacry version (you need to pay so someone with the private key decypher the keys and then the files). Each malware has its own method as far as I know. – Tensibai May 15 '17 at 16:49
  • 1
    There is of course no assurance that the data is encrypted at all. They may have simply overwritten it with random bits. – Hot Licks May 16 '17 at 11:41
32

All ransomware implementations are different, but for the most part, the particularly stupid variants that did things like use a hard-coded key, or used easily guessable or reproducible key generation methods have been weeded out and replaced by much stronger variants.

For wannacry specifically, each infection creates a new RSA keypair on the machine being infected. The private key from this pair is then encrypted with a public key shipped in the malware, which is part of a keypair owned by the wannacry author.

The new, infection specific public key is then used to encrypt the AES keys, which are generated using a CSPRNG, and a new AES key is generated for each file encrypted.

Presumably once you pay the ransom, the malware authors will then use their private key (the other half of the keypair to the public key hard-coded into the malware) to decrypt your private key, which the decryptor tool can then use to decrypt the AES keys, and in turn the files.

  • 2
    I'd say "nominally" rather than "presumably" since I wouldn't presume the bad guys will act in good faith and decrypt your files, but that is what is claimed. – JesseM May 15 '17 at 21:07
  • 17
    @JesseM They are running a business, so they want their customers to be satisfied - otherwise no one else will pay the ransom. That said, I believe some variants didn't actually have any decryption methods and others were supposed to but the methods were bugged and didn't work. – IllusiveBrian May 15 '17 at 21:25
  • 32
    "Satisfied" ransomware customer LOL – Zubin May 15 '17 at 22:57
  • 4
    @IllusiveBrian completely agree if the folks behind it care about "satisfied customers." As you said, "some variants didn't actually have any decryption methods" and are just scammers trying to profit off the reputation of the "satisfied customer" type of malware. That's why I quibbled with "presumably" in this case. I have yet to hear of anyone reporting decryption after paying. – JesseM May 16 '17 at 0:20
  • 1
    I assume few report it as they are not too proud of the mishap, and prefer no longer to think of it. That was the deal for paying, actually! – Volker Siegel May 16 '17 at 0:54

protected by Community Jul 19 '18 at 17:21

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.