etc.git


etc

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

commit f809db373c0baae29594db5c46d174bf1a8c46db
parent 86af0ff87e08d72e641d3ea92641f7fe9e120e28
Author: djnn <[email protected]>
Date: Thu, 4 Sep 2025 09:48:11 +0900

feat: fuzzing for proftpd

Diffstat:
Afuzzing/proftpd/run.sh | 51+++++++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 51 insertions(+), 0 deletions(-)

diff --git a/fuzzing/proftpd/run.sh b/fuzzing/proftpd/run.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+set -e
+
+# Variables (edit if needed)
+REPO_URL="https://github.com/proftpd/proftpd.git"
+REPO_DIR="proftpd"
+CC=${CC:-gcc}
+CXX=${CXX:-g++}
+CFLAGS=${CFLAGS:-"-O2"}
+CXXFLAGS=${CXXFLAGS:-"-O2"}
+LIB_FUZZING_ENGINE=${LIB_FUZZING_ENGINE:-"-fsanitize=fuzzer"}
+OUT_DIR="fuzz_out"
+SEED_CORPUS_URL="https://github.com/dvyukov/go-fuzz-corpus.git"
+
+# Clone the repository
+git clone "$REPO_URL"
+cd "$REPO_DIR"
+
+# Configure and build
+export LDFLAGS="${CFLAGS}"
+./configure --enable-ctrls
+make -j"$(nproc)"
+
+# Patch src/main.c for fuzzing
+sed 's/int main(/int main2(/g' -i src/main.c
+
+# Compile main.c again
+NEW_CC_FLAG="$CC $CFLAGS -DHAVE_CONFIG_H -DLINUX  -I. -I./include"
+$NEW_CC_FLAG -c src/main.c -o src/main.o
+rm src/ftpdctl.o || true
+
+# Create fuzz_lib.a from all object files
+find . -name "*.o" -exec ar rcs fuzz_lib.a {} \;
+
+# Build fuzzer (assumes tests/fuzzing/fuzzer.c exists)
+mkdir -p "$OUT_DIR"
+$NEW_CC_FLAG -c tests/fuzzing/fuzzer.c -o fuzzer.o
+$CC $CXXFLAGS $LIB_FUZZING_ENGINE fuzzer.o -o "$OUT_DIR/fuzzer" \
+    src/scoreboard.o \
+    lib/prbase.a \
+    fuzz_lib.a \
+    -Llib \
+    -lcrypt -pthread
+
+# Build seed corpus
+git clone "$SEED_CORPUS_URL"
+zip "$OUT_DIR/fuzzer_seed_corpus.zip" go-fuzz-corpus/json/corpus/*
+
+echo "=== Build complete ==="
+echo "To run fuzzing:"
+echo "$OUT_DIR/fuzzer -runs=1000000 $OUT_DIR/fuzzer_seed_corpus.zip"