Skip to content

Instantly share code, notes, and snippets.

@joocer
Last active August 11, 2020 08:56
Show Gist options
  • Save joocer/b64b3c82e805ec50f3d2d073b1bed4b5 to your computer and use it in GitHub Desktop.
Save joocer/b64b3c82e805ec50f3d2d073b1bed4b5 to your computer and use it in GitHub Desktop.
qualys to off sample (note to jsonl)
import pandas as pd
import xmltodict
import json
import off
FINDINGS_FILE = r'qualys\qualys_hosts.xml'
SEVERITIES = ['Low', 'Low', 'Medium', 'Medium', 'High']
CONFIDENCES = { 'Potential': 'Medium', 'Confirmed': 'High' }
OFF_FILE = r'offl.json'
with open(FINDINGS_FILE) as ff:
findings_doc = xmltodict.parse(ff.read())
off_file = open(OFF_FILE, 'w')
hosts = findings_doc['HOST_LIST_VM_DETECTION_OUTPUT']['RESPONSE']['HOST_LIST']
for host in hosts['HOST']:
location = host.get('DNS')
timestamp = host.get('LAST_VM_SCANNED_DATE')
operating_system = host.get('OS')
for finding in host['DETECTION_LIST']['DETECTION']:
off_entry = {}
off_entry['name'] = finding.get('QID')
off_entry['description'] = finding.get('QID')
off_entry['severity'] = SEVERITIES[int(finding.get('SEVERITY')) - 1]
off_entry['confidence'] = CONFIDENCES[finding.get('TYPE')]
off_entry['timestamp'] = timestamp
off_entry['location'] = location
off_entry['source'] = 'QUALYS'
off_entry['tags'] = []
if (operating_system != None):
off_entry['tags'] = [x.strip() for x in operating_system.split('/')]
off_entry['references'] = []
off_entry['references'].append({
"name": "QID",
"id": finding.get('QID'),
"uri": "QID:" + finding.get("QID")
})
off_entry['references'].append({
"name": "CVE",
"id": "CVE-2020-" + finding.get('QID'),
"uri": "CVE:" + finding.get("QID")
})
#off_entry['fingerprint'] = off.fingerprint.generate_fingerprint(off_entry)
off_file.write(json.dumps(off_entry) + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment