Skip to content

Instantly share code, notes, and snippets.

@jamieparfet
Created July 25, 2018 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamieparfet/6473833af6450b6237ade604e14e547b to your computer and use it in GitHub Desktop.
Save jamieparfet/6473833af6450b6237ade604e14e547b to your computer and use it in GitHub Desktop.
import xml.etree.ElementTree as etree
import shutil
import os
first = 1
for fileName in os.listdir("."):
if ".nessus" in fileName:
print(":: Parsing", fileName)
if first:
mainTree = etree.parse(fileName)
report = mainTree.find('Report')
report.attrib['name'] = 'Merged Report'
first = 0
else:
tree = etree.parse(fileName)
for host in tree.findall('.//ReportHost'):
existing_host = report.find(".//ReportHost[@name='"+host.attrib['name']+"']")
if not existing_host:
print "adding host: " + host.attrib['name']
report.append(host)
else:
for item in host.findall('ReportItem'):
if not existing_host.find("ReportItem[@port='"+ item.attrib['port'] +"'][@pluginID='"+ item.attrib['pluginID'] +"']"):
print "adding finding: " + item.attrib['port'] + ":" + item.attrib['pluginID']
existing_host.append(item)
print(":: => done.")
if "nss_report" in os.listdir("."):
shutil.rmtree("nss_report")
os.mkdir("nss_report")
mainTree.write("nss_report/report.nessus", encoding="utf-8", xml_declaration=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment