Destructive Windows Script

rbt rbt at athop1.ath.vt.edu
Sun Jun 5 20:38:43 EDT 2005


How easy or difficult would it be for a computer forensics expert to 
recover data that is overwritten in this manner? This is a bit off-topic 
for comp.lang.python, but I thought some here would have some insight 
into this.

Warning: **This code is destructive**. Do not run it unless you fully 
understand what you're doing!!!

os.chdir('/temp')
for root, dirs, files in os.walk('.'):
     for f in files:
         try:
             print f

             data = ['0', 'a', '1', 'b', '2', 'c',\
                     '3', 'd', '4', 'e', '5', 'f',\
                     '6', 'g', '7', 'h', '8', 'i',\
                     '9', 'j', '~', '!', '@', '#',\
                     '$', '%', '^', '&', '*', ';']

             fp = file(os.path.join(root,f), 'w')
             random.shuffle(data)
             garble = ''.join(data)
             fp.write(garble)
             fp.close()

             fs = os.popen("del /f /q /s *")
             fs.read()
             fs.close()

         except Exception, e:
             print e
             time.sleep(1)
             continue



More information about the Python-list mailing list