Exemplo n.º 1
0
    def importScan(self, widget):
        """ Parse and import nmap scan """

        # Choose nmap scan file
        chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
        filter = gtk.FileFilter()
        filter.set_name('Nmap scan')
        filter.add_pattern('*.xml')
        chooser.add_filter(filter)

        # Try to parse and import data
        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            self.gom.echo( 'Loading Nmap Scan...', False)
            self.gom.echo(  chooser.get_filename() + ' selected' , False)
            res = chooser.get_filename()

            import lib.ui.nmapParser as nmapParser
            try:
                self.gom.echo( 'Parsing scan results...', False)
                nmapData = nmapParser.parseNmap(res)
                self.gom.echo( 'Inserting data in KB...', False)
                nmapParser.insertData(self.uicore, nmapData)


                askASN = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="Resolve ASN of IP addresses?")
                do_asn = askASN.run()

                self.gom.echo( 'Loaded\nUpdating Graph', False)

                if do_asn == gtk.RESPONSE_YES:
                    doASN=True
                else:
                    doASN=False

                t = threading.Thread(target=self.uicore.getDot, args=(doASN,))
                t.start()

                askASN.destroy()

                gobject.timeout_add(1000, self.update_graph, t)
#                self.xdotw.set_dotcode( self.uicore.get_kbfield('dotcode') )
#                self.gom.kbwin.updateTree()

            except:
                md = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="Error loading file")
                md.run()
                md.destroy()

        elif response == gtk.RESPONSE_CANCEL:
            self.gom.echo( 'Closed, no files selected', False)

        chooser.destroy()
Exemplo n.º 2
0
    def run_nmap(self, options):
        os.popen(options + " -oX /tmp/nmapxml.xml")
        nmapxml = open('/tmp/nmapxml.xml')

        outputs = nmapParser.parseNmap('/tmp/nmapxml.xml')
        nmapxml.close()
        os.remove('/tmp/nmapxml.xml')

        for output in outputs:

            # Add a new target, hostname and OS
            self.add_data_to_kb('targets', output['hostip'])
            self.gom.echo("Host IP:\t" + output['hostip'])
            if 'hostname' in output.keys():
                self.add_data_to_kb(output['hostip'] + '_name',
                                    output['hostname'])
                self.gom.echo("Host Name:\t" + output['hostname'])
            if 'os' in output.keys():
                self.add_data_to_kb(output['hostip'] + '_os', output['os'])
                self.gom.echo("Host OS:\t" + output['os'])

            # Add open ports and services.
            self.gom.echo("Host Ports:")
            for port in output['ports'].keys():
                if output['ports'][port][0] == 'open':
                    self.gom.echo("\n\tPort: " + port)
                    self.add_data_to_kb(output['hostip'] + "_tcp_ports", port)
                    try:
                        self.add_data_to_kb(
                            output['hostip'] + "_" + port + '-info',
                            output['ports'][port][1])
                        self.add_data_to_kb(
                            output['hostip'] + "_" + port + '-info',
                            output['ports'][port][2])
                        self.gom.echo("\tInfo 1: " + output['ports'][port][1])
                        self.gom.echo("\tInfo 2: " + output['ports'][port][2])
                    except:
                        pass

            # Add traceroute
            self.gom.echo("\nTraceroute:")
            for host in output['hops']:
                self.add_data_to_kb('hosts', host[0])
                if host[1] != '':
                    self.add_data_to_kb(host[0] + '_name', host[1])
                    self.gom.echo("\t" + host[0] + "\t-> " + host[1])
                else:
                    self.gom.echo("\t" + host[0])
                self.add_data_to_kb(output['hostip'] + '_trace', host[0])
Exemplo n.º 3
0
    def parse_data(self):

            import lib.ui.nmapParser as nmapParser

            self.gom.echo( 'Parsing scan results...', False)
            nmapData = nmapParser.parseNmap('/tmp/nmapxml.xml')
            os.remove('/tmp/nmapxml.xml')
            self.gom.echo( 'Inserting data in KB...', False)
            nmapParser.insertData(self.uicore, nmapData)

            self.gom.echo( 'Loaded\nUpdating Graph', False)

            self.uicore.getDot(doASN=False)

            self.gom.kbwin.updateTree()
            self.gom.update_graph( self.uicore.get_kbfield('dotcode') )
Exemplo n.º 4
0
    def parse_data(self):

        import lib.ui.nmapParser as nmapParser

        self.gom.echo('Parsing scan results...', False)
        nmapData = nmapParser.parseNmap('/tmp/nmapxml.xml')
        os.remove('/tmp/nmapxml.xml')
        self.gom.echo('Inserting data in KB...', False)
        nmapParser.insertData(self.uicore, nmapData)

        self.gom.echo('Loaded\nUpdating Graph', False)

        self.uicore.getDot(doASN=False)

        self.gom.kbwin.updateTree()
        self.gom.update_graph(self.uicore.get_kbfield('dotcode'))
Exemplo n.º 5
0
    def import_scan(self, widget, type = None, file = None):
        """ Parse and import nmap scan """

        self.gom = self.main.gom
        self.uicore = self.main.uicore
        self.xdotw = self.main.xdotw

        # Choose nmap scan file
        chooser = Gtk.FileChooserDialog(title=None,action=Gtk.FileChooserAction.OPEN, buttons=(Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL,Gtk.STOCK_OPEN,Gtk.ResponseType.OK))

        if file:
            chooser.set_filename(file)

        # Try to parse and import data
        response = chooser.run()
        filter = chooser.get_filter()
        if response == Gtk.ResponseType.OK and type == 'nmap':
            self.gom.echo('Loading Nmap Scan...', False)
            self.gom.echo( chooser.get_filename() + ' selected' , False)
            res = chooser.get_filename()

            import lib.ui.nmapParser as nmapParser
            try:
                self.gom.echo('Parsing scan results...', False)
                nmapData = nmapParser.parseNmap(res)
                self.gom.echo('Inserting data in KB...', False)
                nmapParser.insertData(self.uicore, nmapData)

                askASN = Gtk.MessageDialog(parent=None, flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO, message_format="Resolve ASN of IP addresses?")
                askASN.set_default_response(Gtk.ResponseType.YES)
                do_asn = askASN.run()

                self.gom.echo('Loaded\nUpdating Graph', False)

                if do_asn == Gtk.ResponseType.YES:
                    doASN=True
                else:
                    doASN=False

                t = threading.Thread(target=self.uicore.getDot, args=(doASN,))
                t.start()

                askASN.destroy()

                GObject.timeout_add(1000, self.update_graph, t)

            except:
                md = Gtk.MessageDialog(parent=None, flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.CLOSE, message_format="Error loading file")
                md.run()
                md.destroy()

        elif response == Gtk.ResponseType.OK and type == 'hosts':
            self.gom.echo('Loading Host list...', False)
            self.gom.echo( chooser.get_filename() + ' selected' , False)
            res = chooser.get_filename()
            try:
                hfile = open(res, 'r')
                hlist = hfile.readlines()
                hfile.close()
                hlist = hlist[0].split(',')

                self.gom.echo('Inserting data in KB...', False)
                for host in hlist:
                    self.uicore.set_kbfield('targets', host.strip())
                    self.uicore.set_kbfield('hosts', host.strip())

                # Update graph and KB tree
                self.uicore.getDot(doASN=False)
                self.xdotw.set_dotcode(self.uicore.get_last_dot())
                self.gom.kbwin.update_tree()
            except:
                print("Your lack of faith on my parsing capabilities is disturbing...")

        elif response == Gtk.ResponseType.CANCEL:
            self.gom.echo('Closed, no files selected', False)

        chooser.destroy()
Exemplo n.º 6
0
    def import_scan(self, widget):
        """ Parse and import nmap scan """

        self.gom = self.main.gom
        self.uicore = self.main.uicore
        self.xdotw = self.main.xdotw

        # Choose nmap scan file
        chooser = gtk.FileChooserDialog(
            title=None,
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                     gtk.RESPONSE_OK))

        filter = gtk.FileFilter()
        filter.set_name('Nmap scan')
        filter.add_pattern('*.xml')
        chooser.add_filter(filter)

        filter = gtk.FileFilter()
        filter.set_name('Host list')
        filter.add_pattern('*.csv')
        chooser.add_filter(filter)

        # Try to parse and import data
        response = chooser.run()
        filter = chooser.get_filter()
        if response == gtk.RESPONSE_OK and filter.get_name() == 'Nmap scan':
            self.gom.echo('Loading Nmap Scan...', False)
            self.gom.echo(chooser.get_filename() + ' selected', False)
            res = chooser.get_filename()

            import lib.ui.nmapParser as nmapParser
            try:
                self.gom.echo('Parsing scan results...', False)
                nmapData = nmapParser.parseNmap(res)
                self.gom.echo('Inserting data in KB...', False)
                nmapParser.insertData(self.uicore, nmapData)

                askASN = gtk.MessageDialog(
                    parent=None,
                    flags=gtk.DIALOG_MODAL,
                    type=gtk.MESSAGE_QUESTION,
                    buttons=gtk.BUTTONS_YES_NO,
                    message_format="Resolve ASN of IP addresses?")
                do_asn = askASN.run()

                self.gom.echo('Loaded\nUpdating Graph', False)

                if do_asn == gtk.RESPONSE_YES:
                    doASN = True
                else:
                    doASN = False

                t = threading.Thread(target=self.uicore.getDot, args=(doASN, ))
                t.start()

                askASN.destroy()

                gobject.timeout_add(1000, self.update_graph, t)

            except:
                md = gtk.MessageDialog(parent=None,
                                       flags=gtk.DIALOG_MODAL,
                                       type=gtk.MESSAGE_ERROR,
                                       buttons=gtk.BUTTONS_CLOSE,
                                       message_format="Error loading file")
                md.run()
                md.destroy()

        elif response == gtk.RESPONSE_OK and filter.get_name() == 'Host list':
            self.gom.echo('Loading Host list...', False)
            self.gom.echo(chooser.get_filename() + ' selected', False)
            res = chooser.get_filename()
            try:
                hfile = open(res, 'r')
                hlist = hfile.readlines()
                hfile.close()
                hlist = hlist[0].split(',')

                self.gom.echo('Inserting data in KB...', False)
                for host in hlist:
                    self.uicore.set_kbfield('targets', host.strip())
                    self.uicore.set_kbfield('hosts', host.strip())

                # Update graph
                self.uicore.getDot(doASN=False)
                self.xdotw.set_dotcode(self.uicore.get_kbfield('dotcode'))
            except:
                print "Your lack of faith on my parsing capabilities is disturbing..."

        elif response == gtk.RESPONSE_CANCEL:
            self.gom.echo('Closed, no files selected', False)

        chooser.destroy()