Live data from Hacker News

WannaCry in-memory key recovery for Windows XP

github.com

31–40 of 95 posts

Re: WannaCry in-memory key recovery for Windows XP

#31
post #22

It's hilarious that it uses public-key crypto, yet lets the client know the private key. What's even the point, then?

Exactly. I would've thought the malware would ask a C&C server to generate a key pair and then only send the public key to the malware. But I guess perhaps that required too much processing power for the server. But then again this can also distributed: let a random victim generate an RSA keypair for another victim.

If those network requests could be identified, the whole thing would be shut down by network operators.

Re: WannaCry in-memory key recovery for Windows XP

#32
post #17

It's hilarious that it uses public-key crypto, yet lets the client know the private key. What's even the point, then?

I mean a technical user capable of this solution is not very likely to get hit by this in the first place. The hacker probably doesn't care if x% of people defeat the encryption.. as long as x% pay the ransom.

Given the infrastructure and health victims that have been hit, I certainly hope that some serious people are looking into this. Given the relatively small sums of money we've seen flowing into the bitcoin addresses, if I were the perpetrator, I would not think I'd got a particularly good deal - exchanging 40k or so for interest from a number of heavy hitting actors just doesn't seem worth it.

Re: WannaCry in-memory key recovery for Windows XP

#33

It's hilarious that it uses public-key crypto, yet lets the client know the private key. What's even the point, then?

I don't know the exact details of how WannaCry encrypts the files, but ransomware generally works like this: when hitting a new machine, it generates a random key K1 and then encrypts all the user's files with AES (or some other symmetric key encryption) using K1 as the key. It then encrypts K1 itself using some public key Kpub embedded in the ransomware, then stores the encrypted K1 on disk. When the user pays the r…

There are 4+N keys involved.

  - The attacker's RSA private key (UNKNOWN)
  - The attacker's RSA public key (KNOWN)
  - The local device's RSA private key (KNOWN, but then poorly wiped)
    - This is encrypted with the attacker's RSA public key
  - The local device's RSA public key (KNOWN)
  - A separate AES key for each file
    - These are encrypted with the local device's RSA public key
How decryption should work: Get the local device's RSA private key from the attacker (EDIT: this is not the attacker's RSA private key, it's the local one), then you can decrypt the AES key for each file.

Re: WannaCry in-memory key recovery for Windows XP

#34
I'm probably going to show my ignorance of RNGs here, but if we know the machine, the algorithm used, and the time the key was generated, doesnt that limit the number of possible choices? Could we check when the file was encrypted and brute force the possible keys?

Re: WannaCry in-memory key recovery for Windows XP

#35

It's hilarious that it uses public-key crypto, yet lets the client know the private key. What's even the point, then?

I don't know the exact details of how WannaCry encrypts the files, but ransomware generally works like this: when hitting a new machine, it generates a random key K1 and then encrypts all the user's files with AES (or some other symmetric key encryption) using K1 as the key. It then encrypts K1 itself using some public key Kpub embedded in the ransomware, then stores the encrypted K1 on disk. When the user pays the r…

This doesn't appear to be how WannaCry works: as ridiculous as it sounds, it looks like WannaCry actually generates a private key on the infected machine. If you look in search_primes.cpp (from line 251) in the linked repo, you'll see that the tool is literally searching the memory for prime numbers that divide the public modulus.

EDIT: CiPHPerCoder appears to have figured how the key management works.

Re: WannaCry in-memory key recovery for Windows XP

#36

Earlier quoted context omitted.

I don't know the exact details of how WannaCry encrypts the files, but ransomware generally works like this: when hitting a new machine, it generates a random key K1 and then encrypts all the user's files with AES (or some other symmetric key encryption) using K1 as the key. It then encrypts K1 itself using some public key Kpub embedded in the ransomware, then stores the encrypted K1 on disk. When the user pays the r…

There are 4+N keys involved. - The attacker's RSA private key (UNKNOWN) - The attacker's RSA public key (KNOWN) - The local device's RSA private key (KNOWN, but then poorly wiped) - This is encrypted with the attacker's RSA public key - The local device's RSA public key (KNOWN) - A separate AES key for each file - These are encrypted with the local device's RSA public key How decryption should work: Get the local dev…

If someone were to pay up and receive the attacker's private key, what's to stop them from distributing it to others?

Re: WannaCry in-memory key recovery for Windows XP

#37
post #8

Earlier quoted context omitted.

Heh. Since this only works before a reboot and Windows 10, by design, destructively reboots with no recourse, I could imagine this ironic farce: a) security holes lead to a ransom, b) security holes let you reverse the ransom, but c) forced reboots kill any hope you have of recovering with this kind of hack.

But Windows 10 was for the same reason largely not affected: it was patched and rebooted.

And Windows XP was not targeted at all by WannaCry.

Re: WannaCry in-memory key recovery for Windows XP

#38
post #36

Earlier quoted context omitted.

There are 4+N keys involved. - The attacker's RSA private key (UNKNOWN) - The attacker's RSA public key (KNOWN) - The local device's RSA private key (KNOWN, but then poorly wiped) - This is encrypted with the attacker's RSA public key - The local device's RSA public key (KNOWN) - A separate AES key for each file - These are encrypted with the local device's RSA public key How decryption should work: Get the local dev…

If someone were to pay up and receive the attacker's private key, what's to stop them from distributing it to others?

That's exactly the trick: the attacker doesn't send you their private key, they decrypt (using their private key) the other private key that the ransomware generated on your machine, which is what was used to encrypt the per-file AES keys.

Re: WannaCry in-memory key recovery for Windows XP

#39

Earlier quoted context omitted.

But Windows 10 was for the same reason largely not affected: it was patched and rebooted.

And Windows XP was not targeted at all by WannaCry.

In that case, Microsoft wouldn't have released an emergency patch for XP, three years after end of support. But they did [0].

[0]: https://blogs.technet.microsoft.com/msrc/2017/05/12/customer...

Re: WannaCry in-memory key recovery for Windows XP

#40
post #36

Earlier quoted context omitted.

There are 4+N keys involved. - The attacker's RSA private key (UNKNOWN) - The attacker's RSA public key (KNOWN) - The local device's RSA private key (KNOWN, but then poorly wiped) - This is encrypted with the attacker's RSA public key - The local device's RSA public key (KNOWN) - A separate AES key for each file - These are encrypted with the local device's RSA public key How decryption should work: Get the local dev…

If someone were to pay up and receive the attacker's private key, what's to stop them from distributing it to others?

The attacker probably just decrypts your locally generated key. I doubt they send along the master key.
Post reply on HN