def getTargets(self, path):
targets = list()
# Recursively proceesses all nmap XML files from all specified folders
if len(path) > 0:
# Obtains all nmap XML files from each folder
p = path[0] + '*.xml'
if (len(glob(p)) == 0):
self.printMsg(5, "[!] [Error] There's no xml files in " + p[:-5])
else:
for f in glob(p):
self.printMsg(3, "Processing " + f.split(self.separator)[-1] + " ...")
dom = parse(f)
nmaprun = dom.documentElement
# For each host in nmap XML file
for node in nmaprun.getElementsByTagName('host'):
# Extracts IP addresses from all hosts with status = "up"
if node.getElementsByTagName('status')[0].getAttribute('state') == "up":
targets.append(node.getElementsByTagName('address')[0].getAttribute('addr'))
dom.unlink()
del path[0]
targets.extend(self.getTargets(path))
return targets
评论列表
文章目录