seed = schedule.choose(population) hits[seed.data] += 1 hits from html.parser import HTMLParser def my_parser(inp): parser = HTMLParser() parser.feed(inp) if __name__ == "__main__": runner = FunctionCoverageRunner(my_parser) runner.run("Hello World") cov = runner.coverage() list(cov)[:5] # Print 5 statements covered in HTMLParser import time import random if __name__ == "__main__": n = 5000 seed_input = " " # empty seed runner = FunctionCoverageRunner(my_parser) fuzzer = GreyboxFuzzer([seed_input], Mutator(), PowerSchedule()) start = time.time() fuzzer.runs(runner, trials=n)
if __package__ is None or __package__ == "": from MutationFuzzer import FunctionCoverageRunner else: from .MutationFuzzer import FunctionCoverageRunner def crashme(s): if len(s) > 0 and s[0] == 'b': if len(s) > 1 and s[1] == 'a': if len(s) > 2 and s[2] == 'd': if len(s) > 3 and s[3] == '!': raise Exception() crashme_runner = FunctionCoverageRunner(crashme) crashme_runner.run("good") list(crashme_runner.coverage()) # ## Blackbox, Greybox, and Boosted Greybox Fuzzing if __name__ == "__main__": print('\n## Blackbox, Greybox, and Boosted Greybox Fuzzing') if __package__ is None or __package__ == "": from Fuzzer import Fuzzer else: from .Fuzzer import Fuzzer class MutationFuzzer(Fuzzer): def __init__(self, seeds, mutator, schedule):