http://qs321.pair.com?node_id=186262

aufrank has asked for the wisdom of the Perl Monks concerning the following question:

hey all--

I'm getting ready to format one of my drives as there are two more linux distributions I'd like to try out (inspired by a CB discussion yesterday). This sparked a memory of a section in Neal Stephenson's Cryptonomicon where the main modern-day character, Randy, attempts to completely wipe a disc containing some sensitive data in such a way as to ensure that nothing can be recovered from it. It's one of the more intense hacker-ly (possibly cracker-ly, though the files he was getting at were his own) sequences, and at the time I remember wondering what the best way to do that sort of thing would be. Since about May I've been assuming that the best way (or even several of the best ways) to do just about anything involve perl.

Now that I'm reformatting anyway, and since I'm currently perl-crazy, I'm curious: how could the task Randy attempted be accomplished in perl? I don't have the book with me, but as I remember it, the two main things he tried to do were to:

  • delete all mail files and any file that contained certain names (had to do this first as time was an issue and he didn't know if the second process would finish)
  • go through the drive block by block and overwrite each one seven times with random bits
  • The first part isn't really interesting to me... all I really want to know is if perl can be used to make something as simple as cleaning an old disk a sexy process. I believe the character in the book did this with a bunch of unix commands, but he probably wrote a lot more lines of code than one of you perl gurus would have. anyone got a one-liner to wipe a partition and cover it with junk til the data's unrecoverable? out of idle curiosity, is there a better/more secure perl way to do this than the one employed in the book? regardless of the answer, I'll just end up writing a new file system over it anyway.

    yes, this is how bored I happen to be :D
    --au

    I suppose I ought to include some disclaimer about how you all shouldn't bother responding if this sort of code seems likely to get people into trouble or to be abused, but I also suppose you all would have used your own good judgment even had I not said a thing. thanks for any appropriate responses :) If this doesn't get answered I'm certainly not sweating it, I'll just cfdisk like everyone else