Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Secure wipe a directory

I know how to wipe a file in C# including it's sectors and such.

But how do I overwrite the directories themselves?

Example: @"C:\mydirectory\" must be unrecoverable gone forever (all files insides are already wiped) so that it will be impossible to recover the directory structure or their names.

------------------- Update below (comment formatting is such a hassle so I post it here)---

For the file deletion I look up the partition's cluster and section size's and overwrite it at least 40 times using 5 different algorithms where the last algorithm is always the random one. The data is also actually written to the disk each time (and not just in memory or something). The only risk is that when I wipe something the physical address on the disk of that file could theoretically have been changed. The only solution I know for that is to also wipe the free disk space after the file has been wiped and hope that no other file currently partially holds the old physical location of the wiped file. Or does Windows not do such a thing?

http://www.sans.org/reading_room/whitepapers/incident/secure-file-deletion-fact-fiction_631 states:

"It is important to note the consensus that overwriting the data only reduces the likelihood of data being recovered. The more times data is overwritten, the more expensive and time consuming it becomes to recover the data. In fact Peter Guttman states “…it is effectively impossible to sanitize storage locations by simple overwriting them, no matter how many overwrite passes are made or what data patterns are written.”3 Overwritten data can be recovered using magnetic force microscopy, which deals with imaging magnetization patterns on the platters of the hard disk. The actual details of how this is accomplished are beyond the scope of this paper."

Personally I believe that when I overwrite the data like 100+ times using different (maybe unknown) algorithms (and if there is no copy of the data left elsewhere like in the swap files) that it will take any very expensive team of professionals many many years to get that data back. And if they do get the data back after all those years then they deserve it I guess... That must be a project for life.

So:

  • wiping unused data: use cipher (http://support.microsoft.com/kb/315672) or fill the hard-disk with 4GB files or use the Eraser command line executable.
  • wiping swap files: ?
  • wiping bad sectors: ?
  • wiping directories: use Eraser (as Teoman Soygul stated)
  • How do we know for sure that we overwrote the actual physical addresses?
  • wiping the most recently used files and the Windows log files should of course be piece a cake for any programmer :)
  • Eraser solves most of the above problems but cannot wipe the pages files. So any forensic will still find the data back if it was in those swap files at any moment.
  • AFAIK eraser does not wipe the file allocation tables. But I'm not sure.

And the conclusion should then be: It's (near) impossible to secure wipe in C#?

like image 549
Napoleon Avatar asked Nov 04 '22 21:11

Napoleon


1 Answers

there is no general approach for this ... consider a SSD: you can't even make sure that your write operation will write to the same physical address, because of wear-levelling methods

like image 159
DarkSquirrel42 Avatar answered Nov 09 '22 17:11

DarkSquirrel42