예제 #1
0
import re

class MysteryRunner(Runner):
    def run(self, inp):
        x = inp.find(chr(0o17 + 0o31))
        y = inp.find(chr(0o27 + 0o22))
        if x >= 0 and y >= 0 and x < y:
            return (inp, Runner.FAIL)
        else:
            return (inp, Runner.PASS)

if __name__ == "__main__":
    mystery = MysteryRunner()
    random_fuzzer = RandomFuzzer()
    while True:
        inp = random_fuzzer.fuzz()
        result, outcome = mystery.run(inp)
        if outcome == mystery.FAIL:
            break


if __name__ == "__main__":
    failing_input = result
    failing_input


# ## Manual Input Reduction

if __name__ == "__main__":
    print('\n## Manual Input Reduction')
예제 #2
0
        parser = HTMLParser(
        )  # resets the HTMLParser object for every fuzz input
        parser.feed(inp)


if __name__ == "__main__":
    # create random fuzzer
    fuzzer = RandomFuzzer(min_length=1,
                          max_length=100,
                          char_start=32,
                          char_range=94)

    # create population of fuzz inputs
    population = []
    for i in range(trials):
        population.append(fuzzer.fuzz())

    # execute and measure trace coverage
    trace_timeseries = population_trace_coverage(population, my_parser)[1]

    # execute and measure code coverage
    code_timeseries = population_coverage(population, my_parser)[1]

    # plot trace coverage over time
    plt.figure(num=None, figsize=(12, 4), dpi=80, facecolor='w', edgecolor='k')
    plt.subplot(1, 2, 1)
    plt.plot(trace_timeseries)
    plt.xlabel('# of fuzz inputs')
    plt.ylabel('# of traces exercised')
    plt.title('Trace Coverage Over Time')