From 22b56f88e9a69ca38dc5a7f621fc78ad1c7d933c Mon Sep 17 00:00:00 2001 From: Neil Zhao Date: Sun, 10 Jun 2018 11:28:58 +0000 Subject: [PATCH 1/2] change bomb_ending to 3 --- include/a_tester.h | 2 +- script/angr_run.py | 2 +- script/klee_run.py | 2 +- script/klee_run_cpp.py | 48 ----------------------------------------- script/triton_caller.py | 2 +- 5 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 script/klee_run_cpp.py diff --git a/include/a_tester.h b/include/a_tester.h index c009433..92d9077 100644 --- a/include/a_tester.h +++ b/include/a_tester.h @@ -1,4 +1,4 @@ #pragma once -#define BOMB_ENDING 1 +#define BOMB_ENDING 3 #define NORMAL_ENDING 0 diff --git a/script/angr_run.py b/script/angr_run.py index 4cdf104..975bfc3 100644 --- a/script/angr_run.py +++ b/script/angr_run.py @@ -123,7 +123,7 @@ def run_symexe(path, argv_size=2, show_bytes=True, show_model=False): else: color = 'red' - if 1 in tests: + if 3 in tests: exit(1) elif errored or 139 in tests: exit(-1) diff --git a/script/klee_run.py b/script/klee_run.py index f30b6b5..636efed 100644 --- a/script/klee_run.py +++ b/script/klee_run.py @@ -40,7 +40,7 @@ tests = running_res -if 1 in tests: +if 3 in tests: exit(1) elif 139 in tests: exit(-1) diff --git a/script/klee_run_cpp.py b/script/klee_run_cpp.py deleted file mode 100644 index b8d7cec..0000000 --- a/script/klee_run_cpp.py +++ /dev/null @@ -1,48 +0,0 @@ -import sys -import os -from termcolor import colored -from subprocess import Popen, call, PIPE -import argparse - - -os.environ['LD_LIBRARY_PATH'] = '/home/klee/klee_build/klee/lib/:$LD_LIBRARY_PAT' -lib_path = '/home/klee/klee_build/klee/lib/' - -parser = argparse.ArgumentParser() -parser.add_argument("-e", "--expected", type=int, help="Expected amount of results") -args = parser.parse_args() -print(colored('[+] Compiling ...', 'green')) - -# os.system('sh /home/klee/ConcTrignr/klee/run_program.sh') -cmd = 'clang++ -Iinclude -L ' + lib_path + ' -Lbuild -o klee/a.out klee/a.c -lkleeRuntest -lpthread -lutils -lcrypto -lm' -p = Popen(cmd.split(' ')) -rt_value = p.wait() -if rt_value != 0: - exit(3) - -running_res = set() -for file in os.listdir(os.path.join('klee', 'klee-last')): - if file.endswith('.ktest'): - # show = 'ktest-tool --write-ints klee/klee-last/%s' % file - # os.system(show) - cmd = 'KTEST_FILE=klee/klee-last/%s' % file - res = os.system(cmd + ' klee/a.out') >> 8 - running_res.add(res) - -tests = running_res -# print(tests) -# if args.expected is None: -# standard = {0, 1} -# elif args.expected == 2: -# standard = {0, 1} -# elif args.expected == 1: -# standard = {0, } -# else: -# exit(-1) - -if 1 in tests: - exit(1) -elif 139 in tests: - exit(-1) -else: - exit(0) diff --git a/script/triton_caller.py b/script/triton_caller.py index 5cc55e6..8b1e4f5 100644 --- a/script/triton_caller.py +++ b/script/triton_caller.py @@ -111,7 +111,7 @@ else: exit(-1) -if 1 in tests: +if 3 in tests: exit(1) elif 139 in tests: exit(-1) From c67dd9dd0e35ac720ec09b45780265f1bcceb967 Mon Sep 17 00:00:00 2001 From: Neil Zhao Date: Sun, 10 Jun 2018 11:32:23 +0000 Subject: [PATCH 2/2] add overide root dir option --- run_tests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run_tests.py b/run_tests.py index 4ad5fba..9c23509 100644 --- a/run_tests.py +++ b/run_tests.py @@ -17,7 +17,7 @@ def kill_all(process): parent.kill() -def ATKrun(target, func_name='logic_bomb', default_stdin_len=10, maxtime=60, source=None, skip=False): +def ATKrun(target, func_name='logic_bomb', default_stdin_len=10, maxtime=60, source=None, skip=False, folder=None): def params_list_parser(params): if len(params.strip()) == 0: return [] @@ -37,6 +37,8 @@ def params_list_parser(params): return res cmds_tp, tp_path, prefix, src_dirs = target + if folder: + src_dirs = (folder, ) if not os.path.exists(prefix): os.mkdir(prefix) @@ -188,13 +190,14 @@ def params_list_parser(params): parser.add_argument("-t", "--maxtime", required=False, default=60, type=int, help="Max running time for a program") parser.add_argument("-s", "--source", required=False, type=str, help="Output source code into a directory") parser.add_argument("-n", "--no_test", action="store_true", help="Don't do the test") + parser.add_argument("-f", "--folder", type=str, help="Overide test dir in config") args = parser.parse_args() if args.source: print("Saving output results in ", args.source) try: - res = ATKrun(switches[args.engine], func_name=FUNC_NAME, maxtime=args.maxtime, source=args.source, skip=args.no_test) + res = ATKrun(switches[args.engine], func_name=FUNC_NAME, maxtime=args.maxtime, source=args.source, skip=args.no_test, folder=args.folder) if args.source and args.no_test: exit(0) except KeyError: