예제 #1
0
    def sh(self, name='w3af', callback=None):
        '''
        Main cycle
        '''
        try:
            if callback:
                if hasattr(self, '_context'):
                    ctx = self._context
                else:
                    ctx = None
                self._context = callbackMenu(name, self, self._w3af, ctx, callback)
            else:
                self._context = rootMenu(name, self, self._w3af)
                
            self._lastWasArrow = False
            self._showPrompt()
            self._active = True
            term.setRawInputMode(True)

            self._executePending()

            while self._active: 
                try:
                    c = term.getch()
                    self._handleKey(c)
                except Exception, e:
                    om.out.console(str(e))

            term.setRawInputMode(False)
예제 #2
0
    def _execute(self):
        # term.writeln()

        line = self._getLineStr()
        term.setRawInputMode(False)
        om.out.console('')
        if len(line) and not line.isspace():

            self._getHistory().remember(self._line)
    
            try:               
                # New menu is the result of any command.
                # If None, the menu is not changed.
                params = self.inRawLineMode() and line or self._parseLine(line)
                menu = self._context.execute(params)
            except w3afMustStopException:
                menu = None
                self.exit()

            except w3afException, e:
                menu = None
                om.out.console( e.value )
                
            if menu:
                if callable(menu):
                    
                    # Command is able to delegate the detection 
                    # of the new menu to the console 
                    # (that's useful for back command:
                    # otherwise it's not clear what must be added to the trace)
                    # It's kind of hack, but I had no time 
                    # to think of anything better.
                    # An other option is to allow menu 
                    # objects modify console state directly which I don't like
                    # -- Sasha
                    menu = menu() 
                    
                elif menu != self._context:
                    # Remember this for the back command
                    self._trace.append(self._context)
                if menu is not None:
                    self._context = menu
예제 #3
0
    def _execute(self):
        # term.writeln()

        line = self._getLineStr()
        term.setRawInputMode(False)
        om.out.console('')
        if len(line) and not line.isspace():

            self._getHistory().remember(self._line)
    
            try:               
                # New menu is the result of any command.
                # If None, the menu is not changed.
                params = self.inRawLineMode() and line or self._parseLine(line)
                menu = self._context.execute(params)
            except w3afMustStopException, wmse:
                menu = None
                self.exit()

            except w3afException, e:
                menu = None
                om.out.console( e.value )
예제 #4
0
                    # of the new menu to the console 
                    # (that's useful for back command:
                    # otherwise it's not clear what must be added to the trace)
                    # It's kind of hack, but I had no time 
                    # to think of anything better.
                    # An other option is to allow menu 
                    # objects modify console state directly which I don't like
                    # -- Sasha
                    menu = menu() 
                    
                elif menu != self._context:
                    # Remember this for the back command
                    self._trace.append(self._context)
                if menu is not None:
                    self._context = menu
        term.setRawInputMode(True)


    def _onEnter(self):
        self._execute()
        self._initPrompt()
        self._showPrompt()

    def _delWord(self):
        filt = str.isspace
        while (True):
            if self._position == 0:
                break

            char = self._line[self._position-1]