The ransomware WannaCry has infected hundreds of thousands of computer systems around the globe, but a security researcher claims he's figured out how to beat it.

In some cases, that is.

Adrien Guinet says that he was able to decrypt a ransomwared computer running Windows XP in his lab by discovering the prime numbers that make up the WannaCry private key. The private key is what a ransomware victim would need to buy off his attackers in order to regain access to his own files, but Guinet says he was able to do this without paying any Bitcoin ransom.

Importantly, Guinet acknowledges this technique has only been demonstrated to work on a computer running Windows XP. Why does that matter? Despite initial reports, those systems were not affected by the major May 12 outbreak as the worm that spread the ransomware didn't hit those systems.

However, WannaCry itself does work on XP — suggesting that if the ransomware manages to spread to XP this new technique could be used to help future victims.

I got to finish the full decryption process, but I confirm that, in this case, the private key can recovered on an XP system #wannacry!! pic.twitter.com/QiB3Q1NYpS — Adrien Guinet (@adriengnt) May 18, 2017

There are some other provisos as well.

"In order to work, your computer must not have been rebooted after being infected," Guinet wrote on Github. "Please also note that you need some luck for this to work," he added, "and so it might not work in every cases!"

Why luck? As Guinet explains, when WannaCry infects a computer it generates encryption keys that rely on prime numbers. Here comes the important part: The ransomware "does not erase the prime numbers from memory before freeing the associated memory."

"If you are lucky (that is the associated memory hasn't been reallocated and erased)," continues Guinet, "these prime numbers might still be in memory."

If you can recover those prime numbers, as Guinet says he did, you can decrypt your files.

Guinet released the software he used to decrypt the infected system to the public. He calls it "Wannakey."

As mentioned above, Wannakey has not been tested on a large scale and so it may not be a silver bullet. It does, however, suggest that data considered lost in future ransomware attacks may actually be recoverable. And that is some much needed good news.