aboutsummaryrefslogtreecommitdiff
path: root/fuzzer
diff options
context:
space:
mode:
authorFelix Weinrank <weinrank@fh-muenster.de>2019-10-01 14:13:26 +0200
committerMichael Tüxen <tuexen@fh-muenster.de>2019-10-01 14:13:26 +0200
commite67c6f8b30b8a8dfab5f04a40fa14cabffebec7c (patch)
tree6dd45c0f2d1a524004ebce645104cf948af662f4 /fuzzer
parent75d762a3a111d7c519043fe2c4799bf16510c415 (diff)
downloadusrsctp-e67c6f8b30b8a8dfab5f04a40fa14cabffebec7c.tar.gz
Minor fixes: Fuzzer scripts, programs debug, structure field (#392)
Diffstat (limited to 'fuzzer')
-rwxr-xr-xfuzzer/build-fuzzer.sh44
-rwxr-xr-xfuzzer/check-input.sh28
-rwxr-xr-xfuzzer/fuzzer_connect_multi.sh2
-rw-r--r--fuzzer/text2pcap.sh1
4 files changed, 52 insertions, 23 deletions
diff --git a/fuzzer/build-fuzzer.sh b/fuzzer/build-fuzzer.sh
index f1880313..59111e1c 100755
--- a/fuzzer/build-fuzzer.sh
+++ b/fuzzer/build-fuzzer.sh
@@ -1,30 +1,50 @@
-#!/bin/sh
+#!/usr/bin/env bash
set -e
NPROC=1
+# OS detection
if [ "$(uname)" = "Linux" ]; then
- NPROC=$(nproc)
- CC=clang-9
+ NPROC=$(nproc)
+ CC=clang-10
+ LINKER=ld.lld-10
elif [ "$(uname)" = "Darwin" ]; then
- NPROC=$(sysctl -n hw.ncpu)
- CC=/usr/local/opt/llvm/bin/clang
+ NPROC=$(sysctl -n hw.ncpu)
+ CC=/usr/local/opt/llvm/bin/clang
+ LINKER=/usr/local/opt/llvm/bin/ld.lld
elif [ "$(uname)" = "FreeBSD" ]; then
- NPROC=$(sysctl -n hw.ncpu)
- CC=clang90
+ NPROC=$(sysctl -n hw.ncpu)
+ CC=clang-devel
+ LINKER=ld.lld-devel
else
- echo "Error: $(uname) not supported, sorry!"
- exit 1
+ echo "Error: $(uname) not supported, sorry!"
+ exit 1
fi
+# Check if we have a compiler
if ! [ -x "$(command -v $CC)" ]; then
- echo "Error: $CC is not installed!" >&2
- exit 1
+ echo "Error: $CC is not installed!" >&2
+ exit 1
fi
echo "OS :" $(uname)
echo "CC :" $CC
echo "NP :" $NPROC
-cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=RelWithDebInfo .
+# Go to script directory
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+cd "$SCRIPT_DIR"
+cd ".."
+
+pwd
+
+# Find and then delete all files under current directory (.) that:
+# 1. contains "cmake" (case-&insensitive) in its path (wholename)
+# 2. name is not CMakeLists.txt
+find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete
+
+# Build with ASAN / MSAN
+cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$LINKER" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=RelWithDebInfo .
+#cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$LINKER" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=RelWithDebInfo .
+
make -j"$NPROC"
diff --git a/fuzzer/check-input.sh b/fuzzer/check-input.sh
index 51ea7031..78c152c9 100755
--- a/fuzzer/check-input.sh
+++ b/fuzzer/check-input.sh
@@ -4,27 +4,37 @@
# usage: check-input.sh input_data
#
-set -e
-set -u
+set -e # stop on error
+set -u # uinitialized variables -> error!
#make
+C_RED='\033[0;31m' # RED
+C_GRN='\033[0;32m' # RED
+C_NOC='\033[0m' # No Color
+
echo "Fuzzer Input: $1"
echo "########## Beginning Fuzzer Chain"
echo ""
set +e
-./fuzzer_connect_multi_verbose -timeout=30 $1 2>$1.log
+./fuzzer_connect_multi_verbose -timeout=30 $1 > $1.log 2>&1
FUZZER_RETVAL=$?
set -e
+echo "Fuzzer returncode: $FUZZER_RETVAL"
+
if [ "$FUZZER_RETVAL" -eq "0" ]; then
- echo "Execution successful - fuzzer terminated without an issue"
+ echo -e "$C_RED"
+ echo "$1 - NOT REPRODUCABLE"
+ echo -e "$C_NOC"
elif [ "$FUZZER_RETVAL" -eq "77" ]; then
- echo "Exceution successful - found an issue!"
+ echo -e "$C_GRN"
+ echo "$1 - REPRODUCABLE"
+ echo -e "$C_NOC"
else
- echo "Internal error, exiting!"
- exit
+ echo "Unexpected return code: $FUZZER_RETVAL - handle with care..!"
+ #exit
fi
grep "# SCTP_PACKET" $1.log > $1.pcap-log
@@ -38,7 +48,7 @@ echo ""
# Open Wireshark if we have an X session
if [ -z ${DISPLAY+x} ]; then
- echo "\$DISPLAY unset, skipping wireshark"
+ echo "\$DISPLAY unset, skipping wireshark"
else
- wireshark $1.pcapng
+ wireshark $1.pcapng
fi
diff --git a/fuzzer/fuzzer_connect_multi.sh b/fuzzer/fuzzer_connect_multi.sh
index 665cfd6c..f7ac3598 100755
--- a/fuzzer/fuzzer_connect_multi.sh
+++ b/fuzzer/fuzzer_connect_multi.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0
+export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0:detect_leaks=1
ulimit -c unlimited
mkdir -p CORPUS_CONNECT
diff --git a/fuzzer/text2pcap.sh b/fuzzer/text2pcap.sh
deleted file mode 100644
index 0c46c3be..00000000
--- a/fuzzer/text2pcap.sh
+++ /dev/null
@@ -1 +0,0 @@
-text2pcap -n -l 248 -D -t "%H:%M:%S." fuzzer.log fuzzer.pcapng