Exemple #1
0
def main():
    logger = logging.getLogger()
    hdlr = logging.StreamHandler()
    logger.addHandler(hdlr)

    parser = argparse.ArgumentParser()
    group = parser.add_mutually_exclusive_group()
    group.add_argument('--debug', help='', action='store_true')
    group.add_argument('-v', '--verbose', help='', action='store_true')
    parser.add_argument('searchstring',
                        type=str,
                        help='The string to enumerate')
    parser.add_argument('fuzzedfile',
                        help='Path to a fuzzedfile',
                        type=str)

    args = parser.parse_args()

    if args.debug:
        logger.setLevel(logging.DEBUG)
    elif args.verbose:
        logger.setLevel(logging.INFO)
    else:
        logger.setLevel(logging.WARNING)

    enumerate_string(path=args.fuzzedfile, str_to_enum=args.searchstring)
Exemple #2
0
    def test_enumerate_string(self):
        (fd, f) = tempfile.mkstemp(suffix='.foo', dir=self.tempdir)
        os.write(fd, 'AAAAxxxAAAAxxxxxAAAAxAAAA')
        os.close(fd)
        root, ext = os.path.splitext(f)
        expected_newpath = '{}-enum{}'.format(root, ext)

        newpath = text.enumerate_string(f, 'AAAA')
        self.assertTrue(newpath.endswith('-enum.foo'))

        self.assertEqual(expected_newpath, newpath)
        self.assertTrue(os.path.exists(expected_newpath))

        with open(newpath, 'rb') as fp:
            content = fp.read()
            self.assertEqual('0AAAxxx1AAAxxxxx2AAAx3AAA', content)
        os.remove(newpath)
        os.remove(f)
    def test_enumerate_string(self):
        (fd, f) = tempfile.mkstemp(suffix='.foo', dir=self.tempdir)
        os.write(fd, 'AAAAxxxAAAAxxxxxAAAAxAAAA')
        os.close(fd)
        root, ext = os.path.splitext(f)
        expected_newpath = '{}-enum{}'.format(root, ext)

        newpath = text.enumerate_string(f, 'AAAA')
        self.assertTrue(newpath.endswith('-enum.foo'))

        self.assertEqual(expected_newpath, newpath)
        self.assertTrue(os.path.exists(expected_newpath))

        with open(newpath, 'rb') as fp:
            content = fp.read()
            self.assertEqual('0AAAxxx1AAAxxxxx2AAAx3AAA', content)
        os.remove(newpath)
        os.remove(f)