A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/aguinet/wannakey below:

aguinet/wannakey: Wannacry in-memory key recovery

This software has only been tested and known to work under Windows XP, 7 x86, 2003, Vista and Windows Server 2008 (tests by @msuiche).

Please also note that you need some luck for this to work (see below), and so it might not work in every case!

This software allows to recover the prime numbers of the RSA private key that are used by Wanacry.

It does so by searching for them in the wcry.exe process. This is the process that generates the RSA private key. The main issue is that the CryptDestroyKey and CryptReleaseContext does not erase the prime numbers from memory before freeing the associated memory.

This is not really a mistake from the ransomware authors, as they properly use the Windows Crypto API. Indeed, for what I've tested, under Windows 10, CryptReleaseContext does cleanup the memory (and so this recovery technique won't work). It can work under Windows XP because, in this version, CryptReleaseContext does not do the cleanup. Moreover, MSDN states this, for this function : "After this function is called, the released CSP handle is no longer valid. This function does not destroy key containers or key pairs.". So, it seems that there are no clean and cross-platform ways under Windows to clean this memory.

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

That's what this software tries to achieve.

You can use the binary wannakey.exe in the bin/ folder. It will locate the encryption PID by itself. If it can't, you might need to search it by hand and pass it as an argument of the wannakey.exe tool.

If you have multiple cores, you can use the wannakey_omp.exe binary. If you don't have the vcomp140.dll on your system, you can copy alongside wannakey_omp.exe the version that is present in the bin directory (extracted from the MSVC 2015 C++ runtime). Unfortunately, it doesn't seem straightforward to statically link with this library.

If the key had been succeesfully generated, you will just need to use the "Decrypt" button of the malware to decrypt your files!

Windows Crytp API leak check

A tool named "winapi_check" (see the bin/ directory) checks whether the Windows Crypto API remove the private key's primes from memory or not. This allows to verify if wannakey has a small chance or not to work.

Please note that, even if this tool says wannakey stands a chance, it doesn't mean it will work!

If you have tried this tool, please report the results here: #5.

You need at least Visual Studio 2015 express and CMake.

Launch a VS2015 Native Tools command line prompt and run:

> cd /path/to/wannakey/wannakey/
> mkdir build
> cd build
> cmake -G "Visual Studio 14 2015" -T "v140_xp" ..
> cmake --build . --config "release"

Binary will be in the src/Release directory.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3