Created
January 17, 2017 07:44
-
-
Save jap/f1821f465b6fcc7f993a472943066dbb to your computer and use it in GitHub Desktop.
This is a very simple script to slowly corrupt directories. Use at your own peril.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2004 Sam Hocevar <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Inspiration for the name of this script: https://youtu.be/nVVTOHVXQQA | |
# | |
# (c) 2017 Jasper Spaans <[email protected]> | |
# This software is licenced under the WTFPL version 2 <see the file COPYING> | |
import mmap | |
import os | |
import random | |
import sys | |
x = "All this data is lost in time, like tears in the rain! " | |
lx = len(x) | |
y = range(lx) | |
random.seed(1337) | |
random.shuffle(y) | |
target_dirs = sys.argv[1:] | |
if not target_dirs: | |
print "Please supply one or more pathnames on the commandline" | |
sys.exit(-1) | |
counter = os.path.join(os.getenv("HOME"), ".swrcounter") | |
try: | |
with file(counter, "r") as f: | |
c = int(f.read()) | |
except: | |
c = 0 | |
all_files = [] | |
for target_dir in target_dirs: | |
for root, dirs, files in os.walk(target_dir): | |
for fn in files: | |
real_fn = os.path.join(root,fn) | |
st = os.stat(real_fn) | |
all_files.append((real_fn, st.st_mtime)) | |
the_char = x[y[c]] | |
for f in sorted(all_files, key=lambda x: x[1]): | |
fn = f[0] | |
with file(fn, "r+b") as fi: | |
mm = mmap.mmap(fi.fileno(), 0) | |
for offset in xrange(y[c], len(mm), lx): | |
mm[offset] = the_char | |
c = (c + 1) % lx | |
with file(counter, "w") as f: | |
f.write(str(c)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment