Beispiel #1
0
    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
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
 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
Beispiel #5
0
    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)
Beispiel #6
0
    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)
Beispiel #7
0
    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
Beispiel #8
0
    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
Beispiel #9
0
 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
Beispiel #10
0
 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
Beispiel #11
0
    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
Beispiel #12
0
    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
Beispiel #13
0
class ExecutionElement(object):
    def __init__(self, name='', parent_name='', ancestry=None):
        self.name = name
        self.parent_name = parent_name
        self._construct_ancestry(ancestry)
        self.event_handler = EventHandler(self.__class__.__name__ + 'EventHandler')

    def _construct_ancestry(self, ancestry):
        self.ancestry = list(ancestry) if ancestry is not None else [self.parent_name]
        self.ancestry.append(self.name)

    def _register_event_callbacks(self, callbacks):
        self.event_handler.add_events(callbacks)

    def _from_xml(self, xml_element, *args):
        raise NotImplementedError('from_xml(xml_element) has not been implemented')

    def to_xml(self, xml_element):
        raise NotImplementedError('to_xml(xml_element) has not been implemented')
Beispiel #14
0
 def fire(self, trigger):
     EventHandler.fire(trigger + ":" + self.vector + "-" + self.shortName)
Beispiel #15
0
 def __init__(self, name='', parent_name='', ancestry=None):
     self.name = name
     self.parent_name = parent_name
     self._construct_ancestry(ancestry)
     self.event_handler = EventHandler(self.__class__.__name__ + 'EventHandler')
Beispiel #16
0
 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))
Beispiel #17
0
 def fire(self, trigger):
     EventHandler.fire(trigger + ":" + self.vector + "-" + self.shortName)
Beispiel #18
0
 def fire(self, trigger):
     EventHandler.fire(trigger)
Beispiel #19
0
 def fire(self, trigger):
     EventHandler.fire(trigger + ":INPUTFile")