Generalized fuzzing script
This commit is contained in:
parent
7f7bcbff52
commit
887340c04d
|
@ -1,6 +1,7 @@
|
|||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
|
||||
dist_noinst_SCRIPTS = test-manpage.sh \
|
||||
test-fuzzing.sh \
|
||||
test-pkcs11-tool-sign-verify.sh
|
||||
|
||||
TESTS = test-manpage.sh \
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
#!/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
|
||||
|
||||
if [ ! -d tests/fuzzing-testcases ]
|
||||
then
|
||||
mkdir -p tests/fuzzing-testcases
|
||||
echo -ne "$(printf '\\x90\\x00')" > tests/fuzzing-testcases/9000
|
||||
IN=tests/fuzzing-testcases
|
||||
else
|
||||
IN=-
|
||||
fi
|
||||
|
||||
FUZZ_FILE=input.apdu afl-fuzz -i $IN -o out -f input.apdu src/tools/pkcs15-tool -D
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
case "$1" in
|
||||
"pkcs11-tool")
|
||||
CMD="src/tools/pkcs11-tool --test --login --pin 123456"
|
||||
;;
|
||||
"pkcs15-tool")
|
||||
CMD="src/tools/pkcs15-tool --dump"
|
||||
;;
|
||||
"eidenv")
|
||||
CMD="src/tools/eidenv"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown fuzzing target"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
IN=tests/fuzzing-testcases
|
||||
if [ ! -d "$IN" ]
|
||||
then
|
||||
mkdir -p "$IN"
|
||||
echo -ne "$(printf '\\x90\\x00')" > "$IN"/9000
|
||||
fi
|
||||
|
||||
# reuse output directory if possible
|
||||
OUT="out-$1"
|
||||
if [ -d "$OUT" ]
|
||||
then
|
||||
IN=-
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
#export AFL_USE_ASAN=1
|
||||
./configure CC=afl-gcc CFLAGS="-O0" --disable-shared --disable-notify --with-pcsc-provider=$PWD/x41-smartcard-fuzzing/scard_override/libsccard_override.so
|
||||
make
|
||||
|
||||
FUZZ_FILE=input.apdu afl-fuzz -i "$IN" -o "$OUT" -f input.apdu $CMD
|
Loading…
Reference in New Issue