Skip to content

Instantly share code, notes, and snippets.

@nopslider
Created August 2, 2018 09:41
Show Gist options
  • Save nopslider/3fe4880d069acc2426864cb72b2d906e to your computer and use it in GitHub Desktop.
Save nopslider/3fe4880d069acc2426864cb72b2d906e to your computer and use it in GitHub Desktop.
List information about hosts in a Nessus scan
#!/usr/bin/python3
import xml.etree.ElementTree as ET
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("nessusfile")
args = parser.parse_args()
nessus = ET.parse(args.nessusfile)
nessusroot = nessus.getroot()
for host in nessusroot.iter('ReportHost'):
name = host.attrib["name"]
ip = "Unknown"
netbios = "Unknown"
os = "Unknown"
for tag in host.iter('tag'):
if tag.attrib['name'] == 'operating-system':
os = tag.text.replace("\n","/")
if tag.attrib['name'] == 'host-ip':
ip = tag.text
if tag.attrib['name'] == 'netbios-name':
netbios = tag.text
print("{}|{}|{}|{}".format(name,netbios,ip,os))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment