예제 #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
파일: exploit.py 프로젝트: 1d3df9903ad/w3af
 def _cmd_interact( self, parameters ):
     '''
     Show the available shells and interact with them.
     '''
     if len(parameters) not in (0,1):
         self._cmd_help(['interact'])
     else:
         if len(parameters) == 0:
             if self._exploitResults:
                 self._show()
             else:
                 om.out.console('No proxy or shell objects have been created.')
         else:
             try:
                 self._selectedShell = int( parameters[0] )
             except:
                 self._cmd_help(['interact'])
             else:
                 
                 # Check that the user selected a valid shell
                 if self._selectedShell in range( len( self._exploitResults ) ):
                     
                     # And now check that the "shell" is actually a shell
                     # because maybe the user want's to interact with a proxy :S
                     # TODO: I should use different variables to store shells and proxies
                     if not isinstance(self._exploitResults[ self._selectedShell ], shell):
                         msg = 'You can only interact with shell objects.'
                         msg += ' To interact with proxy objects, please use your browser.'
                         om.out.error( msg )
                     else:
                         # Everything ok!
                         prompt = self._exploitResults[ self._selectedShell ].getName()
                         
                         msg = 'Execute "exit" to get out of the remote shell.'
                         msg += ' Commands typed in this menu will be run through the'
                         msg += ' ' + prompt + ' shell'
                         om.out.console( msg )
                         prompt = prompt+'-'+str(self._selectedShell)
                         return callbackMenu(prompt, self._console, self._w3af, self, self._callback)
 #                        console = self._console.fork()
 #                        console.sh( prompt, self._callback )
                 elif len(self._exploitResults) == 0:
                     om.out.console('No shell objects available; please use the exploit plugins to create them.')
                 elif len(self._exploitResults) == 1:
                     om.out.error('You can only interact with shell object with id 0; no other shells available.')
                 else:
                     om.out.error('Please select a shell in range [0-'+str(len(self._exploitResults)-1)+'].')