Skip to content

Instantly share code, notes, and snippets.

@btoews
Created May 17, 2012 16:55
Show Gist options
  • Star 55 You must be signed in to star a gist
  • Fork 28 You must be signed in to fork a gist
  • Save btoews/2720173 to your computer and use it in GitHub Desktop.
Save btoews/2720173 to your computer and use it in GitHub Desktop.
Merging Nessus Files
# file: merger.py
# based off: http://cmikavac.net/2011/07/09/merging-multiple-nessus-scans-python-script/
# by: mastahyeti
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)
@PepsiBlue14
Copy link

Greetings,
Are you aware of any file size limitations? I have 200 files I'm attempting to combine that total 2GB.

@Gunstick
Copy link

This does not work with python2.6 which is still the most installed version in production environment. Knowing no python, I'm doomed :-) I tried this, but it's growing over my head: http://stackoverflow.com/questions/13667979/python-2-6-1-expected-path-separator

@RollForCode
Copy link

This is great for smaller files, but i have 40 reports that push through to a 1Gb .nessus file. it takes a good 5Gb of RAM to run this. if anyone knows of a script that uses iterparse (or similar), it would be great to see.

@xcabax
Copy link

xcabax commented Sep 28, 2016

This works perfect. I merged 56 reports with more than 25,000 hosts.

@Sendarg
Copy link

Sendarg commented Apr 1, 2017

Great,useful~

@TerminalFi
Copy link

TerminalFi commented Jun 29, 2018

NessusParser-Excel

https://github.com/TheSecEng/NessusParser-Excel

Notes

  • Clean output
  • Supports GB's of data

NessusMerger-Dirty

Notes

  • Supports GB's of files (Uses iterparse())
  • Fast

https://github.com/TheSecEng/NessusMerger-Dirty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment