Exemplo n.º 1
0
def main_loop():
    """ Main execution loop after initialization. """

    import lib.ui.cli.core as CLIcore
    global prompt
    global oldPrompt
    global prevRes
    global target
    global port
    global covert
    global timeout
    global waittime
    global debug

    oldPrompt = ""
    prevRes = ""
    inguma = Inguma(hasScapy)

    while 1:
        res = CLIcore.unified_input_prompt(inguma)
        if res == None:
            print "Exit."
            sys.exit(0)

        if res == "" and prevRes == "":
            pass
        elif res.lower() == "save kb":
            saveKb()
        elif res.lower() == "clear kb":
            clearKb()
        elif res.lower() == "load kb":
            loadKb()
        elif res.lower() == "show kb":
            showKb()
        elif res.lower() == "show discover":
            showDiscover()
        elif res.lower() == "show gather":
            showGather()
        elif res.lower() == "show rce":
            showRce()
        elif res.lower() == "show fuzzers":
            showFuzzers()
        elif res.lower() == "show brute":
            showBrutes()
        elif res.lower() == "autoscan":
            doAutoScan()
        elif res.lower() == "report":
            generateReport(user_data)
        elif res.lower() == "payload":
            printPayloads()
        elif res != "" and prevRes != "":
            prevRes += "\n" + res
        elif res == "" and prevRes != "":
            try:
                if prevRes != "":
                    prevRes += "\n" + res
                    res = prevRes

                exec(GLOBAL_VARIABLES + res)

            except:
                print "Exec error:", sys.exc_info()[1]

            prevRes = ""
            if oldPrompt != "":
                prompt = oldPrompt
                oldPrompt = ""
        elif res[len(res) - 1] == ":":
            oldPrompt = prompt
            prompt = ">>>>>>> "
            prevRes = res
        else:
            try:
                if not runCommand(res, locals()):
                    exec(GLOBAL_VARIABLES + res)
            except:
                print "Internal error.", sys.exc_info()[1]

                if debug:
                    raise
Exemplo n.º 2
0
    def __init__(self, core, host=''):

        super(reportWin, self).__init__()

        self.TITLE = "Report"
        self.uicore = core
        self.host = host

        # Window properties
        self.connect("destroy", self.win_destroy)
        self.set_size_request(800, 600)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_title(self.TITLE)

        # VBox for Menu and Textview
        self.vbox = Gtk.VBox()

        # Menu
        self.mb = Gtk.MenuBar()

        agr = Gtk.AccelGroup()
        self.add_accel_group(agr)

        filemenu = Gtk.Menu()
        filem = Gtk.MenuItem("_File")
        filem.set_submenu(filemenu)

        savi = Gtk.ImageMenuItem(Gtk.STOCK_SAVE, agr)
        key, mod = Gtk.accelerator_parse("S")
        savi.add_accelerator("activate", agr, key, mod, Gtk.AccelFlags.VISIBLE)
        filemenu.append(savi)

        savi.connect("activate", self.save_report)

        sep = Gtk.SeparatorMenuItem()
        filemenu.append(sep)

        exit = Gtk.ImageMenuItem(Gtk.STOCK_QUIT, agr)
        key, mod = Gtk.accelerator_parse("Q")
        exit.add_accelerator("activate", agr, key, mod, Gtk.AccelFlags.VISIBLE)
        filemenu.append(exit)

        exit.connect("activate", self.win_destroy)

        self.mb.append(filem)
        # Add Menu to VBox
        self.vbox.pack_start(self.mb, False, False, 0)

        # Textview
        self.reporttv = Gtk.TextView()

        self.reporttv.set_wrap_mode(Gtk.WrapMode.NONE)
        self.reporttv.set_editable(False)
        #self.reporttv.set_cursor_visible(False)

        # Change text font
        fontdesc = Pango.FontDescription("MonoSpace 10")
        #fontdesc = Pango.FontDescription("Purisa 10")
        self.reporttv.modify_font(fontdesc)

        # Scrolled Window for Textview
        self.sw = Gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
        self.sw.add_with_viewport(self.reporttv)

        # Get KB to parse for report
        self.textbuffer = self.reporttv.get_buffer()
        if self.host:
            self.report_data = generateReport( self.uicore.get_kbList(), self.host )
        else:
            self.report_data = generateReport( self.uicore.get_kbList() )
        self.textbuffer.set_text(self.report_data)
        # Add Textview to VBox
        self.vbox.pack_start(self.sw, True, True, 0)

        # Show all
        self.add(self.vbox)
        self.show_all()
Exemplo n.º 3
0
    def __init__(self, core):

        super(reportWin, self).__init__()

        self.TITLE = "Report"
        self.uicore = core

        # Window properties
        self.connect("destroy", self.win_destroy)
        self.set_size_request(800, 600)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_title(self.TITLE)

        # VBox for Menu and Textview
        self.vbox = gtk.VBox()

        # Menu
        self.mb = gtk.MenuBar()

        agr = gtk.AccelGroup()
        self.add_accel_group(agr)

        filemenu = gtk.Menu()
        filem = gtk.MenuItem("_File")
        filem.set_submenu(filemenu)

        savi = gtk.ImageMenuItem(gtk.STOCK_SAVE, agr)
        key, mod = gtk.accelerator_parse("S")
        savi.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
        filemenu.append(savi)

        savi.connect("activate", self.save_report)

        sep = gtk.SeparatorMenuItem()
        filemenu.append(sep)

        exit = gtk.ImageMenuItem(gtk.STOCK_QUIT, agr)
        key, mod = gtk.accelerator_parse("Q")
        exit.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
        filemenu.append(exit)

        exit.connect("activate", self.win_destroy)

        self.mb.append(filem)
        # Add Menu to VBox
        self.vbox.pack_start(self.mb, False, False, 0)

        # Textview
        self.reporttv = gtk.TextView()

        self.reporttv.set_wrap_mode(gtk.WRAP_NONE)
        self.reporttv.set_editable(False)
        #self.reporttv.set_cursor_visible(False)

        # Change text font
        fontdesc = pango.FontDescription("MonoSpace 10")
        #fontdesc = pango.FontDescription("Purisa 10")
        self.reporttv.modify_font(fontdesc)

        # Scrolled Window for Textview
        self.sw = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
        self.sw.add_with_viewport(self.reporttv)

        # Get KB to parse for report
        self.textbuffer = self.reporttv.get_buffer()
        self.report_data = generateReport( self.uicore.get_kbList() )
        self.textbuffer.set_text(self.report_data)
        # Add Textview to VBox
        self.vbox.pack_start(self.sw, True, True, 0)

        # Show all
        self.add(self.vbox)
        self.show_all()
Exemplo n.º 4
0
def runInterfaceCommand(res):

    global prompt
    global oldPrompt
    global prevRes
    global target
    global port
    global covert
    global timeout
    global waittime
    global debug

    if res.lower() == "help":
        showHelp()
    elif res == "" and prevRes == "":
        pass
    elif res == "save kb":
        saveKb()
    elif res == "clear kb":
        clearKb()
    elif res == "load kb":
        loadKb()
    elif res == "show kb":
        showKb()
    elif res.lower() == "show discover":
        showDiscover()
    elif res.lower() == "show gather":
        showGather()
    elif res.lower() == "show rce":
        showRce()
    elif res.lower() == "show fuzzers":
        showFuzzers()
    elif res.lower() == "show brute":
        showBrutes()
    elif res.lower() == "autoscan":
        doAutoScan()
    elif res.lower() == "report":
        generateReport(user_data)
    elif res.lower() == "payload":
        printPayloads()
    elif res != "" and prevRes != "":
        prevRes += "\n" + res
    elif res == "" and prevRes != "":
        try:
            if prevRes != "":
                prevRes += "\n" + res
                res = prevRes

            exec(GLOBAL_VARIABLES + res)

        except:
            print "Exec error:",sys.exc_info()[1]

        prevRes = ""
        if oldPrompt != "":
            prompt = oldPrompt
            oldPrompt = ""
    elif res[len(res)-1] == ":":
        oldPrompt = prompt
        prompt = ">>>>>>> "
        prevRes = res
    else:
        try:
            if not runCommand(res, locals()):
                exec(GLOBAL_VARIABLES + res)
        except:
            print "Internal error.",sys.exc_info()[1]
            
            if debug:
                raise
Exemplo n.º 5
0
def runInterfaceCommand(res):

    global prompt
    global oldPrompt
    global prevRes
    global target
    global port
    global covert
    global timeout
    global waittime
    global debug

    if res.lower() == "help":
        showHelp()
    elif res == "" and prevRes == "":
        pass
    elif res == "save kb":
        saveKb()
    elif res == "clear kb":
        clearKb()
    elif res == "load kb":
        loadKb()
    elif res == "show kb":
        showKb()
    elif res.lower() == "show discover":
        showDiscover()
    elif res.lower() == "show gather":
        showGather()
    elif res.lower() == "show rce":
        showRce()
    elif res.lower() == "show fuzzers":
        showFuzzers()
    elif res.lower() == "show brute":
        showBrutes()
    elif res.lower() == "autoscan":
        doAutoScan()
    elif res.lower() == "report":
        generateReport(user_data)
    elif res.lower() == "payload":
        printPayloads()
    elif res != "" and prevRes != "":
        prevRes += "\n" + res
    elif res == "" and prevRes != "":
        try:
            if prevRes != "":
                prevRes += "\n" + res
                res = prevRes

            exec(GLOBAL_VARIABLES + res)

        except:
            print "Exec error:", sys.exc_info()[1]

        prevRes = ""
        if oldPrompt != "":
            prompt = oldPrompt
            oldPrompt = ""
    elif res[len(res) - 1] == ":":
        oldPrompt = prompt
        prompt = ">>>>>>> "
        prevRes = res
    else:
        try:
            if not runCommand(res, locals()):
                exec(GLOBAL_VARIABLES + res)
        except:
            print "Internal error.", sys.exc_info()[1]

            if debug:
                raise
Exemplo n.º 6
0
def main_loop():
    """ Main execution loop after initialization. """

    global prompt
    global oldPrompt
    global prevRes
    global target
    global port
    global covert
    global timeout
    global waittime

    oldPrompt = ""
    prevRes = ""
    inguma = Inguma(hasScapy)

    while 1:
        res = uicore.unified_input_prompt(inguma)
        if res == None:
            glob.gom.echo("Exit.")
            return False

        if res == "" and prevRes == "":
            pass
        elif res.lower() == "save kb":
            # FIXME: We cannot use globals inside the KnowledgeBase class, so
            # we have to assign the 'target' global variable to a glob attribute
            # prior to calling the class method.
            glob.target = target
            res = input('Filename [%s]: ' % glob.kb.default_filename)
            if res:
                glob.kb.save(res)
            else:
                glob.kb.save()
            # FIXME: We cannot use globals inside the KnowledgeBase class, so
            # we have to reassign the 'target' global variable after calling
            # it. 'global target' is defined above in the function,
            target = glob.target
        elif res.lower() == "clear kb":
            glob.kb.reset()
        elif res.lower() == "load kb":
            # FIXME: We cannot use globals inside the KnowledgeBase class, so
            # we have to assign the 'target' global variable to a glob attribute
            # prior to calling the class method.
            glob.target = target
            glob.gom.echo('* Warning! Warning! Warning! Warning! Warning! Warning! *')
            glob.gom.echo('*** Never load KB files received from untrusted sources ***')
            res = input('Filename [%s]: ' % glob.kb.default_filename)

            if res:
                glob.kb.load(res)
            else:
                glob.kb.load()
            # FIXME: We cannot use globals inside the KnowledgeBase class, so
            # we have to reassign the 'target' global variable after calling
            # it. 'global target' is defined above in the function,
            target = glob.target
        elif res.lower() == "show kb":
            glob.gom.echo(glob.kb.format_text())
        elif res.lower() == "show discover":
            showDiscover()
        elif res.lower() == "show gather":
            showGather()
        elif res.lower() == "show rce":
            showRce()
        elif res.lower() == "show fuzzers":
            showFuzzers()
        elif res.lower() == "show brute":
            showBrutes()
        elif res.lower() == "autoscan":
            doAutoScan()
        elif res.lower() == "report":
            generateReport(user_data)
        elif res.lower() == "payload":
            printPayloads()
        elif res != "" and prevRes != "":
            prevRes += "\n" + res
        elif res == "" and prevRes != "":
            try:
                if prevRes != "":
                    prevRes += "\n" + res
                    res = prevRes

                exec(glob.GLOBAL_VARIABLES + res)

            except:
                print("Exec error:",sys.exc_info()[1])

            prevRes = ""
            if oldPrompt != "":
                prompt = oldPrompt
                oldPrompt = ""
        elif res[len(res)-1] == ":":
            oldPrompt = prompt
            prompt = ">>>>>>> "
            prevRes = res
        else:
            try:
                if not runCommand(res, locals()):
                    exec(glob.GLOBAL_VARIABLES + res)
            except:
                print("Internal error.",sys.exc_info()[1])

                if glob.debug:
                    raise