decipher

Ransomware decryption PoC

Proof of concept that recovers files encrypted by ransomware from a memory dump.

decipher
Fields
Systems, network & security
Interests
Infrastructure & security
Language
C
Year
2024 · last push 2024-12-02
GitHub
0 (2026-11-07)

README

Straight from the project’s GitHub repository. (2026-11-07) · GitHub

Deciphering Ransomware - Analysis and working PoC

ToC

Introduction

  • To see the analytical research part of the project check the report folder:
    • Analysis (analysis.md)
    • Markdown Slides in English and Slovak (slides_en.md, slides_sk.md)
  • To get the idea of how the code in src functions (used to capture key from memory and decipher files) see these sections below:
    • Included Modules (modules)
    • RSA Functions (src/_rsa)
    • Main Functions (src/main)
    • Main Procedure (How we obtain the private key)

Note: Biggest hurdle is that this only works up to Windows 7 (Windows Server 2008) and therefore DOESN'T include today's most popular Windows 10 and Windows 11 compatibility. Currently only WannaCry is supported.

Dependencies

In order for the code to work you will need to get the OpenSSL toolkit libraries installed. A copy of openssl alongside a working Visual Studio solution is provided in the wanakiwi repository (https://github.com/gentilkiwi/wanakiwi/), I purposefully left them out (plan to add a downloader or detect existing OpenSSL install). Other modules are included.

Included Modules (module_*)

All of these are included in the modules and used:

  • File: Exists, Write, Read, Find
  • Memory: Open, Copy, ReverseBytes
  • MiniDump: Open, Close, RVAtoPTR, Stream, Copy
  • String: ArgsByName
  • Process: ProcInfo, PIDforName, MemInfo, NTQuerySysInfo
  • Output: Echo

RSA Functions (_rsa)

  • QuickImport
  • ToPrivateKeyBlob
  • PubKeyBlobToRSA
  • PubKeyFileToNewPubKeyEN
  • SimpleModuleCryptoHKEY
  • InitDefaultKey
  • FreeDefaultKey
  • DecryptFileWithKey
  • NormalizedEntropy

Main Functions

  • wmain
  • findProcess
  • memoryAnalysis
  • fileCallbackPublicKey
  • fileCallbackWannaCry
  • echoBigNum
  • checkValidArchitecture
  • regDeletePendingFileRenameOps

Main Procedure

Entire procedure is in the wmain function; see the following comments in main.c:

  1. Handle args e.g. private/public key on input
  2. Start working from public key if we didn't get private key on input
  3. Process memory or minidump
  4. Entropy
  5. Try to get private key from memory
  6. Start working with private key

License

See LICENSE file. This project began as a rewrite of memory dump and private key recovery procedures from wanakiwi for a more generic approach, which is intended to include future ransomware behavior.

Related work

2025 4fork

APFS FUSE for FreeBSD

Prompt-driven port of a file system driver

Prompt engineering & AISystems, network & securityC++

2026 2

presshaven.io

Honeypot digital twin

Systems, network & securitySoftware & webLua

2024 2

shortcut

"Add to Home Screen" for macOS

Software & webSystems, network & securityShell

All projects

Loading…

Open original