This commit is contained in:
vanhauser-thc
2021-12-26 01:05:07 +01:00
parent 8217b5ff81
commit 24dd35ef96
4 changed files with 15 additions and 12 deletions

View File

@ -31,7 +31,7 @@ jobs:
macos: macos:
runs-on: macOS-latest runs-on: macOS-latest
env: env:
AFL_MAP_SIZE: 4000 AFL_MAP_SIZE: 65536
AFL_SKIP_CPUFREQ: 1 AFL_SKIP_CPUFREQ: 1
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -39,9 +39,11 @@ jobs:
run: echo AFL_MAP_SIZE=$AFL_MAP_SIZE run: echo AFL_MAP_SIZE=$AFL_MAP_SIZE
- name: install - name: install
run: brew install make run: brew install make
- name: fix install
run: cd /usr/local/bin; ln -s gcc-* gcc; ln -s g++-* g++; which gcc; gcc -v
- name: build - name: build
run: export CC=/usr/local/Cellar/llvm/*/bin/clang; export CXX="$CC"++; export LLVM_CONFIG=/usr/local/Cellar/llvm/*/bin/llvm-config; gmake ASAN_BUILD=1 run: export PATH=/usr/local/Cellar/llvm/*/":$PATH"; export CC=/usr/local/Cellar/llvm/*/bin/clang; export CXX="$CC"++; export LLVM_CONFIG=/usr/local/Cellar/llvm/*/bin/llvm-config; sudo -E ./afl-system-config; gmake ASAN_BUILD=1
- name: frida - name: frida
run: export CC=/usr/local/Cellar/llvm/*/bin/clang; export CXX="$CC"++; cd frida_mode; gmake run: export CC=/usr/local/Cellar/llvm/*/bin/clang; export CXX="$CC"++; cd frida_mode; gmake
- name: run tests - name: run tests
run: sudo -E ./afl-system-config ; gmake tests run: sudo -E ./afl-system-config; export PATH=/usr/local/Cellar/llvm/*/":/usr/local/bin:$PATH"; gmake tests

View File

@ -99,7 +99,8 @@ Be sure to setup `PATH` to point to the correct clang binaries and use the
freshly installed clang, clang++, gmake and coreutils, e.g.: freshly installed clang, clang++, gmake and coreutils, e.g.:
``` ```
export PATH="/usr/local/Cellar/llvm/13.0.0_2/bin/:/usr/local/opt/coreutils/libexec/gnubin:$PATH" export
PATH="/usr/local/Cellar/llvm/13.0.0_2/bin/:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:$PATH"
export CC=clang export CC=clang
export CXX=clang++ export CXX=clang++
gmake gmake

View File

@ -68,24 +68,24 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && {
../afl-clang-fast -DTEST_SHARED_OBJECT=1 -z defs -fPIC -shared -o test-instr.so ../test-instr.c > /dev/null 2>&1 ../afl-clang-fast -DTEST_SHARED_OBJECT=1 -z defs -fPIC -shared -o test-instr.so ../test-instr.c > /dev/null 2>&1
test -e test-instr.so && { test -e test-instr.so && {
$ECHO "$GREEN[+] llvm_mode shared object with -z defs compilation succeeded" $ECHO "$GREEN[+] llvm_mode shared object with -z defs compilation succeeded"
test `uname -s` = 'Linux' && LIBS=-ldl : test `uname -s` = 'Linux' && LIBS=-ldl
../afl-clang-fast -o test-dlopen.plain test-dlopen.c ${LIBS} > /dev/null 2>&1 ../afl-clang-fast -o test-dlopen.plain test-dlopen.c ${LIBS} > /dev/null 2>&1
test -e test-dlopen.plain && { test -e test-dlopen.plain && {
$ECHO "$GREEN[+] llvm_mode test-dlopen compilation succeeded" $ECHO "$GREEN[+] llvm_mode test-dlopen compilation succeeded"
echo 0 | TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ./test-dlopen.plain > /dev/null 2>&1 echo 0 | DYLD_INSERT_LIBRARIES=./test-instr.so LD_PRELOAD=./test-instr.so TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ./test-dlopen.plain > /dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
$ECHO "$RED[!] llvm_mode test-dlopen exits with an error" $ECHO "$RED[!] llvm_mode test-dlopen exits with an error"
CODE=1 CODE=1
fi fi
echo 0 | TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-dlopen.plain.0 -r -- ./test-dlopen.plain > /dev/null 2>&1 echo 0 | AFL_PRELOAD=./test-instr.so TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-dlopen.plain.0 -r -- ./test-dlopen.plain > /dev/null 2>&1
TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-dlopen.plain.1 -r -- ./test-dlopen.plain < /dev/null > /dev/null 2>&1 AFL_PRELOAD=./test-instr.so TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-dlopen.plain.1 -r -- ./test-dlopen.plain < /dev/null > /dev/null 2>&1
test -e test-dlopen.plain.0 -a -e test-dlopen.plain.1 && { test -e test-dlopen.plain.0 -a -e test-dlopen.plain.1 && {
diff test-dlopen.plain.0 test-dlopen.plain.1 > /dev/null 2>&1 && { diff test-dlopen.plain.0 test-dlopen.plain.1 > /dev/null 2>&1 && {
$ECHO "$RED[!] llvm_mode test-dlopen instrumentation should be different on different input but is not" $ECHO "$RED[!] llvm_mode test-dlopen instrumentation should be different on different input but is not"
CODE=1 CODE=1
} || { } || {
$ECHO "$GREEN[+] llvm_mode test-dlopen instrumentation present and working correctly" $ECHO "$GREEN[+] llvm_mode test-dlopen instrumentation present and working correctly"
TUPLES=`echo 0|TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-dlopen.plain 2>&1 | grep Captur | awk '{print$3}'` TUPLES=`echo 0|AFL_PRELOAD=./test-instr.so TEST_DLOPEN_TARGET=./test-instr.so AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-dlopen.plain 2>&1 | grep Captur | awk '{print$3}'`
test "$TUPLES" -gt 3 -a "$TUPLES" -lt 12 && { test "$TUPLES" -gt 3 -a "$TUPLES" -lt 12 && {
$ECHO "$GREEN[+] llvm_mode test-dlopen run reported $TUPLES instrumented locations which is fine" $ECHO "$GREEN[+] llvm_mode test-dlopen run reported $TUPLES instrumented locations which is fine"
} || { } || {

View File

@ -105,14 +105,14 @@ test -n "$TRAVIS_OS_NAME" && {
export ASAN_OPTIONS=detect_leaks=0:allocator_may_return_null=1:abort_on_error=1:symbolize=1 export ASAN_OPTIONS=detect_leaks=0:allocator_may_return_null=1:abort_on_error=1:symbolize=1
} }
export AFL_LLVM_INSTRUMENT=AFL #export AFL_LLVM_INSTRUMENT=AFL # AFL mode makes dlopen not link on macos
# on OpenBSD we need to work with llvm from /usr/local/bin # on OpenBSD we need to work with llvm from /usr/local/bin
test -e /usr/local/bin/opt && { test -e /usr/local/bin/opt && {
export PATH="/usr/local/bin:${PATH}" test `uname -s` = 'Darwin' || export PATH="/usr/local/bin:${PATH}"
} }
# on MacOS X we prefer afl-clang over afl-gcc, because # on MacOS X we prefer afl-clang over afl-gcc, because
# afl-gcc does not work there # afl-gcc does not work there (it is a symlink from clang)
test `uname -s` = 'Darwin' -o `uname -s` = 'FreeBSD' && { test `uname -s` = 'Darwin' -o `uname -s` = 'FreeBSD' && {
AFL_GCC=afl-clang AFL_GCC=afl-clang
} || { } || {