Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Dec 18, 2023
1 parent db6ac0c commit 9b68296
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 31 deletions.
File renamed without changes.
36 changes: 21 additions & 15 deletions fishpp_new_exp/fuzzer.py → fuzzers/fishpp_new_exp/fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,28 @@ def get_uninstrumented_build_directory(target_directory):
"""Return path to CmpLog target directory."""
return os.path.join(target_directory, 'uninstrumented')


def prepare_tmp_files(tmp_dir):
"""prepare tmp files"""
if not os.path.isdir(tmp_dir) or os.path.exists(tmp_dir):
os.mkdir(tmp_dir)
os.mkdir('%s/idlog' % (tmp_dir))
os.mkdir('%s/cg' % (tmp_dir))
os.mkdir('%s/fid' % (tmp_dir))
os.system('touch %s/idlog/fid %s/idlog/targid' % (tmp_dir, tmp_dir))
fua = tmp_dir + '/idlog'
fub = tmp_dir + '/cg'
fuc = tmp_dir + '/fid'
os.mkdir(fua)
os.mkdir(fub)
os.mkdir(fuc)
fud = 'touch ' + tmp_dir + '/idlog/fid ' + tmp_dir + '/idlog/targid'
os.system(fud)


def set_ff_env():
# set FishFuzz Env before build
"""set FishFuzz Env before build"""
os.environ['TMP_DIR'] = os.environ['OUT'] + '/TEMP'
os.environ['FF_TMP_DIR'] = os.environ['OUT'] + '/TEMP'
prepare_tmp_files(os.environ['TMP_DIR'])


def build(*args): # pylint: disable=too-many-branches,too-many-statements
"""Build benchmark."""
# BUILD_MODES is not already supported by fuzzbench, meanwhile we provide
Expand Down Expand Up @@ -173,7 +181,7 @@ def build(*args): # pylint: disable=too-many-branches,too-many-statements
if 'eclipser' in build_modes:
os.environ['FUZZER_LIB'] = '/libStandaloneFuzzTarget.a'
else:
os.environ['FUZZER_LIB'] = '/FishFuzz/afl_driver.o' # '/libAFLDriver.a'
os.environ['FUZZER_LIB'] = '/FishFuzz/afl_driver.o'

# Some benchmarks like lcms. (see:
# https://github.com/mm2/Little-CMS/commit/ab1093539b4287c233aca6a3cf53b234faceb792#diff-f0e6d05e72548974e852e8e55dffc4ccR212)
Expand Down Expand Up @@ -252,15 +260,12 @@ def build(*args): # pylint: disable=too-many-branches,too-many-statements
shutil.copy('/FishFuzz/afl-frida-trace.so', build_directory)
shutil.copy('/get_frida_entry.sh', build_directory)

tmp_dir_dst = os.environ['OUT'] + '/TEMP'
tmp_dst = os.environ['OUT'] + '/TEMP'
print('[post_build] generating distance files')
# python3 /Fish++/distance/match_function.py -i $FF_TMP_DIR
# python3 /Fish++/distance/merge_callgraph.py -i $FF_TMP_DIR
# python3 /Fish++/distance/calculate_distance.py -i $FF_TMP_DIR
os.system('python3 /FishFuzz/fish_mode/distance/match_function.py -i %s' % (tmp_dir_dst))
# os.system('python3 /FishFuzz/distance/merge_callgraph.py -i %s' % (tmp_dir_dst))
# os.system('python3 /FishFuzz/distance/calculate_distance.py -i %s' % (tmp_dir_dst))
os.system('python3 /FishFuzz/fish_mode/distance/calculate_all_distance.py -i %s' % (tmp_dir_dst))
xxa = 'python3 /FishFuzz/distance/match_function.py -i ' + tmp_dst
os.system(xxa)
xxb = 'python3 /FishFuzz/distance/calculate_all_distance.py -i ' + tmp_dst
os.system(xxb)


# pylint: disable=too-many-arguments
Expand Down Expand Up @@ -289,10 +294,11 @@ def fuzz(input_corpus,
if os.path.exists('./afl++.dict'):
flags += ['-x', './afl++.dict']

flags += ['-p', 'explore']

# Move the following to skip for upcoming _double tests:
if os.path.exists(cmplog_target_binary) and no_cmplog is False:
flags += ['-c', cmplog_target_binary]
flags += ['-p', 'explore']

#os.environ['AFL_IGNORE_TIMEOUTS'] = '1'
os.environ['AFL_IGNORE_UNKNOWN_ENVS'] = '1'
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,28 @@ def get_uninstrumented_build_directory(target_directory):
"""Return path to CmpLog target directory."""
return os.path.join(target_directory, 'uninstrumented')


def prepare_tmp_files(tmp_dir):
"""prepare tmp files"""
if not os.path.isdir(tmp_dir) or os.path.exists(tmp_dir):
os.mkdir(tmp_dir)
os.mkdir('%s/idlog' % (tmp_dir))
os.mkdir('%s/cg' % (tmp_dir))
os.mkdir('%s/fid' % (tmp_dir))
os.system('touch %s/idlog/fid %s/idlog/targid' % (tmp_dir, tmp_dir))
fua = tmp_dir + '/idlog'
fub = tmp_dir + '/cg'
fuc = tmp_dir + '/fid'
os.mkdir(fua)
os.mkdir(fub)
os.mkdir(fuc)
fud = 'touch ' + tmp_dir + '/idlog/fid ' + tmp_dir + '/idlog/targid'
os.system(fud)


def set_ff_env():
# set FishFuzz Env before build
"""set FishFuzz Env before build"""
os.environ['TMP_DIR'] = os.environ['OUT'] + '/TEMP'
os.environ['FF_TMP_DIR'] = os.environ['OUT'] + '/TEMP'
prepare_tmp_files(os.environ['TMP_DIR'])


def build(*args): # pylint: disable=too-many-branches,too-many-statements
"""Build benchmark."""
# BUILD_MODES is not already supported by fuzzbench, meanwhile we provide
Expand All @@ -58,7 +66,7 @@ def build(*args): # pylint: disable=too-many-branches,too-many-statements

# If nothing was set this is the default:
if not build_modes:
build_modes = ['tracepc']#, 'cmplog', 'dict2file']
build_modes = ['tracepc', 'dict2file']

# For bug type benchmarks we have to instrument via native clang pcguard :(
build_flags = os.environ['CFLAGS']
Expand Down Expand Up @@ -173,7 +181,7 @@ def build(*args): # pylint: disable=too-many-branches,too-many-statements
if 'eclipser' in build_modes:
os.environ['FUZZER_LIB'] = '/libStandaloneFuzzTarget.a'
else:
os.environ['FUZZER_LIB'] = '/FishFuzz/afl_driver.o' # '/libAFLDriver.a'
os.environ['FUZZER_LIB'] = '/FishFuzz/afl_driver.o'

# Some benchmarks like lcms. (see:
# https://github.com/mm2/Little-CMS/commit/ab1093539b4287c233aca6a3cf53b234faceb792#diff-f0e6d05e72548974e852e8e55dffc4ccR212)
Expand Down Expand Up @@ -252,15 +260,12 @@ def build(*args): # pylint: disable=too-many-branches,too-many-statements
shutil.copy('/FishFuzz/afl-frida-trace.so', build_directory)
shutil.copy('/get_frida_entry.sh', build_directory)

tmp_dir_dst = os.environ['OUT'] + '/TEMP'
tmp_dst = os.environ['OUT'] + '/TEMP'
print('[post_build] generating distance files')
# python3 /Fish++/distance/match_function.py -i $FF_TMP_DIR
# python3 /Fish++/distance/merge_callgraph.py -i $FF_TMP_DIR
# python3 /Fish++/distance/calculate_distance.py -i $FF_TMP_DIR
os.system('python3 /FishFuzz/fish_mode/distance/match_function.py -i %s' % (tmp_dir_dst))
# os.system('python3 /FishFuzz/distance/merge_callgraph.py -i %s' % (tmp_dir_dst))
# os.system('python3 /FishFuzz/distance/calculate_distance.py -i %s' % (tmp_dir_dst))
os.system('python3 /FishFuzz/fish_mode/distance/calculate_all_distance.py -i %s' % (tmp_dir_dst))
xxa = 'python3 /FishFuzz/distance/match_function.py -i ' + tmp_dst
os.system(xxa)
xxb = 'python3 /FishFuzz/distance/calculate_all_distance.py -i ' + tmp_dst
os.system(xxb)


# pylint: disable=too-many-arguments
Expand Down Expand Up @@ -289,10 +294,11 @@ def fuzz(input_corpus,
if os.path.exists('./afl++.dict'):
flags += ['-x', './afl++.dict']

flags += ['-p', 'explore']

# Move the following to skip for upcoming _double tests:
if os.path.exists(cmplog_target_binary) and no_cmplog is False:
flags += ['-c', cmplog_target_binary]
flags += ['-p', 'explore']

#os.environ['AFL_IGNORE_TIMEOUTS'] = '1'
os.environ['AFL_IGNORE_UNKNOWN_ENVS'] = '1'
Expand Down
File renamed without changes.

0 comments on commit 9b68296

Please sign in to comment.