From 9e5d7bc87366a3737b680ad796f802d8f919ff9f Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Tue, 15 Jan 2019 12:21:47 +0100 Subject: [PATCH] added minimal test script for fuzzing with AFL Credits go to https://www.x41-dsec.de/lab/blog/smartcards/ --- tests/test-fuzzing-pkcs15-tool-dump.sh | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/test-fuzzing-pkcs15-tool-dump.sh diff --git a/tests/test-fuzzing-pkcs15-tool-dump.sh b/tests/test-fuzzing-pkcs15-tool-dump.sh new file mode 100644 index 00000000..c66b0304 --- /dev/null +++ b/tests/test-fuzzing-pkcs15-tool-dump.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ ! -d x41-smartcard-fuzzing ]; +then + git clone https://github.com/x41sec/x41-smartcard-fuzzing +fi + +gcc -shared -fPIC -o x41-smartcard-fuzzing/scard_override/libsccard_override.so x41-smartcard-fuzzing/scard_override/scard_override.c -ldl -I/usr/include/PCSC/ + +if [ ! -f configure ]; +then + autoreconf -vis +fi + +if [ ! -f Makefile ]; +then + make clean +fi + +#export AFL_USE_ASAN=1 +./configure CC=afl-gcc CFLAGS="-O0" LDFLAGS="-ldl" --disable-shared --disable-notify --with-pcsc-provider=$PWD/x41-smartcard-fuzzing/scard_override/libsccard_override.so +make + +mkdir -p tests/fuzzing-testcases +echo -ne "$(printf '\\x90\\x00')" > tests/fuzzing-testcases/9000 + +FUZZ_FILE=input.apdu afl-fuzz -i tests/fuzzing-testcases -o out -f input.apdu src/tools/pkcs15-tool -D