forked from SECFORCE/sparta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOS.py
50 lines (39 loc) · 1.11 KB
/
OS.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
50
#!/usr/bin/python
__author__ = 'ketchup'
__version__= '0.1'
__modified_by = 'ketchup'
import sys
import xml.dom.minidom
class OS:
name = ''
family = ''
generation = ''
os_type = ''
vendor = ''
accuracy = 0
def __init__( self, OSNode ):
if not (OSNode is None):
self.name = OSNode.getAttribute('name')
self.family = OSNode.getAttribute('osfamily')
self.generation = OSNode.getAttribute('osgen')
self.os_type = OSNode.getAttribute('type')
self.vendor = OSNode.getAttribute('vendor')
self.accuracy = OSNode.getAttribute('accuracy')
if __name__ == '__main__':
dom = xml.dom.minidom.parse('test.xml')
osclass = dom.getElementsByTagName('osclass')[0]
osmatch = dom.getElementsByTagName('osmatch')[0]
os = OS( osclass )
print os.name
print os.family
print os.generation
print os.os_type
print os.vendor
print str(os.accuracy)
os = OS( osmatch )
print os.name
print os.family
print os.generation
print os.os_type
print os.vendor
print str(os.accuracy)