forked from MozillaSecurity/peach
/
filelist.py
59 lines (49 loc) · 1.97 KB
/
filelist.py
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
from Peach.Mutators.string import _SimpleGeneratorMutator
from Peach.Engine.dom import *
from Peach.Engine.common import *
from Tftp.randomdict import RandomDict
class FileListMutator(_SimpleGeneratorMutator):
def __init__(self, peach, node):
_SimpleGeneratorMutator.__init__(self, peach, node)
FileListMutator.weight = 2
self.name = "FileListMutator"
self._generator = RandomDict(None, None)
@staticmethod
def supportedDataElement(node):
return False
def randomMutation(self, node, rand):
self.changedName = node.getFullnameInDataModel()
self._generator.setRand(rand)
node.currentValue = self._generator.next()
class DownloadFileListMutator(FileListMutator):
"""
Example: <String><Hint name="type" value="downloadfilelist"></String>
"""
def __init__(self, peach, node):
FileListMutator.__init__(self, peach, node)
DownloadFileListMutator.weight = 2
self.name = "DownloadFileListMutator"
self._generator.setFilename("Tftp/downloadFileList.txt")
@staticmethod
def supportedDataElement(node):
if isinstance(node, String) and node.isMutable:
for child in node.hints:
if child.name == 'type' and child.value == 'downloadfilelist':
return True
return False
class UploadFileListMutator(FileListMutator):
"""
Example: <String><Hint name="type" value="uploadfilelist"></String>
"""
def __init__(self, peach, node):
FileListMutator.__init__(self, peach, node)
UploadFileListMutator.weight = 2
self.name = "UploadFileListMutator"
self._generator.setFilename("Tftp/uploadFileList.txt")
@staticmethod
def supportedDataElement(node):
if isinstance(node, String) and node.isMutable:
for child in node.hints:
if child.name == 'type' and child.value == 'uploadfilelist':
return True
return False