コード例 #1
0
 def __init__(self, enigma):
     self.enigma = enigma
     self.enigma.reset()
     self.enigma_fuzzer = RandomFuzzer(min_length=3,
                                       max_length=3,
                                       char_start=65,
                                       char_range=26)
コード例 #2
0
class BletchleyPark(object):
    def __init__(self, enigma):
        self.enigma = enigma
        self.enigma.reset()
        self.enigma_fuzzer = RandomFuzzer(min_length=3,
                                          max_length=3,
                                          char_start=65,
                                          char_range=26)

    def break_message(self, message):
        """Returning the trigram for an encoded message"""
        self.enigma.cur_msg = message
        while True:
            (trigram, outcome) = self.enigma_fuzzer.run(self.enigma)
            if outcome == self.enigma.PASS:
                break
        return trigram
コード例 #3
0
ファイル: Reducer.py プロジェクト: Ilyushin/fuzzingbook

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__":
コード例 #4
0
if __name__ == "__main__":
    trials = 50000  # number of random inputs generated

if __name__ == "__main__":
    # create wrapper function
    def my_parser(inp):
        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')