Exemplo n.º 1
0
def check_reached(problem, problemset, rers_basepath, afl_basepath):
    rers_path = f"{rers_basepath}/{problemset}/{problem}/{problem}.so"
    afl_dir = f'{afl_basepath}/{problemset}/{problem}'
    bin_path = f'{afl_basepath}/{problemset}/{problem}/{problem}'

    sul = RERSSOConnector(rers_path)

    aflutils = AFLUtils(afl_dir, bin_path,
                        [str(x) for x in sul.get_alphabet()], sul)

    reached = [
        int(re.sub('error_', '', x)) for x in aflutils.gather_reached_errors()
    ]

    reachable, unreachable = parse_csv(
        Path(rers_path).parent.joinpath(
            f'reachability-solution-{problem}.csv'))

    print("Reached:", set(reached))
    print("Not reached:", set(reached).symmetric_difference(set(reachable)))
    print(f'{len(set(reached))}/{len(set(reachable))}')
Exemplo n.º 2
0
        assert og_output == new_output
        assert 'error' in og_output

        return trimmed_trace


if __name__ == "__main__":
    problem = "Problem12"
    problemset = "TrainingSeqReachRers2019"

    path = f"/home/tom/projects/lstar/rers/{problemset}/{problem}/{problem}.so"

    sul = RERSSOConnector(path)

    afl_dir = f'/home/tom/projects/lstar/afl/{problemset}/{problem}'
    bin_path = f'/home/tom/projects/lstar/afl/{problemset}/{problem}/{problem}'

    aflutils = AFLUtils(afl_dir, bin_path,
                        [str(x) for x in sul.get_alphabet()], sul)

    reached = [
        int(re.sub('error_', '', x)) for x in aflutils.gather_reached_errors()
    ]

    reachable, unreachable = parse_csv(
        Path(path).parent.joinpath(f'reachability-solution-{problem}.csv'))

    print("Reached:", set(reached))
    print("Not reached:", set(reached).symmetric_difference(set(reachable)))
Exemplo n.º 3
0
for i in tqdm(range(100)):

    simgr.explore(
        find=lambda s: b"error" in s.posix.dumps(2),
        avoid=lambda s: b"Invalid" in s.posix.dumps(2),
    )

    print("ACTIVE")
    for a in simgr.active:
        print(a.posix.dumps(0), a.posix.dumps(1), a.posix.dumps(2))

    print("FOUND")
    for a in simgr.found:
        print(a.posix.dumps(0), a.posix.dumps(1), a.posix.dumps(2))

    # print(["AVOID"])
    # for a in simgr.avoid:
    #     print(a.posix.dumps(0), a.posix.dumps(1), a.posix.dumps(2))

result = set([a.posix.dumps(2).decode() for a in simgr.found])
reached = set([int(re.search('[0-9]+', r).group(0)) for r in result])

from rers.check_result import parse_csv
reachable, unreachable = parse_csv(
    'rers/TrainingSeqReachRers2019/Problem12/reachability-solution-Problem12.csv'
)
if len(reachable.difference(reached)) > 0:
    print("Not reached", reachable - reached)
    print("Falsely reached", reached - reachable)
else:
    print("Success")
Exemplo n.º 4
0
problems = [f'Problem{x}' for x in range(18, 19)]
problemset = "SeqReachabilityRers2019"

rers_basepath = "/home/tom/projects/lstar/rers"
fuzzer_basepath = "/home/tom/afl/libfuzz"

for problem in problems:

    answers_path = Path(rers_basepath)\
                        .joinpath(problemset)\
                        .joinpath(problem)\
                        .joinpath(f'constraints-solution-{problem}.txt')

    assert answers_path.exists()

    reachable, unreachable = parse_csv(answers_path)

    print(problem)
    errors = check_reached(problem, problemset, rers_basepath, fuzzer_basepath)
    print(f"Reached {len(errors)}/{len(reachable)}")
    if len(errors) != len(reachable):
        print(f"Missing: {reachable.symmetric_difference(errors)}")
    print(len(errors))

    result_dir = Path(f'results/{problemset}')
    result_dir.mkdir(exist_ok=True, parents=True)

    problem_number = problem.replace('Problem', '')

    with result_dir.joinpath(f'{problem}_tcatshoek.csv').open('w') as f:
        for error in sorted(errors, key=lambda x: int(x)):
Exemplo n.º 5
0
    )

    print("ACTIVE")
    for a in simgr.active:
        print(a.posix.dumps(0), a.posix.dumps(1), a.posix.dumps(2))

    print("FOUND")
    for a in simgr.found:
        print(a.posix.dumps(0), a.posix.dumps(1), a.posix.dumps(2))

    print("AVOID")
    for a in simgr.avoid:
        print(a.posix.dumps(0), a.posix.dumps(1), a.posix.dumps(2))

# Decode the results
result = set([a.posix.dumps(2).decode() for a in simgr.found])
reached = set([int(re.search('[0-9]+', r).group(0)) for r in result])

# And check how well we did on the RERS problems
from rers.check_result import parse_csv
reachable, unreachable = parse_csv(
    f'rers/{problemset}/{problem}/reachability-solution-{problem}.csv')

print("\nRESULTS:")
print(f"Reached {len(reached)}/{len(reachable)} errors")

if len(reachable.difference(reached)) > 0:
    print("Not reached", reachable - reached)
    print("Falsely reached", reached - reachable)
else:
    print("Success")