Quantcast
Channel: Blogfreakz - Web Design and Web Development resources » Python
Viewing all articles
Browse latest Browse all 7

How To Parse MBSA Files Using Python Script

$
0
0

Have you ever needed to analyze MBSA files using Python? Well, you can stop cramming now because Azmath just shared the answer to your problem with this nice Python script!

ScreenHunter 689 Oct. 17 16.34 How To Parse MBSA Files Using Python Script
#-------------------------------------------------------------------------------
# Name:        MBSA parser
# Author:      Azmath
# Created:     11/07/2012
# Copyright:   (c) 2012
#-------------------------------------------------------------------------------

from xml.etree import ElementTree

with open('test.mbsa', 'rt') as f:
 tree = ElementTree.parse(f)
print "servername" + "|"+"domainname" +"|"+"scandate"+"|"+"id" +"|"+ "severity" +"|"+ "Patchtype" + "|"+"Description"
for node in tree.iter('SecScan'):
 name = node.attrib.get('Machine')
 domain = node.attrib.get('Domain')
 scandate = node.attrib.get('LDate')
 if name and domain:
 print '  %s :: %s' % (name, domain)
 else:
 print name

for node in tree.iter('UpdateData'):
 id = node.attrib.get('ID')
 if id:
 isinstalled = node.attrib.get('IsInstalled')
 if isinstalled == 'false':
 bid = node.attrib.get('BulletinID')
 if bid:
 bulletinid = bid
 else:
 bulletinid = "None"
 idd = node.attrib.get('ID')
 #print "Patch id = " +idd
 severity = node.attrib.get('Severity')
 #print "Severity = "+severity
 dtype = node.attrib.get ('Type')
 #print "Patch type:" + dtype
 for p in node.getiterator('Title'):
 desc = p.text
 print name + "|"+domain +"|"+scandate+"|"+idd +"|"+ severity +"|"+ dtype + "|"+desc     

Incoming search terms for the article:


Viewing all articles
Browse latest Browse all 7

Trending Articles