-
Notifications
You must be signed in to change notification settings - Fork 9
/
fuzz.sh
executable file
·42 lines (37 loc) · 1.21 KB
/
fuzz.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
if [ "clean" = "$1" ]; then
echo $(pwd)/fuzz/hfuzz_target
rm -rf $(pwd)/fuzz/hfuzz_target
for FILE in $(pwd)/fuzz/hfuzz_workspace/*/*.*; do
echo $FILE
rm -f $FILE
done
exit
fi
DOCKER="docker"
${DOCKER} build -t pdu-fuzz - <<'EOF'
FROM ubuntu:bionic
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8
VOLUME /usr/local/src/pdu
WORKDIR /usr/local/src/pdu
SHELL ["/bin/bash", "-eu", "-o", "pipefail", "-c"]
RUN \
export DEBIAN_FRONTEND=noninteractive; \
apt-get -q update; \
apt-get -q install -y curl build-essential linux-headers-generic pkg-config binutils-dev libunwind-dev libpcap-dev tshark; \
apt-get -q clean autoclean;
RUN \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable; \
source $HOME/.cargo/env; \
cargo install honggfuzz;
ENTRYPOINT \
mkdir -p /tmp/honggfuzz/$FUZZ_TARGET; \
source $HOME/.cargo/env; \
cd ./fuzz; \
RUSTFLAGS="-C link-dead-code" HFUZZ_RUN_ARGS="-t 5 -T --output /tmp/honggfuzz/$FUZZ_TARGET" cargo hfuzz run $FUZZ_TARGET
EOF
if [ -z "$1" ]; then
echo "Usage: fuzz.sh [ clean | ethernet | arp | ipv4 | ipv6 | tcp | udp | icmp | gre ]"
fi
${DOCKER} run --init --rm -v "$(pwd):/usr/local/src/pdu" -e FUZZ_TARGET=$1 pdu-fuzz