Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Securely erasing a file using simple methods? [duplicate]

Possible Duplicate:
C# - Deleting a file permanently

Hello,

I am using C# .NET Framework 2.0. I have a question relating to file shredding.

My target operating systems are Windows 7, Windows Vista, and Windows XP. Possibly Windows Server 2003 or 2008 but I'm guessing they should be the same as the first three.

My goal is to securely erase a file.

I don't believe using File.Delete is secure at all. I read somewhere that the operating system simply marks the raw hard-disk data for deletion when you delete a file - the data is not erased at all. That's why there exists so many working methods to recover supposedly "deleted" files. I also read, that's why it's much more useful to overwrite the file, because then the data on disk actually has to be changed. Is this true? Is this generally what's needed?

If so, I believe I can simply write the file full of 1's and 0's a few times.

I've read: http://www.codeproject.com/KB/files/NShred.aspx http://blogs.computerworld.com/node/5756 http://blogs.computerworld.com/node/5687 Securely deleting a file in C#.NET

like image 325
Jason Avatar asked Dec 30 '10 06:12

Jason


2 Answers

I'm afraid that you are facing a complex issue. I would suggest not to try to solve it by your own.

Note that beside ensuring a physical overwrite of the file (which may be over LAN, flash, or whatever), you'll have to take care of any application caches, windows hibernate files, windows recovery files, windows swap file, and all copies or older erased versions of this files (swap all empty space, or worse, space that contained cache before, and may have been allocated to other files since) - all in the correct order.

I think that your chances can be better if you are able to store your files on a dedicated logical (or even physical) drive, which is not used by the OS or by other applications, and if you'll convince Windows not to swap the memory you are using to hold the file, while in RAM (using VirtualLock()). Still, you should erase swap, cache, etc.

On top of that, you should integrate a product like Eraser into your application (Eraser is Free software and its source code is released under GNU General Public License).

like image 167
Lior Kogan Avatar answered Nov 07 '22 11:11

Lior Kogan


From what I've read , the solution to actually making the data no longer visible seems to be overwriting the file with 0's and 1's.

like image 42
contactmatt Avatar answered Nov 07 '22 13:11

contactmatt