Beispiel #1
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
Beispiel #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
Beispiel #3
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',
        ]
        freq = HTTPQSRequest(URL('http://www.w3af.com/bar.htm'))

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

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

        expected_urls = [
            'http://www.w3af.com/ls+-+la.htm',
            'http://www.w3af.com/bar.ls+-+la'
        ]

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

        self.assertEqual(expected_urls, generated_urls)
Beispiel #4
0
    def test_config_true(self):
        fuzzer_config = {'fuzz_url_filenames': True}
        freq = HTTPQSRequest(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 = HTTPQSRequest(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 = 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)
Beispiel #7
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)
Beispiel #8
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)
    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', ]
        freq = HTTPQSRequest(URL('http://www.w3af.com/bar.htm'))

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

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

        expected_urls = ['http://www.w3af.com/ls+-+la.htm',
                         'http://www.w3af.com/bar.ls+-+la']

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

        self.assertEqual(expected_urls, generated_urls)
    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)