def _test_fuzz(self, inputlen=1000, iterations=100, rangelist=None):
        _input = bytearray('A' * inputlen)
        # sub in null chars
        chars_inserted = 0
        for i in xrange(0, inputlen, 10):
            _input[i] = 0x0D
            chars_inserted += 1

        for i in xrange(iterations):
            fuzzed = fuzz(fuzz_input=copy.copy(_input),
                                seed_val=0,
                                jump_idx=i,
                                ratio_min=0.1,
                                ratio_max=0.3,
                                range_list=rangelist,
                                fuzzable_chars=[0x0D]
                              )
            self.assertEqual(inputlen, len(fuzzed))
            self.assertNotEqual(_input, fuzzed)
            hd = bytewise_hd(_input, fuzzed)

            self.assertGreater(hd, 0)
            self.assertLessEqual(hd, chars_inserted)

            actual_ratio = hd / float(chars_inserted)
            self.assertGreaterEqual(actual_ratio, 0.1)
            self.assertLessEqual(actual_ratio, 0.3)
Esempio n. 2
0
    def test_fuzz_rangelist(self):
        inputlen = 10000
        iterations = 100
        r = [(0, 100), (600, 1000), (3000, 10000)]
        _input, chars_inserted = _insert_crlf(bytearray('A' * inputlen))

        for i in xrange(iterations):
            fuzzed = fuzz(
                fuzz_input=copy.copy(_input),
                seed_val=0,
                jump_idx=i,
                ratio_min=0.1,
                ratio_max=0.3,
                range_list=r,
                fuzzable_chars=[0x0D],
            )
            self.assertEqual(inputlen, len(fuzzed))
            self.assertNotEqual(_input, fuzzed)

            for (a, b) in r:
                # make sure we didn't change the exclude ranges
                self.assertEqual(_input[a:b + 1], fuzzed[a:b + 1])

            hd = bytewise_hd(_input, fuzzed)

            self.assertGreater(hd, 0)
            self.assertLess(hd, chars_inserted)

            # we excluded all but 2500 bytes in r above
            actual_ratio = hd / 2500.0
            self.assertGreaterEqual(actual_ratio, 0.01)
            self.assertLessEqual(actual_ratio, 0.03)
Esempio n. 3
0
    def test_fuzz_rangelist(self):
        inputlen = 10000
        iterations = 100
        r = [(0, 100), (600, 1000), (3000, 10000)]
        _input, chars_inserted = _insert_crlf(bytearray('A' * inputlen))

        for i in xrange(iterations):
            fuzzed = fuzz(fuzz_input=copy.copy(_input),
                                seed_val=0,
                                jump_idx=i,
                                ratio_min=0.1,
                                ratio_max=0.3,
                                range_list=r,
                                fuzzable_chars=[0x0D],
                              )
            self.assertEqual(inputlen, len(fuzzed))
            self.assertNotEqual(_input, fuzzed)

            for (a, b) in r:
                # make sure we didn't change the exclude ranges
                self.assertEqual(_input[a:b + 1], fuzzed[a:b + 1])

            hd = bytewise_hd(_input, fuzzed)

            self.assertGreater(hd, 0)
            self.assertLess(hd, chars_inserted)

            # we excluded all but 2500 bytes in r above
            actual_ratio = hd / 2500.0
            self.assertGreaterEqual(actual_ratio, 0.01)
            self.assertLessEqual(actual_ratio, 0.03)
    def _test_fuzz(self, inputlen=1000, iterations=100, rangelist=None):
        _input = bytearray('A' * inputlen)
        # sub in null chars
        chars_inserted = 0
        for i in xrange(0, inputlen, 10):
            _input[i] = 0x0D
            chars_inserted += 1

        for i in xrange(iterations):
            fuzzed = fuzz(fuzz_input=copy.copy(_input),
                          seed_val=0,
                          jump_idx=i,
                          ratio_min=0.1,
                          ratio_max=0.3,
                          range_list=rangelist,
                          fuzzable_chars=[0x0D])
            self.assertEqual(inputlen, len(fuzzed))
            self.assertNotEqual(_input, fuzzed)
            hd = bytewise_hd(_input, fuzzed)

            self.assertGreater(hd, 0)
            self.assertLessEqual(hd, chars_inserted)

            actual_ratio = hd / float(chars_inserted)
            self.assertGreaterEqual(actual_ratio, 0.1)
            self.assertLessEqual(actual_ratio, 0.3)
Esempio n. 5
0
    def test_fuzz_rangelist(self):
        inputlen = 10000
        iterations = 100
        r = [(0, 100), (600, 1000), (3000, 10000)]
        for i in xrange(iterations):
            fuzzed = fuzz(
                fuzz_input=_input(inputlen),
                seed_val=0,
                jump_idx=i,
                ratio_min=0.1,
                ratio_max=0.3,
                range_list=r,
            )
            self.assertEqual(inputlen, len(fuzzed))
            self._fail_if_not_fuzzed(fuzzed)

            for (a, b) in r:
                # make sure we didn't change the exclude ranges
                self.assertEqual(_input(inputlen)[a:b + 1], fuzzed[a:b + 1])

            hd = bytewise_hd(_input(inputlen), fuzzed)

            self.assertGreater(hd, 0)
            self.assertLess(hd, inputlen)

            # we excluded all but 2500 bytes in r above
            actual_ratio = hd / 2500.0
            self.assertGreaterEqual(actual_ratio, 0.1)
            self.assertLessEqual(actual_ratio, 0.3)
    def test_fuzz_rangelist(self):
        inputlen = 10000
        iterations = 100
        r = [(0, 100), (600, 1000), (3000, 10000)]
        for i in xrange(iterations):
            fuzzed = fuzz(fuzz_input=_input(inputlen),
                                seed_val=0,
                                jump_idx=i,
                                ratio_min=0.1,
                                ratio_max=0.3,
                                range_list=r,
                              )
            self.assertEqual(inputlen, len(fuzzed))
            self._fail_if_not_fuzzed(fuzzed)

            for (a, b) in r:
                # make sure we didn't change the exclude ranges
                self.assertEqual(_input(inputlen)[a:b + 1], fuzzed[a:b + 1])

            hd = bytewise_hd(_input(inputlen), fuzzed)

            self.assertGreater(hd, 0)
            self.assertLess(hd, inputlen)

            # we excluded all but 2500 bytes in r above
            actual_ratio = hd / 2500.0
            self.assertGreaterEqual(actual_ratio, 0.1)
            self.assertLessEqual(actual_ratio, 0.3)
Esempio n. 7
0
    def _test_fuzz(self, inputlen=1000, iterations=100, rangelist=None):
        for i in xrange(iterations):
            fuzzed = fuzz(fuzz_input=_input(inputlen),
                                seed_val=0,
                                jump_idx=i,
                                ratio_min=0.1,
                                ratio_max=0.3,
                                range_list=rangelist,
                              )
            self.assertEqual(inputlen, len(fuzzed))
            self._fail_if_not_fuzzed(fuzzed)

            hd = bytewise_hd(_input(inputlen), fuzzed)

            self.assertGreater(hd, 0)
            self.assertLess(hd, inputlen)

            actual_ratio = hd / float(inputlen)
            self.assertGreaterEqual(actual_ratio, 0.1)
            self.assertLessEqual(actual_ratio, 0.3)