Disk Cleaner?

This is a discussion on Disk Cleaner? within the C++ Programming forums, part of the General Programming Boards category; Hi all, I just wanted to know if I was practical to create a program that will search a disk ...

  1. #1
    Registered Abuser Loic's Avatar
    Join Date
    Mar 2007
    Location
    Sydney
    Posts
    115

    Disk Cleaner?

    Hi all, I just wanted to know if I was practical to create a program that will search a disk for free space then overwrite it with random data.

    Also how would I go about writing such a program? Could someone give me some advice? Or point me in the right direction to some info???

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    If you are asking such a question, I don't think you are up for it. It is a lot more complex than it sounds. Due to the way modern file-systems work, it is very difficult to find free space. I would say it's right next to impossible if you don't know how your target filesystem works. If it's something proprietary and complex like NTFS, I would say just forget about it.

    Short answer: it is not practical.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Well someone does it... do they not?

    Just do some research on your filesystem.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    Yes, there is a handful of people in the programming world that can do this. But that doesn't mean everyone can do it.

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    I hate to argue, but it is far from impossible.

    I would recommend finding an open-source project that does something similar, and go from there.

  6. #6
    Registered Abuser Loic's Avatar
    Join Date
    Mar 2007
    Location
    Sydney
    Posts
    115
    That’s what I thought, there a quite a few programs that do it well something similar. I was looking around on sourceforge.net. see if i can find some code to go over.

    And I also found a vb script that sorta dose the same thing http://www.codeproject.com/KB/vbscri...te_script.aspx but isn't really what i am looking for.. & its in vb.

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,145
    Writing random bits to a File System is easy: open a file -> write random bits. Ten lines of C++ and you'll have it. The underlying file system should figure out where to create new files in available--empty/free--space. That's all the script does. This isn't the same thing as writing random bits to any unused blocks on a disk. It isn't even conceptually similar to completely trashing old data on a disk. It's not at all secure. You'll need to know virtually everything about the File System in question to actually make anything that would be secure. (NTFS for example can store small files directly in the file table. If you deleted such a small file and ran that script it would not even touch the actual data you wanted to garbage.)

    So, what are you actually wanting to do?

    Soma

  8. #8
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    You'll need to know virtually everything about the File System in question to actually make anything that would be secure.
    which, for something like NTFS is impossible, even if not for the complexity. The specifications of the FS is not even open to the public. You will have to reverse engineer it, and that is by no means an easy task (it took Linux kernel developers many years of work to get NTFS support into the Linux kernel, for example, and it is still read-only as of now IIRC).

    I would recommend finding an open-source project that does something similar, and go from there.
    It has to be one that works for NTFS, too, as what you are trying to do is very filesystem-dependent. I doubt anything like that exists. Feel free to prove me wrong.

    ... overwrite it with random data...
    wouldn't 0's work equally well?

  9. #9
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    Quote Originally Posted by Loic View Post
    Hi all, I just wanted to know if I was practical to create a program that will search a disk for free space then overwrite it with random data.

    Also how would I go about writing such a program? Could someone give me some advice? Or point me in the right direction to some info???
    Open a file. Start writing random data to the file. Keep going until the OS gives you an error because you ran out of disk space. You have now overwritten all free space on the drive, with random data. Now delete the file you just created.

    EDIT: If you're looking for security from the cops -- good luck. Not only will they find the little bits you didn't catch, but there is technology which can read old bit states to a reasonable degree of precision -- i.e., they can read data you've overwritten with something else. That's why industrial strength data erasure tools make multiple passes with different bit sequences. And if you want real security, smash the drive and then burn it.

    EDIT EDIT: For instance, did you clear your browser cache? If not, the free block eraser won't erase those sectors, and you might get "busted." I really question the legitimate need for pure data erasure. The big boys just destroy the drives when they need data to go away.
    Last edited by brewbuck; 04-07-2008 at 09:17 PM.

  10. #10
    Registered Abuser Loic's Avatar
    Join Date
    Mar 2007
    Location
    Sydney
    Posts
    115
    Ok well i found this program on sourceforge.net http://sourceforge.net/projects/eraser

    seems to be what i need to look into.

  11. #11
    Registered Abuser Loic's Avatar
    Join Date
    Mar 2007
    Location
    Sydney
    Posts
    115
    Quote Originally Posted by brewbuck View Post
    Open a file. Start writing random data to the file. Keep going until the OS gives you an error because you ran out of disk space. You have now overwritten all free space on the drive, with random data. Now delete the file you just created.

    EDIT: If you're looking for security from the cops -- good luck. Not only will they find the little bits you didn't catch, but there is technology which can read old bit states to a reasonable degree of precision -- i.e., they can read data you've overwritten with something else. That's why industrial strength data erasure tools make multiple passes with different bit sequences. And if you want real security, smash the drive and then burn it.

    EDIT EDIT: For instance, did you clear your browser cache? If not, the free block eraser won't erase those sectors, and you might get "busted." I really question the legitimate need for pure data erasure. The big boys just destroy the drives when they need data to go away.
    well, i think i am going to start looking over the source of that eraser program. just need to find the source now :S but it seems to be what i am looking for...

    and, as for what you said about someone trying to hide something from the cops... 99.9% of programs i found all make multiple passes with different data. "eraser" dose up to 35 i think... and if i am not mistaken. i read somewhere that an Department of defensive method only makes 7 passes?

    but i am sure there is still much to be learnt...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Disk failure in 3 disk RAID0 & 5?
    By cpjust in forum Tech Board
    Replies: 12
    Last Post: 12-22-2008, 09:09 AM
  2. lost disk
    By Benzakhar in forum Linux Programming
    Replies: 7
    Last Post: 01-11-2004, 05:18 PM
  3. Formatting Output
    By Aakash Datt in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2003, 08:20 PM
  4. Towers of Hanoi, special output.
    By spoon_ in forum C Programming
    Replies: 3
    Last Post: 03-15-2003, 05:08 PM
  5. Direct disk access in DOS
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-26-2002, 01:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21