示例#1
0
文件: shell.py 项目: Adastra-thw/w3af
    def _payload(self, parameters):
        '''
        Handle the payload command:
            - payload desc list_processes -> return payload description
            - payload list_processes      -> run payload

        :param payload_name: The name of the payload I want to run.
        :param parameters: The parameters as sent by the user.
        '''
        #
        #    Handle payload desc xyz
        #
        if len(parameters) == 2:
            if parameters[0] == 'desc':
                payload_name = parameters[1]

                if payload_name not in payload_handler.get_payload_list():
                    return 'Unknown payload name: "%s"' % payload_name

                return payload_handler.get_payload_desc(payload_name)

        #
        #    Handle payload xyz
        #
        payload_name = parameters[0]
        parameters = parameters[1:]

        if payload_name not in payload_handler.get_payload_list():
            return 'Unknown payload name: "%s"' % payload_name

        if payload_name in payload_handler.runnable_payloads(self):
            om.out.debug(
                'Payload %s can be run. Starting execution.' % payload_name)

            # Note: The payloads are actually writing to om.out.console
            # so there is no need to get the result. If someone wants to
            # get the results in a programatic way they should execute the
            # payload with use_api=True.
            try:
                payload_handler.exec_payload(self, payload_name, parameters)
                result = None
            except TypeError:
                # We get here when the user calls the payload with an incorrect
                # number of parameters:
                payload = payload_handler.get_payload_instance(
                    payload_name, self)
                result = payload.get_desc()
            except ValueError, ve:
                # We get here when one of the parameters provided by the user is
                # not of the correct type, or something like that.
                result = str(ve)
示例#2
0
文件: shell.py 项目: daemon13/w3af
    def _payload(self, parameters):
        '''
        Handle the payload command:
            - payload desc list_processes -> return payload description
            - payload list_processes      -> run payload

        :param payload_name: The name of the payload I want to run.
        :param parameters: The parameters as sent by the user.
        '''
        #
        #    Handle payload desc xyz
        #
        if len(parameters) == 2:
            if parameters[0] == 'desc':
                payload_name = parameters[1]

                if payload_name not in payload_handler.get_payload_list():
                    return 'Unknown payload name: "%s"' % payload_name

                return payload_handler.get_payload_desc(payload_name)

        #
        #    Handle payload xyz
        #
        payload_name = parameters[0]
        parameters = parameters[1:]

        if payload_name not in payload_handler.get_payload_list():
            return 'Unknown payload name: "%s"' % payload_name

        if payload_name in payload_handler.runnable_payloads(self):
            om.out.debug(
                'Payload %s can be run. Starting execution.' % payload_name)

            # Note: The payloads are actually writing to om.out.console
            # so there is no need to get the result. If someone wants to
            # get the results in a programatic way they should execute the
            # payload with use_api=True.
            try:
                payload_handler.exec_payload(self, payload_name, parameters)
                result = None
            except TypeError:
                # We get here when the user calls the payload with an incorrect
                # number of parameters:
                payload = payload_handler.get_payload_instance(
                    payload_name, self)
                result = payload.get_desc()
            except ValueError, ve:
                # We get here when one of the parameters provided by the user is
                # not of the correct type, or something like that.
                result = str(ve)
示例#3
0
 def test_get_payload_instance(self):
     for payload_name in get_payload_list():
         payload_inst = get_payload_instance(payload_name, None)
         
         self.assertTrue( payload_inst.require() in ('linux', 'windows') )
示例#4
0
    def test_get_payload_instance(self):
        shell = FakeExecShell()
        for payload_name in get_payload_list():
            payload_inst = get_payload_instance(payload_name, shell)

            self.assertTrue(payload_inst.require() in ('linux', 'windows'))
示例#5
0
    def test_get_payload_instance(self):
        shell = FakeExecShell()
        for payload_name in get_payload_list():
            payload_inst = get_payload_instance(payload_name, shell)

            self.assertTrue(payload_inst.require() in ('linux', 'windows'))