Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

cryptonomicon challenge

by aufrank (Pilgrim)
on Jul 30, 2002 at 16:43 UTC ( #186262=perlquestion: print w/replies, xml ) Need Help??

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

    Replies are listed 'Best First'.
    Re: cryptonomicon challenge
    by John M. Dlugosz (Monsignor) on Jul 30, 2002 at 18:52 UTC
      I don't think writing random information 7 times is going to be enough. I think that's enough to prevent an analog read head from seeing 3 layers back, but the track-alignment issues can leave information laying around longer.

      There are standards published by the government that uses specific patterns, not random numbers. Gibson uses patterns designed with knowledge of how the run-length encoding works in his tester product--similar knowledge might be useful here too, to make sure the =physical= bits are all written.

      I would think the first pass would "wipe", not just "delete" the sensitive files.

      So, here is an idea. Implement a wiper that takes a file name, opens it for read/write access, and overwrites it n times with the required patterns or random data (making sure it's really flushed, etc.).

      Then, queue the list of files to process. Put the "sensitive" files first, but eventually list all files.

      Slack space can be accomidated by making a slack file that fills up the rest of the space, before starting.

      That way, one program does it all, and it can be reasonably portable and not need lower-level disk access.

    Re: cryptonomicon challenge
    by derby (Abbot) on Jul 30, 2002 at 19:02 UTC
    Re: cryptonomicon challenge
    by BrowserUk (Patriarch) on Jul 30, 2002 at 18:09 UTC

      I've been using BCWipe (under Win32) for several years. It is also (recently?) available for Linux

      Its not a Perl solution, but it is DoD 5200.28 complient which should mean something. Its also on a GPL licence which if you really want to impliment this in Perl, would give you source as a starting point.

    Re: cryptonomicon challenge
    by neilwatson (Priest) on Jul 30, 2002 at 17:29 UTC
      I've often wondered how to securely erase disks myself.

      In theory you could do something like:

      1. write from /dev/random to disk.
      2. erase what you just wrote.
      3. repeat as desired.

      How you would go about that I really don't know.

      Neil Watson
      watson-wilson.ca

    Re: cryptonomicon challenge
    by Ryszard (Priest) on Jul 31, 2002 at 12:03 UTC
      Dont forget looking into your page file for some additional information you'll need to erase. When i generally want to wipe my disk of particular information i use PGP and set it to wipe 20 times.

      I read somewhere about 3 years ago (cant recall the source) that an electron tunnelling microscope can recover data that has been overwritten 7 times.

    Re: cryptonomicon challenge
    by hiseldl (Priest) on Jul 30, 2002 at 20:09 UTC
      ...on the hackerish Rube Goldberg side...

      You could program a degausser via a Perl X10 script to erase your hard drives! This would at least start the data destruction process.

      :)

      --
      hiseldl

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: perlquestion [id://186262]
    Approved by Snuggle
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (4)
    As of 2022-12-02 08:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?