Exemple #1
0
    def test_rand_number(self):
        x = rand_number(length=1)
        self.assertIn(int(x), range(10))

        x = rand_number( length=2 )
        self.assertIn(int(x), range(100))
    
        x = rand_number( length=3 )
        self.assertIn(int(x), range(1000))

        x = rand_number( length=5 )
        y = rand_number( length=5 )
        z = rand_number( length=5 )
        w = rand_number( length=5 )
        self.assertTrue(x != y != z != w)
Exemple #2
0
    def test_rand_number(self):
        x = rand_number(length=1)
        self.assertIn(int(x), range(10))

        x = rand_number(length=2)
        self.assertIn(int(x), range(100))

        x = rand_number(length=3)
        self.assertIn(int(x), range(1000))

        x = rand_number(length=5)
        y = rand_number(length=5)
        z = rand_number(length=5)
        w = rand_number(length=5)
        self.assertTrue(x != y != z != w)
Exemple #3
0
    def _get_limit_response(self, m):
        '''
        We request the limit (something that doesn't exist)
            - If http://localhost/a.php?b=1 ; then I should request b=12938795
                                                                 (random number)
            - If http://localhost/a.php?b=abc ; then I should request b=hnv98yks
                                                                    (random alnum)

        :return: The limit response object
        '''
        # Copy the dc, needed to make a good vuln report
        dc = copy.deepcopy(m.get_dc())

        if m.get_original_value().isdigit():
            m.set_mod_value(rand_number(length=8))
        else:
            m.set_mod_value(rand_alnum(length=8))
        limit_response = self._uri_opener.send_mutant(m)

        # restore the dc
        m.set_dc(dc)
        return limit_response
Exemple #4
0
    def _get_limit_response(self, m):
        '''
        We request the limit (something that doesn't exist)
            - If http://localhost/a.php?b=1 ; then I should request b=12938795
                                                                 (random number)
            - If http://localhost/a.php?b=abc ; then I should request b=hnv98yks
                                                                    (random alnum)

        :return: The limit response object
        '''
        # Copy the dc, needed to make a good vuln report
        dc = copy.deepcopy(m.get_dc())

        if m.get_original_value().isdigit():
            m.set_mod_value(rand_number(length=8))
        else:
            m.set_mod_value(rand_alnum(length=8))
        limit_response = self._uri_opener.send_mutant(m)

        # restore the dc
        m.set_dc(dc)
        return limit_response
    def _get_statements(self, mutant, exclude_numbers=[]):
        '''
        Returns a list of statement tuples.
        '''
        res = {}
        rnd_num = int(rand_number(2, exclude_numbers))
        rnd_num_plus_one = rnd_num + 1

        # Numeric/Datetime
        true_stm = '%i OR %i=%i ' % (rnd_num, rnd_num, rnd_num)
        false_stm = '%i AND %i=%i ' % (rnd_num, rnd_num, rnd_num_plus_one)
        res['numeric'] = (true_stm, false_stm)

        # Single quotes
        true_stm = "%i' OR '%i'='%i" % (rnd_num, rnd_num, rnd_num)
        false_stm = "%i' AND '%i'='%i" % (rnd_num, rnd_num, rnd_num_plus_one)
        res['stringsingle'] = (true_stm, false_stm)

        # Double quotes
        true_stm = '%i" OR "%i"="%i' % (rnd_num, rnd_num, rnd_num)
        false_stm = '%i" AND "%i"="%i' % (rnd_num, rnd_num, rnd_num_plus_one)
        res['stringdouble'] = (true_stm, false_stm)

        return res
    def _get_statements(self, mutant, exclude_numbers=[]):
        '''
        Returns a list of statement tuples.
        '''
        res = {}
        rnd_num = int(rand_number(2, exclude_numbers))
        rnd_num_plus_one = rnd_num + 1

        # Numeric/Datetime
        true_stm = '%i OR %i=%i ' % (rnd_num, rnd_num, rnd_num)
        false_stm = '%i AND %i=%i ' % (rnd_num, rnd_num, rnd_num_plus_one)
        res['numeric'] = (true_stm, false_stm)

        # Single quotes
        true_stm = "%i' OR '%i'='%i" % (rnd_num, rnd_num, rnd_num)
        false_stm = "%i' AND '%i'='%i" % (rnd_num, rnd_num, rnd_num_plus_one)
        res['stringsingle'] = (true_stm, false_stm)

        # Double quotes
        true_stm = '%i" OR "%i"="%i' % (rnd_num, rnd_num, rnd_num)
        false_stm = '%i" AND "%i"="%i' % (rnd_num, rnd_num, rnd_num_plus_one)
        res['stringdouble'] = (true_stm, false_stm)

        return res