def _generate_fname(self, fuzzable_request):
        """
        Check the URL filenames
        :return: A list mutants.
        """
        url = fuzzable_request.get_url()
        fname_ext = url.get_file_name()
        splitted_fname_ext = fname_ext.split(".")

        if not len(splitted_fname_ext) == 2:
            return []

        name = splitted_fname_ext[0]

        wordnet_result = self._search_wn(name)

        # Given that we're going to be testing these as filenames, we're
        # going to remove the ones with spaces, since that's very strange
        # to find online
        wordnet_result = [word for word in wordnet_result if " " not in word]

        fuzzer_config = {}
        fuzzer_config["fuzz_url_filenames"] = True

        mutants = FileNameMutant.create_mutants(fuzzable_request, wordnet_result, [0], False, fuzzer_config)

        return mutants
Exemple #2
0
    def _generate_fname(self, fuzzable_request):
        """
        Check the URL filenames
        :return: A list mutants.
        """
        url = fuzzable_request.get_url()
        fname_ext = url.get_file_name()
        splitted_fname_ext = fname_ext.split('.')

        if not len(splitted_fname_ext) == 2:
            return []

        name = splitted_fname_ext[0]

        wordnet_result = self._search_wn(name)

        # Given that we're going to be testing these as filenames, we're
        # going to remove the ones with spaces, since that's very strange
        # to find online
        wordnet_result = [word for word in wordnet_result if ' ' not in word]

        fuzzer_config = {}
        fuzzer_config['fuzz_url_filenames'] = True

        mutants = FileNameMutant.create_mutants(fuzzable_request,
                                                wordnet_result, [
                                                    0,
                                                ], False, fuzzer_config)

        return mutants
    def test_basics(self):
        parts = URLPartsContainer('', 'ping!', '.htm')

        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar.htm'))
        m = FileNameMutant(freq)
        m.set_dc(parts)

        self.assertEqual(m.get_url().url_string,
                         u'http://www.w3af.com/foo/ping%21.htm')

        expected_found_at = '"http://www.w3af.com/foo/ping%21.htm", using HTTP'\
                            ' method GET. The modified parameter was the URL'\
                            ' filename, with value: "ping!".'
        generated_found_at = m.found_at()

        self.assertEqual(generated_found_at, expected_found_at)
Exemple #4
0
    def test_valid_results_double_encoding(self):
        """
        In this case the number of generated mutants is higher due to the
        encoded and double encoded versions which are returned. In the previous
        case, and given that both the encoded and double encoded versions were
        the same, the number of generated mutants was 4.
        """
        payloads = ['ls - la', 'http://127.0.0.1:8015/test/']
        freq = FuzzableRequest(URL('http://www.w3af.com/bar.htm'))

        generated_mutants = FileNameMutant.create_mutants(
            freq, payloads, [], False, self.fuzzer_config)

        expected_urls = [
            'http://www.w3af.com/ls+-+la.htm',
            'http://www.w3af.com/bar.ls+-+la',
            'http://www.w3af.com/http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F.htm',
            'http://www.w3af.com/http%3A//127.0.0.1%3A8015/test/.htm',
            'http://www.w3af.com/bar.http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F',
            'http://www.w3af.com/bar.http%3A//127.0.0.1%3A8015/test/'
        ]

        generated_urls = [m.get_url().url_string for m in generated_mutants]

        self.assertEqual(set(expected_urls), set(generated_urls))
Exemple #5
0
    def test_config_true(self):
        fuzzer_config = {'fuzz_url_filenames': True}
        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))

        generated_mutants = FileNameMutant.create_mutants(
            freq, self.payloads, [], False, fuzzer_config)

        self.assertNotEqual(len(generated_mutants), 0, generated_mutants)
    def test_config_true(self):
        fuzzer_config = {'fuzz_url_filenames': True}
        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))

        generated_mutants = FileNameMutant.create_mutants(freq, self.payloads,
                                                          [], False,
                                                          fuzzer_config)

        self.assertNotEqual(len(generated_mutants), 0, generated_mutants)
    def test_valid_results(self):
        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar.htm'))

        generated_mutants = FileNameMutant.create_mutants(freq, self.payloads,
                                                          [], False,
                                                          self.fuzzer_config)

        self.assertEqual(len(generated_mutants), 4, generated_mutants)

        expected_urls = [URL('http://www.w3af.com/foo/abc.htm'),
                         URL('http://www.w3af.com/foo/def.htm'),
                         URL('http://www.w3af.com/foo/bar.abc'),
                         URL('http://www.w3af.com/foo/bar.def')]

        generated_urls = [m.get_url() for m in generated_mutants]

        self.assertEqual(expected_urls, generated_urls)
Exemple #8
0
    def test_valid_results(self):
        freq = HTTPQSRequest(URL('http://www.w3af.com/foo/bar.htm'))

        generated_mutants = FileNameMutant.create_mutants(freq, self.payloads,
                                                          [], False,
                                                          self.fuzzer_config)

        self.assertEqual(len(generated_mutants), 4, generated_mutants)

        expected_urls = [URL('http://www.w3af.com/foo/abc.htm'),
                         URL('http://www.w3af.com/foo/def.htm'),
                         URL('http://www.w3af.com/foo/bar.abc'),
                         URL('http://www.w3af.com/foo/bar.def')]

        generated_urls = [m.get_url() for m in generated_mutants]

        self.assertEqual(expected_urls, generated_urls)
Exemple #9
0
    def test_basics(self):
        divided_path = DataContainer()
        divided_path['start'] = ''
        divided_path['modified_part'] = 'ping!'
        divided_path['end'] = '.htm'

        freq = HTTPQSRequest(URL('http://www.w3af.com/foo/bar.htm'))
        m = FileNameMutant(freq)
        m.set_mutant_dc(divided_path)
        m.set_var('modified_part')
        self.assertEqual(m.get_url().url_string,
                         u'http://www.w3af.com/foo/ping%21.htm')

        expected_mod_value = 'The sent url filename is: "ping!.htm".'
        generated_mod_value = m.print_mod_value()

        self.assertEqual(generated_mod_value, expected_mod_value)

        expected_found_at = '"http://www.w3af.com/foo/ping%21.htm", using HTTP'\
                            ' method GET. The modified parameter was the URL'\
                            ' filename, with value: "ping!".'
        generated_found_at = m.found_at()

        self.assertEqual(generated_found_at, expected_found_at)
Exemple #10
0
    def test_basics(self):
        parts = URLPartsContainer('', 'ping!', '.htm')

        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar.htm'))
        m = FileNameMutant(freq)
        m.set_dc(parts)

        self.assertEqual(m.get_url().url_string,
                         u'http://www.w3af.com/foo/ping%21.htm')

        expected_found_at = '"http://www.w3af.com/foo/ping%21.htm", using HTTP' \
                            ' method GET. The modified parameter was the URL' \
                            ' filename, with value: "ping!".'
        generated_found_at = m.found_at()

        self.assertEqual(generated_found_at, expected_found_at)
    def test_valid_results_double_encoding(self):
        """
        In this case the number of generated mutants is higher due to the
        encoded and double encoded versions which are returned. In the previous
        case, and given that both the encoded and double encoded versions were
        the same, the number of generated mutants was 4.
        """
        payloads = ['ls - la', 'http://127.0.0.1:8015/test/']
        freq = FuzzableRequest(URL('http://www.w3af.com/bar.htm'))

        generated_mutants = FileNameMutant.create_mutants(freq, payloads, [],
                                                          False,
                                                          self.fuzzer_config)

        expected_urls = ['http://www.w3af.com/ls+-+la.htm',
                         'http://www.w3af.com/bar.ls+-+la',
                         'http://www.w3af.com/http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F.htm',
                         'http://www.w3af.com/http%3A//127.0.0.1%3A8015/test/.htm',
                         'http://www.w3af.com/bar.http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F',
                         'http://www.w3af.com/bar.http%3A//127.0.0.1%3A8015/test/']

        generated_urls = [m.get_url().url_string for m in generated_mutants]
        
        self.assertEqual(set(expected_urls), set(generated_urls))