#!/usr/bin/env bash
#=============================================================================================
# Harness de fuzzing et injection: execution des campagnes de fuzzing en injectant des payloads malveillants
#=============================================================================================
TARGET="./main.sh"
DICTIONARY_PAYLOADS=(
"../../etc/password"
"/var/log; rm -rf / #"
"\$(whoami)"
"10000000000000000000"
"-1"
"'; cat /etc/shadow'"
"%s%s%s%s%s"
"\$(python3 -c 'print(\"A\"*5000)')"
)
echo "Demarrage de la campagne de fuzzing sur ${TARGET}"
for payload in "${DICTIONARY_PAYLOADS[@]}" ; do
echo "[+] Fuzzing argument -d avec payload: ${payload}"
# Execution isolee avec timeout pour detecter les denis de service
timeout 2s ${TARGET} -d "${payload}" -l 10 > /dev/null 2>&1
EXIT_CODE=$?
if [[ $EXIT_CODE -eq 124 ]] ; then
echo "[!] ALERTE DE SECURITE: Timeout / Dos detecte pour payload: ${payload}"
elif [[ $EXIT_CODE -eq 139 ]] ; then
echo "[!] CRASH: Segmentation Fault detectee pour payload: ${payload}"
elif [[ $EXIT_CODE -eq 127 ]] ; then
echo "[!] ERREUR: Une commande inconnue a ete detectee lors de l'execution du payload: ${payload}"
else
echo "[OK] Traitement effectue de facon securisee (EXIT STATUS: ${EXIT_CODE})"
fi
done