-
Notifications
You must be signed in to change notification settings - Fork 1
/
cve.py
53 lines (41 loc) · 1.55 KB
/
cve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
try:
import xml.etree.cElementTree as ET
except ImportError:
import xml.etree.ElementTree as ET
tree = ET.ElementTree(file='cve.xml')
root = tree.getroot()
# print root.tag
# print root.attrib
# for cvenode in root.findall("cvrfdoc/Vulnerability"):
# print cvenode.text
print root.tag
vulnode_all = root.findall('{http://www.icasi.org/CVRF/schema/vuln/1.1}Vulnerability')
for vulnode in vulnode_all:
osvdb =''
cve = vulnode.find('{http://www.icasi.org/CVRF/schema/vuln/1.1}CVE').text
try:
refernode_all = vulnode.find('{http://www.icasi.org/CVRF/schema/vuln/1.1}References').findall('{http://www.icasi.org/CVRF/schema/vuln/1.1}Reference')
for refernode in refernode_all:
desc = refernode.find('{http://www.icasi.org/CVRF/schema/vuln/1.1}Description').text
if desc.startswith('OSVDB'):
print cve+","+desc
# osvdb = desc+','+osvdb
# print osvdb
# if len(osvdb) > 2:
# print cve+","+osvdb
# pass
# print refernode.find('{http://www.icasi.org/CVRF/schema/vuln/1.1}Description').text
except Exception, e:
pass
# refernode_all = vulnode.find('{http://www.icasi.org/CVRF/schema/vuln/1.1}References').findall('{http://www.icasi.org/CVRF/schema/vuln/1.1}Reference')
# for refernode in refernode_all:
# print refernode.find('{http://www.icasi.org/CVRF/schema/vuln/1.1}Description').text
# print type(vulnode)
# for elem in tree.iter():
# print elem.tag
# for vul in vulnode:
# print vul.find('Title').text
# print vul.findall('Reference').findall('Description').text
# print cvenode
# for child in root:
# print child.tag,