-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzzModify
More file actions
executable file
·83 lines (76 loc) · 2.52 KB
/
fuzzModify
File metadata and controls
executable file
·83 lines (76 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
import os
import sys
import string
import random
import argparse
class Modify:
def __init__(self, path):
self.files = list(self._find_files(path))
self.chars = string.printable + string.whitespace
def _find_files(self, path):
for start, dirs, filenames in os.walk(os.path.expanduser(path)):
for filename in filenames:
yield os.path.join(start, filename)
def one(self):
for filename in self.files:
f = list(open(filename, 'r'))
count = 0
for line in f:
n = random.randint(0, len(line))
x = random.randint(0, 6)
mod = line[:n] + ''.join(random.sample(self.chars, x)) + line[n:]
f[count] = mod
count += 1
r = open(filename + '_1', 'w')
for line in f:
r.write(line)
r.close()
def two(self):
for filename in self.files:
f = list(open(filename, 'r'))
count = 0
for line in f:
n = random.randint(0, len(line))
mod = line[:n] + str(hex(random.randint(0, 10000))) + line[n:]
f[count] = mod
count += 1
r = open(filename + '_2', 'w')
for line in f:
r.write(line)
r.close()
def three(self):
for filename in self.files:
f = list(open(filename, 'r'))
count = 0
for line in f:
n = random.randint(0, len(line))
x = random.randint(n, len(line))
f[count] = line[:n] + line[x:]
count += 1
r = open(filename + '_3', 'w')
for line in f:
r.write(line)
r.close()
if __name__ == '__main__':
parse = argparse.ArgumentParser(description="fuzzModify performs\
modifications to files collected by scrape")
parse.add_argument('path', help='input directory',
metavar=('path'))
parse.add_argument('-1', action='store_true', help='add chars',
dest='one')
parse.add_argument('-2', action='store_true', help='add hex',
dest='two')
parse.add_argument('-3', action='store_true', help='remove rand',
dest='three')
if len(sys.argv) < 2:
parse.print_help()
exit()
args = parse.parse_args()
modify = Modify(args.path)
if args.one:
modify.one()
if args.two:
modify.two()
if args.three:
modify.three()