0

Let's say I create a 100KB file only containing 1234567890, that is, a known value. This file would be sitting on several folders as bait.

Once a Rasomware hits the folder and encrypts this file (considering all other forms of anti-rasomware protection failed), could I generate which is the private key that would decrypt that file, and all other files, by knowing the previous file contents?

Does also having the Public Key captured in memory help?

Does having a large known file help? Most examples I found online speak about how this wouldn't work for JPEG and PDF headers, but usually those are very small.

I know this goes against the asymmetrical key theory, but usually there's a difference between cryptography theory and practice, like hashes should be unique for every entry, but in practice there's always the possibility of collisions.

2 Answers 2

4

This is known as a 'known plaintext' attack. All modern encryption algorithms are designed to be resistant to this type of attack.

Many types of files contain known plaintext. For example, PDF documents begin with the header '%PDF'. Other information in most PDF documents is easy to guess, such as embedded fonts, formatting info, etc. If known plaintext attacks were possible, then it would be possible to derive the key used to encrypt any PDF document, in the manner that you describe, based on this known content. The same would apply to many other types of files as well.


Appended 5/10/2020 based on the comments below following this answer and other answers to this question:

Very rarely is asymmetric encryption actually used to encrypt large files. Instead, most asymmetric encryption implementations use hybrid encryption, where a symmetric key is generated, then this key is used to encrypt the files using symmetric encryption (e.g. AES), then the symmetric key is encrypted using asymmetric encryption with the public key, and stored along with the ciphertext. See https://crypto.stackexchange.com/questions/32692/what-is-the-typical-block-size-in-rsa.

So, even when asymmetric encryption (e.g. RSA) is used, the underlying encryption is most likely done using symmetric encryption (e.g. AES). Most modern AES implementations are highly resistant to known plaintext attacks - even if the entire file consists of known plaintext. For example, AES-CBC uses a random initial vector which is XOR'd with the first block of plaintext. This has the effect of completely randomizing the plaintext before it is encrypted. Then, this process is repeated for all subsequent blocks.

So, a known plaintext attack is highly unlikely if hybrid encryption is used - but you make a good point that the underlying (symmetric) key that is used to encrypt the files is in memory for the entire time that the encryption is taking place.

4
  • Yes, that's why I thought about a long known file, most examples I found were based on tiny headers for PDF and JPEG, so I wondered how much does this change for a long file.
    – mFeinstein
    Commented May 9, 2020 at 23:52
  • Any modern encryption algorithm worth its salt will be highly resistant to known plaintext attacks - even for long files, containing lots of known plaintext. JSON files come to mind. JSON files are commonly served by many APIs over HTTPS, and often contain sensitive information, in a key/value structure. The values are sensitive, but the keys are known.
    – mti2935
    Commented May 10, 2020 at 0:46
  • The keys are known, but the values will be like a salt in a hash, changing completely the output of an algorithm.
    – mFeinstein
    Commented May 10, 2020 at 0:49
  • Even if the file consists entirely of known plaintext, a known-plaintext is unlikely. See my addendum to my answer above.
    – mti2935
    Commented May 10, 2020 at 13:24
1

1) It is strange that you expect that ransomware would use asymmetric encryption. It is much slower compared to symmetric encryption with the same strength.

2) Modern encryption algorithms (both symmetric and asymmetric) use random data. Means, even the same data encrypted by the same algorithm can produce different results.

3) Brute-forcing based on known plain text can be successful, but only if the encryption algorithm is weak, e.g. it has short key like 40 - 50 bits. To answer your question we need to know how long the key is.

6
  • 1 - Many Ransomwares stopped using symmetrical keys as they would be in memory for a long time and people could extract it, so by going asymmetrical you have no choice but to pay as the key is never in your system (just on the moment of creation).
    – mFeinstein
    Commented May 10, 2020 at 2:38
  • 2 - Even if they use random data for initialization, the large part of it would have some sort of relation with the contents of the file, so I wonder how much does this weaken out the algorithm. How much does it remove in terms of entropy.
    – mFeinstein
    Commented May 10, 2020 at 2:40
  • 3 - I am not considering brute force, I am just wondering if we can guess a private key if we know the full content of a file.
    – mFeinstein
    Commented May 10, 2020 at 2:41
  • 1
    2 - the algorithms are designed in such way that namely such relation is nearly impossible to deduce. Even if you have a long file consisting only of zeroes, the encryption result will be impossible to distinguish from a random sequence of bytes.
    – mentallurg
    Commented May 10, 2020 at 2:45
  • 3 - then it is not clear what you mean by guess. There is no analytical way to restore the key, no algorithm that produces the key in a given number of predefined steps. If you need a deep mathematical explanation for this for RSA or ECC you can ask it at Cryptography SE.
    – mentallurg
    Commented May 10, 2020 at 2:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .