0

I'm actually not sure if it is even possible to do such a thing as forcing other applications to read a file from Java process that returns the needed bytes instead of reading file from disk, So first of all this information can be helpful.

also you can ignore the forcing idea! Can I open others app from my java application, for example Adobe Acrobat Reader and inject bytes into it instead of opening it individually and read a pdf file with it ?

if Its possible, Can someone explain how? I've search too much in internet and I found no answer.

Also you might want to know that, my idea is to decrypt an encrypted file in memory and let some other application use decrypted bytes from my own app, instead of reading decrypted file from disk (which can be recovered!)

Sepehr GH
  • 1,297
  • 1
  • 17
  • 39
  • You can execute another program within your program and give that your required argument or input. But I'm not sure I've understood you by "forcing"? – Ali Seyedi Apr 17 '16 at 12:24
  • @AliSeyedi I edited my question. This is helpful, How can I do it ? – Sepehr GH Apr 17 '16 at 12:26

2 Answers2

1

An interesting concept, but I'm afraid the answer would be no. This would open a whole can of worms, the stream you're providing the other application would not actually be a file on disk and that's what would be assumed by the other application. Even if you somehow could pass the raw data as something the other application could read (though normally you would only be able to pass the path to a file and the application would open it themselves), what would happen if that application tried to write to it? It would have to modify the memory of your Java application. I'm sure you can see the implications of that.

One way to potentially do this is to create an encrypted volume that is mounted by the operating system (such as what TrueCrypt does) and put your data on there as a file so the other application can just handle your stream as a real file. In this way you would make the other application completely oblivious of the fact you're just presenting it a stream. Your application would be notified to any changes on the mounted volume or the file specifically and could act upon that. This all would be far from trivial though.

Sebastiaan van den Broek
  • 5,818
  • 7
  • 40
  • 73
  • Well, you are right, I think even good antiviruses should stop my app. and for sure I was thinking not to give them writing permissions. but the problem is still there. Well, I've implemented my own Encrypting java app, can creating encrypted volume help me still? Can I do it using java? (a little search is showing me it might be possible) – Sepehr GH Apr 17 '16 at 12:33
  • I'm sure it's possible with Java, but it would not be easy. The TrueCrypt source code is opensource, you could have a look at that if you're willing to give it a shot. Btw if this was helpful, please upvote or accept my answer :) – Sebastiaan van den Broek Apr 17 '16 at 12:35
  • I've already upvoted this answer. Whats your idea about Virtual files? – Sepehr GH Apr 17 '16 at 12:48
  • I never heard of virtual files on their own (that doesn't mean it doesn't exist, I'm no expert on the matter) but a Virtual File System is exactly what applications like TrueCrypt use. – Sebastiaan van den Broek Apr 17 '16 at 12:50
0

It seems to me that letting your decrypted data rest on the hard disk and then shredding that data using jDelete, or Turbo Shredder can do what you want without Anti Virus problems.

Ali Seyedi
  • 1,758
  • 1
  • 19
  • 24
  • Well, I read a lot about that! Its too risky to put any data on disk unencrypted and rely on a Shredder or disk cleaner apps to completely remove it. It might still be possible to recover it. Better solutions is to open it from ram or encrypted volume or file system! Any how, I could not find a file shredder source for Java, but that idea helps, I might write my own, which is still risky ! – Sepehr GH Apr 17 '16 at 17:09
  • @SepehrGH I know very little about your requirements, how much serious are riskes or why you need it to be general purpose. But take a look at this answer which explains why shredding is not that hard or risky and you can implement it yourself or rely on available tools. http://stackoverflow.com/a/1046697/2123877 – Ali Seyedi Apr 17 '16 at 18:06
  • And Turbo Shredders src files are accessible from [here](https://sourceforge.net/projects/turboshredder/files/src/). – Ali Seyedi Apr 17 '16 at 18:10
  • hmmm, That can help. Thanks – Sepehr GH Apr 18 '16 at 15:52