From f9bf26651146a9f2bab50bcb2511b2b296ecc3ca Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sun, 10 Jan 2021 20:26:34 +0100 Subject: [PATCH] Captcha : Randomize digit list for INTRUS --- captcha/captcha.sh | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/captcha/captcha.sh b/captcha/captcha.sh index aad5223..756ddfb 100755 --- a/captcha/captcha.sh +++ b/captcha/captcha.sh @@ -32,29 +32,15 @@ else } fi -DECOUPE() -{ - LENGTH=${#INPUT} - MID=$((LENGTH / 2)) - - get_random - R=$(($R % 2)) - - if [[ $R -eq 1 ]]; then - echo "Tapez ${INPUT:0:$MID}\n suivi de ${INPUT:$MID:$MID}" - else - echo "Saisissez ${INPUT:0:$MID}\n puis ${INPUT:$MID:$MID}" - fi -} - INTRUS() { LENGTH=${#INPUT} NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ') SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ') + RANDOM_DIGITS=$(echo 123456789 | grep -o . | sort -R | tr '\n' ' ') INTRUS=-1 - for i in 1 2 3 4 5 6 7 8 9 + for i in ${RANDOM_DIGITS[@]} do if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then INTRUS=$i