etc.git


etc

~ scripts and random things
git clone https://github.com/djnnvx/etc.git
log | files | refs | archive

run.sh (1546B)

      1 #!/bin/bash
      2 set -e
      3 
      4 REPO_URL="https://github.com/proftpd/proftpd.git"
      5 REPO_DIR="proftpd"
      6 REPO_VERSION="1.3.9"
      7 
      8 OUT_DIR="fuzz_out"
      9 SEED_CORPUS_URL="https://github.com/dvyukov/go-fuzz-corpus.git"
     10 FUZZ_TARGET="json_fuzzer"
     11 
     12 CC=${CC:-clang}
     13 CXX=${CXX:-clang++}
     14 CFLAGS=${CFLAGS:-"-O2 -fsanitize=fuzzer,address -fPIC"}
     15 CXXFLAGS=${CXXFLAGS:-"-O2 -fsanitize=fuzzer,address -fPIC"}
     16 
     17 echo "Cloning ProFTPD repository..."
     18 if [ ! -d "$REPO_DIR" ]; then
     19     git clone "$REPO_URL" --branch "$REPO_VERSION"
     20 fi
     21 cd "$REPO_DIR"
     22 
     23 echo "Configuring and building ProFTPD..."
     24 make clean
     25 ./configure --enable-ctrls --enable-devel=stacktrace
     26 make -j"$(nproc)"
     27 
     28 echo "Building the fuzzer executable..."
     29 mkdir -p "$OUT_DIR"
     30 $CC $CFLAGS -c tests/fuzzing/json_fuzzer.c -o "$OUT_DIR/$FUZZ_TARGET.o" -I. -I./include -DHAVE_CONFIG_H -DLINUX
     31 
     32 CORE_OBJS=$(find src/ -name "*.o" ! -name "main.o" ! -name "ftpdctl.o" | tr '\n' ' ')
     33 MODULES_OBJS=$(find modules/ -name "*.o" | tr '\n' ' ')
     34 
     35 # Link the fuzzer with all relevant object files and libraries
     36 # FIXME(djnn): this is currently broken x.x
     37 $CXX $CXXFLAGS "$OUT_DIR/$FUZZ_TARGET.o" \
     38     $CORE_OBJS \
     39     $MODULES_OBJS \
     40     lib/prbase.a \
     41     -o "$OUT_DIR/$FUZZ_TARGET" -Llib -lcrypt -pthread
     42 
     43 echo "Building seed corpus..."
     44 cd ..
     45 if [ ! -d "go-fuzz-corpus" ]; then
     46     git clone "$SEED_CORPUS_URL"
     47 fi
     48 zip -r "$REPO_DIR/$OUT_DIR/${FUZZ_TARGET}_seed_corpus.zip" go-fuzz-corpus/json/corpus/
     49 
     50 echo "Build complete."
     51 echo "To run the fuzzer:"
     52 echo "./$REPO_DIR/$OUT_DIR/$FUZZ_TARGET $OUT_DIR/${FUZZ_TARGET}_seed_corpus.zip"
     53 echo