Skip to content

Instantly share code, notes, and snippets.

@nopslider
Created August 2, 2018 09:23
Show Gist options
  • Save nopslider/4f0c18ef2f87bc6de1823ec4a5494664 to your computer and use it in GitHub Desktop.
Save nopslider/4f0c18ef2f87bc6de1823ec4a5494664 to your computer and use it in GitHub Desktop.
Audit versions of MSSQL (credentialed check)
#!/usr/bin/python3
import xml.etree.ElementTree as ET
import argparse
import re
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'):
hostname = host.attrib["name"]
ip = "Unknown"
netbios = "Unknown"
os = "Unknown"
for tag in host.iter('tag'):
if tag.attrib['name'] == 'operating-system':
os = tag.text
if tag.attrib['name'] == 'host-ip':
ip = tag.text
if tag.attrib['name'] == 'netbios-name':
netbios = tag.text
for vuln in host.iter('ReportItem'):
if vuln.attrib['pluginName'] == 'Microsoft SQL Server Detection (credentialed check)':
output = vuln.find('plugin_output').text
matches = re.findall("Version[\t ]+:[\t ](.*)",output)
#for match in matches:
recommended = "N/A"
if len(matches) == 2:
recommended = matches[1]
print("{}|{}|{}|{}|{}|{}".format(hostname,netbios,ip,os,matches[0],recommended))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment