0

I have a question about how ransomware works.

According to the authors of this paper: https://www.cise.ufl.edu/~traynor/papers/scaife-icdcs16.pdf (page 2 - 3) , class C is: ransomware reads the original file, then creates a new, independent file containing the encrypted contents and deletes or overwrites (via a move) the original file. This class uses two independent access streams to read and write the data.

Could someone explain this a bit more? Because what I'm wondering is: ransomware opens the original file, then creates a new independent file (okay, so far so good), then copies the unencrypted content from the original file into the new file(?), encrypts it (so it encrypts the content of the new file) and overwrites or deletes the original file?

Or does it encrypt the content of the original file, copy the encrypted content to the new file and then delete the original file?

It seems to be quite similar to scenario 3 of this file (page 6): https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_kharraz.pdf

and one more general question: Is it possible to encrypt a file without opening it? So without creating an IRP_Read or IRP_Create?

Thank you very much.

2
  • 2
    In short: details vary between various ransomware. Commented Jan 4, 2023 at 18:34
  • Please note that both papers were written in 2016. Ransomware has evolved and advanced quite significantly since then resulting in numerous ways to encrypt files.
    – schroeder
    Commented Jan 4, 2023 at 19:16

1 Answer 1

0

The first paper says:

deletes or overwrites (via a move) the original file

"deletes" - this is clear, scenario 2 in the second paper.

"overwrites (via a move)" - this is not described in the second paper.

"overwrites (via a move)" depends on the file system:

  • If both files are in the same storage volume, then many file systems just assign pointer to the contents of the new file. This scenario in not described in the second paper.
  • If files are on different storage volumes, then such optimization is impossible. Usually the source file is being read from one volume, written to a temporary file on the target volume. This is not described in the second paper. Then the temporary file is on the same volume as the target file, and the pointer is changed from the old to the new one, like in the first case. This is not described in the second paper.

Is it possible to encrypt a file without opening it?

No. Encryption is a process of data transformation: You read data and apply some transformations according to the chosen algorithm. If you don't read data, there is nothing to transform.

6
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – schroeder
    Commented Jan 5, 2023 at 9:07
  • @mentallurg, I can't post anything in the chat anymore. But one more question (I can't really find sources on the internet on this particular question, or probably I'm not searching well/not using the right search terms). But if you intercepted e.g. an IRP_MJ_READ packet, how can you read the actual content of the file? Or if you have e.g. an IRP_MJ_WRITE and in the pre-operation process you intercept the IRP_MJ_WRITE packet, can you somehow, by examining the packet, see what the written content is? For example, with procmon? Thank you for your help. Commented Jan 20, 2023 at 21:03
  • I think I can look at the buffer cache Commented Jan 20, 2023 at 22:07
  • @mentallurg Is it correct if I state that the metadata is stored in the buffer (memory) and the content in the cache (memory), also on disk of course, but the CPU is not directly interacting with disk Commented Jan 20, 2023 at 22:28
  • @PieterJansen: 1) Security SE is a site about information security, not about programming. I'd suggest you to ask programming questions at SO.
    – mentallurg
    Commented Jan 21, 2023 at 8:14

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