def processIPs(self, vector): for host in self.nm.all_hosts(): good = False for proto in self.nm[host].all_protocols(): if (good): break lport = list(self.nm[host][proto].keys()) lport.sort() for port in lport: if (good): break if (self.nm[host][proto][port]["state"] == "open"): good = True if (good): kb.add('host/' + host) # fire new event for "newHost" EventHandler.fire("newIP" + ":" + vector) # process ports self.processPorts(host, vector) # process hostscripts if ("hostscript" in self.nm[host]): self.processHostScripts(host, vector) return
def processService(self, host, port, proto, service): name = "" product = "" version = "" for key, value in service.attrib.items(): if key == 'name': name = value if "http" in name: if "https" in name: name = "https" elif "ssl" in name: name = "https" else: name = "http" original = value # print "NMAP -- " + original + " -- " + name elif key == 'product': product = value elif key == 'version': version = value # elif key == 'ostype': # print value # elif key == 'method': # print value # elif key == 'conf': # print value kb.add('service/' + name + '/' + host + '/' + proto + '/' + port + '/version/' + product + ' ' + version) EventHandler.fire("newService_" + name + ":" + self.vector)
def processService(self, host, port, proto, service): name = "" product = "" version = "" for key, value in service.attrib.items(): if key == 'name': name = value if "http" in name: if "https" in name: name = "https" elif "ssl" in name: name = "https" else: name = "http" original = value # print "NMAP -- " + original + " -- " + name elif key == 'product': product = value elif key == 'version': version = value # elif key == 'ostype': # print value # elif key == 'method': # print value # elif key == 'conf': # print value kb.add('service/' + name + '/' + host + '/' + proto + '/' + port + '/version/' + product + ' ' + version) EventHandler.fire("newService_" + name + ":" + self.vector)
def processScript(self, host, port, proto, vector): for script_id in self.nm[host][proto][port]["script"]: script_value = self.nm[host][proto][port]["script"][script_id] if (script_id == "vnc-brute") and (script_value == "No authentication required"): EventHandler.fire(script_id + ":" + vector) self.addVuln(host, "VNCNoAuth", vector, {"port" : str(port), "message": script_value}) self.display.error("VULN [%s] Found on [%s]" % (script_id, host)) return
def processPort(self, host, port): state = port.find('state').attrib['state'] if state == "open": portnum = port.attrib['portid'] proto = port.attrib['protocol'] kb.add('port/' + proto + '/' + portnum + '/' + host) EventHandler.fire("newPort_" + proto + '_' + portnum + ":" + self.vector) self.processService(host, portnum, proto, port.find('service')) for script in port.findall('script'): self.portScriptFunc (host, portnum, proto, script, self.outfile)
def processPort(self, host, port): state = port.find('state').attrib['state'] if state == "open": portnum = port.attrib['portid'] proto = port.attrib['protocol'] kb.add('port/' + proto + '/' + portnum + '/' + host) EventHandler.fire("newPort_" + proto + '_' + portnum + ":" + self.vector) self.processService(host, portnum, proto, port.find('service')) for script in port.findall('script'): self.portScriptFunc(host, portnum, proto, script, self.outfile)
def processService(self, host, port, proto, vector): product = self.nm[host][proto][port]["product"] version = self.nm[host][proto][port]["version"] name = self.nm[host][proto][port]["name"] kb.add('service/' + name + '/host/' + host + '/' + proto + 'port/' + str( port) + '/product' + product + '/version/' + str(version)) # print 'service/' + name + '/host/' + host + '/' + proto + 'port/' + str(port) + '/product' + product + # '/version/' + str(version) EventHandler.fire("newService" + str(name) + ":" + vector) if ("script" in self.nm[host][proto][port]): self.processScript(host, port, proto, vector) return
def processPorts(self, host, vector): for proto in self.nm[host].all_protocols(): lport = list(self.nm[host][proto].keys()) lport.sort() for port in lport: if (self.nm[host][proto][port]["state"] == "open"): # fire event for "newPortXXX" kb.add('host/' + host + '/' + proto + 'port/' + str(port)) # print 'host/' + host + '/' + proto + 'port/' + str(port) EventHandler.fire("newPort" + str(port) + ":" + vector) # process services and info self.processService(host, port, proto, vector) return
def processHost(self, host): ip = "" for addr in host.findall('address'): ip_tmp = addr.attrib['addr'] addrType = addr.attrib['addrtype'] if addrType == "ipv4": ip = ip_tmp kb.add('host/' + ip) EventHandler.fire("newIP" + ":" + self.vector) if host.find('hostname'): for hostname in host.find('hostnames').findall('hostname'): name = hostname.attrib['name'] kb.add('host/' + ip + '/dns/' + name) return ip
def processIPs(self, vector): for host in self.nm.all_hosts(): # print host kb.add('host/' + host) # fire new event for "newHost" EventHandler.fire("newIP" + ":" + vector) # process ports self.processPorts(host, vector) # process hostscripts if ("hostscript" in self.nm[host]): self.processHostScripts(host, vector) return
def processHost(self, host): ip = "" for addr in host.findall('address'): ip_tmp = addr.attrib['addr'] addrType = addr.attrib['addrtype'] if addrType == "ipv4": ip = ip_tmp kb.add('host/' + ip) EventHandler.fire("newIP" + ":" + self.vector) if host.find('hostname'): for hostname in host.find('hostnames').findall('hostname'): name = hostname.attrib['name'] kb.add('host/' + ip + '/dns/' + name) return ip
def processIPs(self, vector): for host in self.nm.all_hosts(): # print host kb.add('host/' + host) # fire new event for "newHost" EventHandler.fire("newIP" + ":" + vector) # process ports self.processPorts(host, vector) # process hostscripts if ("hostscript" in self.nm[host]): self.processHostScripts(host, vector) return
def fireScriptVulnEvent(self, script_id, host, vector): # fire a new trigger EventHandler.fire(script_id + ":" + vector) kb.add('host/' + host + '/vuln/' + script_id) self.display.error("VULN [%s] Found on [%s]" % (script_id, host))
def fire(self, trigger): EventHandler.fire(trigger)
def fire(self, trigger): EventHandler.fire(trigger + ":INPUTFile")
def fire(self, trigger): EventHandler.fire(trigger + ":" + self.vector + "-" + self.shortName)
def fire(self, trigger): EventHandler.fire(trigger + ":" + self.vector + "-" + self.shortName)