forked from videns/vulners-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcentosDetect.py
38 lines (30 loc) · 1.26 KB
/
centosDetect.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
# -*- coding: utf-8 -*-
__author__ = 'videns'
from linuxDetect import linuxDetect
import re
class rpmBasedDetect(linuxDetect):
def __init__(self,sshPrefix):
self.supportedFamilies = ('redhat', 'centos', 'oraclelinux', 'suse', 'fedora')
super(rpmBasedDetect, self).__init__(sshPrefix)
def osDetect(self):
osDetection = super(rpmBasedDetect, self).osDetect()
if osDetection:
(osVersion, osFamily, osDetectionWeight) = osDetection
if osFamily in self.supportedFamilies:
osDetectionWeight = 60
return (osVersion, osFamily, osDetectionWeight)
version = self.sshCommand("cat /etc/centos-release")
if version:
osVersion = re.search("\s+(\d+)\.",version).group(1)
osFamily = "centos"
osDetectionWeight = 70
return (osVersion, osFamily, osDetectionWeight)
version = self.sshCommand("cat /etc/redhat-release")
if version:
osVersion = re.search("\s+(\d+)\.",version).group(1)
osFamily = "rhel"
osDetectionWeight = 60
return (osVersion, osFamily, osDetectionWeight)
def getPkg(self):
pkgList = self.sshCommand("rpm -qa")
return pkgList.splitlines()