Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: Secure delete ie shred a file

by fluffyvoidwarrior (Monk)
on Jan 26, 2006 at 07:55 UTC ( #525661=note: print w/replies, xml ) Need Help??

in reply to Re: Secure delete ie shred a file
in thread Secure delete ie shred a file

I would like to put deleted files beyond the reach of commercially available "undelete" programs at least. I don't think I have the expertise to confidently start poking with disks at a low level and so was hoping for a module. Maybe I can find a command line tool somewhere . . .

Replies are listed 'Best First'.
Re^3: Secure delete ie shred a file
by Enlil (Parson) on Jan 26, 2006 at 08:32 UTC
Re^3: Secure delete ie shred a file
by GrandFather (Sage) on Jan 26, 2006 at 08:05 UTC

    Norton used to make a utility for doing what you want for FAT drives.

    DWIM is Perl's answer to Gödel
Re^3: Secure delete ie shred a file
by DrHyde (Prior) on Jan 27, 2006 at 10:28 UTC
    Here's some untested code for you. The intention is to first figure out how much crap we need to overwrite the file with, then open the file in read/write mode - this avoids clobbering the file and creating a new one which would happen if we just opened the file for writing, and also means that we can get at the beginning of the file unlike if we opened it for appending. Then it just overwrites the file with 'X's. Finally, it closes the file and unlinks it.

    This will certainly protect you from "undelete" on DOS (all it will undelete is a file of 'X's) and DOS-a-likes such as Win95, and probably on WinNT and its successors if using the FAT filesystem. My understanding of ext2 leads me to believe that it should also protect you on most Linux systems. But I can't be sure that it will work anywhere else, including on Linux systems using stuff like Reiserfs, and as other people have pointed out, it certainly won't protect you against The Man. And even that paper is now out of date.

    my $bytes = -s $filename open(FILE, '+<', $filename); seek(FILE, 0, 0); print FILE "X" x $bytes; close(FILE); unlink $filename;
Re^3: Secure delete ie shred a file
by ayrnieu (Beadle) on Jan 28, 2006 at 06:44 UTC
    "commercially available 'undelete'" sounds like you don't mean to consider even marginally clever adversaries. In this case, truncating the file may all you need, with copying something innocent (a random configuration or help file from a windows system directory) or such as a safer second choice. 'undelete' normally only covers *deletion*, right?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://525661]
and a log crumbles through the grate...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2018-02-20 16:44 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (272 votes). Check out past polls.