def _pass_hostinfo(self, entry):
s = None
if entry['host'] not in self._state:
s = {
'vulnerabilities': [],
'exempt_vulnerabilities': [],
'ports': set(),
'hostname': None,
'ipaddress': None,
'os': None,
'credentialed_checks': False
}
else:
s = self._state[entry['host']]
# if the hostname has not been set yet, just default it to the key/target
# value
if s['hostname'] == None:
s['hostname'] = entry['host']
thishostinfo = self._hostinfo_locator(entry)
# attempt to determine the ip address; if our target is an ip just use that,
# otherwise try to locate the ip address using the supplementary host info
try:
ipaddr.IPAddress(entry['host'])
s['ipaddress'] = entry['host']
except:
if thishostinfo != None:
s['ipaddress'] = thishostinfo['host-ip']
if thishostinfo != None and 'operating-system' in thishostinfo:
s['os'] = thishostinfo['operating-system']
# attempt to extract kernel hostname
if 'output of \"uname -a\" is' in entry['output']:
unamestr = entry['output'].replace('\n', ' ')
m = re.search('output of "uname -a" is : Linux (\S+) ', unamestr)
if m != None:
s['hostname'] = m.group(1)
elif '= Computer name' in entry['output']:
cnamestr = entry['output'].replace('\n', ' ')
m = re.search('(\S+)\s+= Computer name', cnamestr)
if m != None:
s['hostname'] = m.group(1)
# flip credentialed checks if we find plugin output indicating the scan
# included successfully used credentials
if 'Credentialed checks : yes' in entry['output']:
s['credentialed_checks'] = True
self._state[entry['host']] = s
评论列表
文章目录