示例#1
0
文件: console_ui.py 项目: RON313/w3af
    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 项目: Daisymei/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"])
            return

        if len(parameters) == 0:
            om.out.console("No shell objects available; please use the exploit" " plugins to create them.")
            self._show()
            return

        try:
            self._selected_shell = int(parameters[0])
        except ValueError:
            self._cmd_help(["interact"])
            return

        # Do we have shells?
        if not len(self._exploit_results):
            msg = "No shells available."
            om.out.error(msg)
            return

        # Check that the user selected a valid shell
        if self._selected_shell not in range(len(self._exploit_results)):
            msg = "Please select a shell in range [0-%s]."
            srange = len(self._exploit_results) - 1
            om.out.error(msg % srange)
            return

        # 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._exploit_results[self._selected_shell], Shell):
            msg = (
                "You can only interact with shell objects."
                " To interact with proxy objects, please use"
                " your browser."
            )
            om.out.error(msg)
            return

        # Everything ok!
        prompt = self._exploit_results[self._selected_shell].get_name()

        msg = (
            'Execute "exit" to get out of the remote shell.'
            " Commands typed in this menu will be run through the %s shell."
        )
        om.out.console(msg % prompt)
        prompt = prompt + "-" + str(self._selected_shell)
        return callbackMenu(prompt, self._console, self._w3af, self, self._callback)
示例#3
0
文件: exploit.py 项目: nolank86/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'])
            return

        if len(parameters) == 0:
            om.out.console('No shell objects available; please use the exploit'
                           ' plugins to create them.')
            self._show()
            return

        try:
            self._selected_shell = int(parameters[0])
        except ValueError:
            self._cmd_help(['interact'])
            return

        # Do we have shells?
        if not len(self._exploit_results):
            msg = 'No shells available.'
            om.out.error(msg)
            return

        # Check that the user selected a valid shell
        if self._selected_shell not in range(len(self._exploit_results)):
            msg = 'Please select a shell in range [0-%s].'
            srange = len(self._exploit_results) - 1
            om.out.error(msg % srange)
            return

        # 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._exploit_results[self._selected_shell], Shell):
            msg = 'You can only interact with shell objects.'\
                  ' To interact with proxy objects, please use'\
                  ' your browser.'
            om.out.error(msg)
            return

        # Everything ok!
        prompt = self._exploit_results[self._selected_shell].get_name()

        msg = 'Execute "exit" to get out of the remote shell.'\
              ' Commands typed in this menu will be run through the %s shell.'
        om.out.console(msg % prompt)
        prompt = prompt + '-' + str(self._selected_shell)
        return callbackMenu(prompt, self._console, self._w3af, self,
                            self._callback)
示例#4
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.set_raw_input_mode(True)

            self._executePending()

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

            term.set_raw_input_mode(False)
        except KeyboardInterrupt:
            pass

        if not hasattr(self, '_parent'):
            try:
                self._w3af.quit()
                self._context.join()
                om.out.console(self._random_message())
                om.manager.process_all_messages()
            except KeyboardInterrupt:
                # The user might be in a hurry, and after "w3af>>> exit" he
                # might also press Ctrl+C like seen here:
                #     https://github.com/andresriancho/w3af/issues/148
                #
                # Since we don't want to show any tracebacks on this situation
                # just "pass".
                pass

            return 0