Example #1
0
    def _setup_grep(self):
        """
        Setup the grep consumer:
            * Create a Queue,
            * Set the Queue in xurllib
            * Start the consumer
        """
        grep_plugins = self._w3af_core.plugins.plugins['grep']

        if grep_plugins:
            self._grep_consumer = grep(grep_plugins, self._w3af_core)
            self._w3af_core.uri_opener.set_grep_queue_put(self._grep_consumer.grep)
            self._grep_consumer.start()
Example #2
0
    def test_should_grep_speed(self):
        """
        This method tests the performance of the should_grep method

        This method is usually run as:

            kernprof -o nose.lprof -v -l nosetests -s -v w3af/core/controllers/core_helpers/consumers/tests/test_grep.py

        Remember to:

            * Specify a valid file in HTTP_FILE (generated during a scan)
            * Decorate the methods you want to analyze with @profile

        """
        if not os.path.exists(self.HTTP_FILE):
            return

        grep_plugins = [code_disclosure()]
        core = w3afCore()

        grep_consumer = grep(grep_plugins, core)

        for count, (request, response) in enumerate(
                iter_http_request_responses(self.HTTP_FILE)):

            if not cf.cf.get('target_domains'):
                cf.cf.save('target_domains', {request.get_uri().get_domain()})

            grep_consumer.should_grep(request, response)

            if count % self.CACHE_TEST_EVERY == 0:
                for _ in xrange(self.CACHE_TESTS):
                    grep_consumer.should_grep(request, response)

            if count >= self.MAX_REQUEST_RESPONSE:
                break