Пример #1
0
    def test_basics(self):
        divided_path = DataContainer()
        divided_path["start"] = "/"
        divided_path["modified_part"] = "ping!"
        divided_path["end"] = "/bar"

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

        expected_mod_value = 'The sent urlparts is: "/ping!/bar".'
        generated_mod_value = m.print_mod_value()

        self.assertEqual(generated_mod_value, expected_mod_value)

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

        self.assertEqual(generated_found_at, expected_found_at)
Пример #2
0
    def test_basics(self):
        divided_path = URLPartsContainer('/', 'ping!', '/bar')

        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))
        m = URLPartsMutant(freq)
        m.set_dc(divided_path)
        self.assertEqual(m.get_url().url_string,
                         u'http://www.w3af.com/ping%21/bar')

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

        self.assertEqual(generated_found_at, expected_found_at)
Пример #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', 'ping 127.0.0.1 -c 5',
                    'http://127.0.0.1:8015/test/']
        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))

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

        expected_urls = ['http://www.w3af.com/ls+-+la/bar',
                         'http://www.w3af.com/ls%2B-%2Bla/bar',
                         'http://www.w3af.com/ping+127.0.0.1+-c+5/bar',
                         'http://www.w3af.com/ping%2B127.0.0.1%2B-c%2B5/bar',
                         'http://www.w3af.com/foo/ls+-+la',
                         'http://www.w3af.com/foo/ls%2B-%2Bla',
                         'http://www.w3af.com/foo/ping+127.0.0.1+-c+5',
                         'http://www.w3af.com/foo/ping%2B127.0.0.1%2B-c%2B5',
                         'http://www.w3af.com/http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F/bar',
                         'http://www.w3af.com/http%253A%252F%252F127.0.0.1%253A8015%252Ftest%252F/bar',
                         'http://www.w3af.com/foo/http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F',
                         'http://www.w3af.com/foo/http%253A%252F%252F127.0.0.1%253A8015%252Ftest%252F']

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

        self.assertEqual(set(expected_urls), generated_urls)
Пример #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', 'ping 127.0.0.1 -c 5', 'http://127.0.0.1:8015/test/'
        ]
        freq = HTTPQSRequest(URL('http://www.w3af.com/foo/bar'))

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

        expected_urls = [
            'http://www.w3af.com/ls+-+la/bar',
            'http://www.w3af.com/ls%2B-%2Bla/bar',
            'http://www.w3af.com/ping+127.0.0.1+-c+5/bar',
            'http://www.w3af.com/ping%2B127.0.0.1%2B-c%2B5/bar',
            'http://www.w3af.com/foo/ls+-+la',
            'http://www.w3af.com/foo/ls%2B-%2Bla',
            'http://www.w3af.com/foo/ping+127.0.0.1+-c+5',
            'http://www.w3af.com/foo/ping%2B127.0.0.1%2B-c%2B5',
            'http://www.w3af.com/http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F/bar',
            'http://www.w3af.com/http%253A%252F%252F127.0.0.1%253A8015%252Ftest%252F/bar',
            'http://www.w3af.com/foo/http%3A%2F%2F127.0.0.1%3A8015%2Ftest%2F',
            'http://www.w3af.com/foo/http%253A%252F%252F127.0.0.1%253A8015%252Ftest%252F'
        ]

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

        self.assertEqual(set(expected_urls), generated_urls)
Пример #5
0
    def test_config_true(self):
        fuzzer_config = {"fuzz_url_parts": True}
        freq = HTTPQSRequest(URL("http://www.w3af.com/foo/bar"))

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

        self.assertNotEqual(len(generated_mutants), 0, generated_mutants)
Пример #6
0
    def test_config_true(self):
        fuzzer_config = {'fuzz_url_parts': True}
        freq = HTTPQSRequest(URL('http://www.w3af.com/foo/bar'))

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

        self.assertNotEqual(len(generated_mutants), 0, generated_mutants)
Пример #7
0
    def test_config_false(self):
        fuzzer_config = {'fuzz_url_parts': False}
        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))

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

        self.assertEqual(len(generated_mutants), 0, generated_mutants)
Пример #8
0
    def test_valid_results(self):
        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))

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

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

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

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

        self.assertEqual(expected_urls, generated_urls)
Пример #9
0
    def test_valid_results(self):
        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))

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

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

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

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

        self.assertEqual(expected_urls, generated_urls)
Пример #10
0
    def test_basics(self):
        divided_path = DataContainer()
        divided_path['start'] = '/'
        divided_path['modified_part'] = 'ping!'
        divided_path['end'] = '/bar'

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

        expected_mod_value = 'The sent urlparts is: "/ping!/bar".'
        generated_mod_value = m.print_mod_value()

        self.assertEqual(generated_mod_value, expected_mod_value)

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

        self.assertEqual(generated_found_at, expected_found_at)
Пример #11
0
    def test_forced_url_parts(self):
        freq = FuzzableRequest(URL('http://www.w3af.com/static/foo/bar.ext'))
        freq.set_force_fuzzing_url_parts([('/static/', False), ('foo', True),
                                          ('/bar.', False), ('ext', True)])

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

        expected_urls = [
            'http://www.w3af.com/static/abc/bar.ext',
            'http://www.w3af.com/static/def/bar.ext',
            'http://www.w3af.com/static/foo/bar.abc',
            'http://www.w3af.com/static/foo/bar.def'
        ]

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

        self.assertEqual(set(expected_urls), generated_urls)
Пример #12
0
    def test_basics(self):
        divided_path = URLPartsContainer('/', 'ping!', '/bar')

        freq = FuzzableRequest(URL('http://www.w3af.com/foo/bar'))
        m = URLPartsMutant(freq)
        m.set_dc(divided_path)
        self.assertEqual(m.get_url().url_string,
                         u'http://www.w3af.com/ping%21/bar')

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

        self.assertEqual(generated_found_at, expected_found_at)
Пример #13
0
 def __init__(self, freq):
     URLPartsMutant.__init__(self, freq)
 def __init__(self, freq):
     URLPartsMutant.__init__(self, freq)