-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoGenerate.py
136 lines (96 loc) · 3.37 KB
/
AutoGenerate.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import os
import win32com.client as win32
import datetime
from achillesstorm import AchillesStorm
from achillesfuzz import AchillesFuzz
from nmap import Nmap
from robust import robustnessform
class autogenerate:
# This class intergrates working of nmap.py,achillesstorm.py,achillesfuzz.py and robust.py.This should be run after FileManagerNessus.py
NmapObject=[]
RobustObject=[]
AchStormObj=[]
AchFuzzObj=[]
def __init__(self):
self.root = '.'
self.fileList = {}
def makeRoot(self, root):
self.root = root
def isXML(self, fileName):
# This function finds for the xml files in the root folder provided.
if fileName.endswith('.xml') or fileName.endswith('.doc') and fileName.lower().rfind('regression')==-1 :
return True
else:
return False
def makeFileList(self):
# This function create list of file names and file paths having xml extension .
key=0
for (path, dirs, files) in os.walk(self.root):
for item in files:
fileName = os.path.join(path,item)
if self.isXML(fileName):
value=(fileName)
key=key+1
self.fileList[key]=value
# for i in self.fileList :
# print i
# print self.fileList[i]
def selectFile(self):
# This function reads first few lines of every xml file encounterd in the root to recognize which xml file is meant for which Tool.
for i in self.fileList:
file=open(self.fileList[i])
xml=file.read()
if "Robustness".lower() in self.fileList[i].lower() :
self.RobustObject.append(robustnessform(self.fileList[i],docfile))
elif "Achilles" in xml:
# print i,'--->',self.fileList[i]
# print "achu"
self.AchStormObj.append(AchillesStorm(self.fileList[i],docfile))
self.AchFuzzObj.append(AchillesFuzz(self.fileList[i],docfile))
elif "nmaprun" in xml :
self.NmapObject.append(Nmap(self.fileList[i],docfile))
def storeforObj(self):
# This functions calls for the required functions for every test tool object.
for objs in self.RobustObject:
# print objs.data.keys()
objs.fetchtabledata()
objs.writetabledata()
objs.replaceDeviceName()
print "-----Robust done-----------"
for objs in self.NmapObject:
objs.fetchip()
objs.fillip()
objs.fetchmac()
objs.fetchversion()
objs.fillversion()
objs.fillmac()
# objs.cleartblnmap()
objs.fetchtblfromxml()
objs.filltblnmap()
print "---------Device Profiling Tool done-----------"
for objs in self.AchStormObj:
objs.clearncorrect()
objs.fetchnfillIPStack()
objs.fetchports()
objs.fillports()
objs.fetchstormtestname()
objs.fetchstorm()
objs.fillstorm()
print "---------------Fuzzing and Flooding Tool Storm Results Done ---------------"
for objs in self.AchFuzzObj:
objs.fetchfuzztestname()
objs.fetchfuzz()
objs.fillfuzz()
print "---------Fuzzing and Flooding Tool Fuzz Results Done-------------------"
if __name__ == "__main__":
fp = autogenerate()
print "Enter path for Root folder of xml files"
root =raw_input()
# root = "C:\Users\inprsha\Desktop\\"
print "Enter path for REPORT TEMPLATE"
docfile=raw_input()
# docfile= "C:\Users\inprsha\Desktop\Mars.doc
fp.makeRoot('.')
fp.makeFileList()
fp.selectFile()
fp.storeforObj()