-
Notifications
You must be signed in to change notification settings - Fork 3
/
nessus_to_csv.py
48 lines (38 loc) · 1.24 KB
/
nessus_to_csv.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
"""This script converts all Nessus files in a direcotry
into one CSV file."""
#!/usr/bin/env python3
# pylint: disable=I0011
# pylint: disable=C0103
import xml.etree.ElementTree as etree
import csv
import os
ip = []
vuln = []
severity = []
start = 1
nessus_file = open('/tmp/nessus_file.csv', 'w')
csvwriter = csv.writer(nessus_file)
csvwriter.writerow(['ip Address', 'vulnerability', 'severity'])
count = 0
i = 0
data = []
for fileName in os.listdir("."):
if ".nessus" in fileName:
if start:
mainTree = etree.parse(fileName)
root = mainTree.getroot()
for reportHost in root.iter('ReportHost'):
ip.append(reportHost.get('name'))
for reportItem in root.iter('ReportItem'):
vuln.append(reportItem.get('pluginName'))
severity.append(reportItem.get('severity'))
# Only go through the while loop while there are still boxes (with IPs) to process
while i < len(ip):
data.append(ip[count])
data.append(vuln[count])
data.append(severity[count])
csvwriter.writerow(data)
data = []
i += 1
count += 1
nessus_file.close()