Пример #1
0
    def get_scan_results(self):
        log.debug(">>> Getting scan results stored in data base")
        u = UmitDB()

        for scan in u.get_scans():
            log.debug(">>> Retrieving result of scans_id %s" % scan.scans_id)
            log.debug(">>> Nmap xml output: %s" % scan.nmap_xml_output)

            temp_file = mktemp(".usr", "umit_")

            tmp = open(temp_file, "w")
            tmp.write(scan.nmap_xml_output)
            tmp.close()

            try:
                parsed = NmapParser()
                parsed.set_xml_file(temp_file)
                parsed.parse()

                # Remove temporary file reference
                parsed.nmap_xml_file = ""
            except:
                pass
            else:
                yield parsed
Пример #2
0
    def get_scan_results(self):
        log.debug(">>> Getting scan results stored in data base")
        u = UmitDB()

        for scan in u.get_scans():
            log.debug(">>> Retrieving result of scans_id %s" % scan.scans_id)
            log.debug(">>> Nmap xml output: %s" % scan.nmap_xml_output)
            
            temp_file = mktemp(".usr", "umit_")
            
            tmp = open(temp_file, "w")
            tmp.write(scan.nmap_xml_output)
            tmp.close()

            try:
                parsed = NmapParser()
                parsed.set_xml_file(temp_file)
                parsed.parse()
                
                # Remove temporary file reference
                parsed.nmap_xml_file = ""
            except:
                pass
            else:
                yield parsed
Пример #3
0
    def get_from_db(self):
        """Getting results from database"""
        from umit.core.UmitDB import UmitDB # change when this module is ok
        db = UmitDB()
        self.db_data = {}
        
        for scan in db.get_scans():
            
            #creating temporary file to store nmap xml
            temp_file = TemporaryFile()
            temp_file.write(scan.nmap_xml_output)
            #temp_file.seek(0) #---> really need this?
            
            try:
                parsed = NmapParser()
                parsed.set_xml_file(temp_file)
                parsed.parse()
                self.db_data[parsed.get_target()] = \
                    ((u'ip',parsed.get_hosts()[0].get_hostname()),
                     (u'date', parsed.get_formated_date()),
                     (u'nmap_command', parsed.get_nmap_command()),
                     (u'num_open_ports', parsed.get_open_ports()),
                     (u'ports', parsed.get_ports()),
                     (u'profile_name', parsed.get_profile_name()),
                     (u'stats', parsed.get_runstats()),
                     )
                
                # Remove temporary file reference
                parsed.nmap_xml_file = ""
                temp_file.close()
                
            except IndexError:
                #log the error
                #TODO: fix the bug with reg without ip
                pass

        del db
        return self.db_data