New intelligent captcha ;)
This commit is contained in:
parent
0c60b0b118
commit
bcff7e019a
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
# This script is an example captcha script.
|
||||
# It takes the text to recognize in the captcha image as a parameter.
|
||||
|
@ -15,13 +15,15 @@
|
|||
|
||||
INPUT=$1
|
||||
|
||||
TRANSFORMATIONS=(DECOUPE.A DECOUPE.B INTRUS.A INTRUS.B SOMME.A SOMME.B)
|
||||
|
||||
if test -n ${BASH_VERSION:-''} ; then
|
||||
get_random ()
|
||||
{
|
||||
R=$RANDOM
|
||||
}
|
||||
else
|
||||
for n in `od -A n -t u2 -N 48 /dev/urandom`; do RL="$RL$n "; done
|
||||
for n in `od -A n -t u2 -N 64 /dev/urandom`; do RL="$RL$n "; done
|
||||
get_random ()
|
||||
{
|
||||
R=${RL%% *}
|
||||
|
@ -29,82 +31,144 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
DECOUPE.A()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
MID=$((LENGTH / 2))
|
||||
|
||||
echo Tapez "${INPUT:0:$MID}" suivi de "${INPUT:$MID:$MID}"
|
||||
}
|
||||
|
||||
DECOUPE.B()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
MID=$((LENGTH / 2))
|
||||
|
||||
echo Saisissez "${INPUT:0:$MID}" puis "${INPUT:$MID:$MID}"
|
||||
}
|
||||
|
||||
INTRUS.A()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ')
|
||||
SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ')
|
||||
INTRUS=-1
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9
|
||||
do
|
||||
if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then
|
||||
INTRUS=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Worst case
|
||||
if [[ $INTRUS -eq "-1" ]]
|
||||
then
|
||||
echo Tapez "$INPUT sans changement"
|
||||
return
|
||||
fi
|
||||
|
||||
for num in ${NUMBERS[@]}
|
||||
do
|
||||
get_random
|
||||
WAVE1_AMPLITUDE=$((2 + $R % 5))
|
||||
R=$(($R % 100))
|
||||
|
||||
if [[ $R -lt 60 ]]; then
|
||||
NEWINPUT=${NEWINPUT}${num}${INTRUS}
|
||||
else
|
||||
NEWINPUT=${NEWINPUT}${num}
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Tapez $NEWINPUT en supprimant\n les $INTRUS"
|
||||
}
|
||||
|
||||
INTRUS.B()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ')
|
||||
SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ')
|
||||
INTRUS=-1
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9
|
||||
do
|
||||
if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then
|
||||
INTRUS=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Worst case
|
||||
if [[ $INTRUS -eq "-1" ]]
|
||||
then
|
||||
echo Tapez "$INPUT sans changement"
|
||||
return
|
||||
fi
|
||||
|
||||
for num in ${NUMBERS[@]}
|
||||
do
|
||||
get_random
|
||||
WAVE1_LENGTH=$((50 + $R % 25))
|
||||
get_random
|
||||
WAVE2_AMPLITUDE=$((2 + $R % 5))
|
||||
get_random
|
||||
WAVE2_LENGTH=$((50 + $R % 25))
|
||||
get_random
|
||||
WAVE3_AMPLITUDE=$((2 + $R % 5))
|
||||
get_random
|
||||
WAVE3_LENGTH=$((50 + $R % 25))
|
||||
get_random
|
||||
W1_LINE_START_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W1_LINE_STOP_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W2_LINE_START_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W2_LINE_STOP_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W3_LINE_START_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W3_LINE_STOP_Y=$((10 + $R % 40))
|
||||
R=$(($R % 100))
|
||||
|
||||
if [[ $R -lt 60 ]]; then
|
||||
NEWINPUT=${NEWINPUT}${num}${INTRUS}
|
||||
else
|
||||
NEWINPUT=${NEWINPUT}${num}
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Saisissez $NEWINPUT en enlevant\n les $INTRUS"
|
||||
}
|
||||
|
||||
SOMME.A()
|
||||
{
|
||||
if [[ $(($INPUT % 2)) -eq 0 ]]; then
|
||||
A=$(($INPUT / 2))
|
||||
B=$A
|
||||
else
|
||||
A=$(($INPUT / 2))
|
||||
B=$(($A+1))
|
||||
fi
|
||||
|
||||
get_random
|
||||
B1_LINE_START_Y=$(($R % 40))
|
||||
get_random
|
||||
B1_LINE_STOP_Y=$(($R % 40))
|
||||
get_random
|
||||
B2_LINE_START_Y=$(($R % 40))
|
||||
get_random
|
||||
B2_LINE_STOP_Y=$(($R % 40))
|
||||
#B3_LINE_START_Y=$(($R % 40))
|
||||
#B3_LINE_STOP_Y=$(($R % 40))
|
||||
R=$(($R % 100))
|
||||
A=$(($A - $R))
|
||||
B=$(($B + $R))
|
||||
|
||||
echo Tapez le résultat de "$A" + "$B"
|
||||
}
|
||||
|
||||
SOMME.B()
|
||||
{
|
||||
if [[ $(($INPUT % 2)) -eq 0 ]]; then
|
||||
A=$(($INPUT / 2))
|
||||
B=$A
|
||||
else
|
||||
A=$(($INPUT / 2))
|
||||
B=$(($A+1))
|
||||
fi
|
||||
|
||||
get_random
|
||||
B1_LINE_START_X=$(($R % 20))
|
||||
get_random
|
||||
B1_LINE_STOP_X=$((100 + $R % 40))
|
||||
get_random
|
||||
B2_LINE_START_X=$(($R % 20))
|
||||
get_random
|
||||
B2_LINE_STOP_X=$((100 + $R % 40))
|
||||
#B3_LINE_START_X=$(($R % 20))
|
||||
#B3_LINE_STOP_X=$((100 + $R % 40))
|
||||
R=$(($R % 100))
|
||||
A=$(($A - $R))
|
||||
B=$(($B + $R))
|
||||
|
||||
echo Saisissez le résultat de "$A" + "$B"
|
||||
}
|
||||
|
||||
get_random
|
||||
RAND_A=$(($R % 10 + 40))
|
||||
RAND_ITALIC=$(($R % 25))
|
||||
get_random
|
||||
RAND_B=$(($R % 14))
|
||||
RAND_ANGLE=$(($R % 5))
|
||||
get_random
|
||||
RAND_C=$(($R % 10 + 60))
|
||||
get_random
|
||||
RAND_D=$(($R % 20))
|
||||
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
||||
|
||||
convert -size 180x60 xc:none -pointsize 40 \
|
||||
\( -clone 0 -stroke plasma:fractal \
|
||||
-strokewidth 1 -draw \
|
||||
"line $B1_LINE_START_X,$B1_LINE_START_Y $B1_LINE_STOP_X,$B1_LINE_STOP_Y" \
|
||||
-strokewidth 1 -draw \
|
||||
"line $B2_LINE_START_X,$B2_LINE_START_Y $B2_LINE_STOP_X,$B2_LINE_STOP_Y" \
|
||||
-wave "$WAVE2_AMPLITUDE"x"$WAVE2_LENGTH" \) \
|
||||
\( -clone 0 -stroke plasma:fractal \
|
||||
-strokewidth 2 -draw "line 0,$W1_LINE_START_Y 140,$W1_LINE_STOP_Y" \
|
||||
-strokewidth 2 -draw "line 0,$W2_LINE_START_Y 140,$W2_LINE_STOP_Y" \
|
||||
-strokewidth 2 -draw "line 0,$W3_LINE_START_Y 140,$W3_LINE_STOP_Y" \
|
||||
-wave "$WAVE3_AMPLITUDE"x"$WAVE3_LENGTH" \) \
|
||||
\( -clone 0 -fill plasma:fractal \
|
||||
-stroke plasma:fractal -strokewidth 3 -annotate "2x0+0+$RAND_A" "$INPUT" \
|
||||
-stroke plasma:fractal -strokewidth 4 -annotate "2x0+0+$RAND_A" "$INPUT" \
|
||||
convert -size 300x60 xc:none -pointsize 20 \
|
||||
\( -clone 0 -fill black \
|
||||
-stroke black -strokewidth 1 \
|
||||
-annotate "${RAND_ANGLE}x${RAND_ITALIC}+0+0" "\n $(${TRANSFORMATIONS[$RAND_INDEX]})" \
|
||||
-roll +$ROLL_X+0 \
|
||||
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
||||
-roll -$ROLL_X+0 \
|
||||
-distort Perspective "0,0,0,0 0,$RAND_C,0,80 80,0,80,5 80,80,80,55" \
|
||||
-rotate "+$RAND_D" \) \
|
||||
\( -size 140x60 xc: +noise Random -alpha set -channel A -evaluate set 40% \) \
|
||||
-compose add \
|
||||
-flatten -crop 140x60 +repage -quality 500 -depth 11 png:-
|
||||
-roll -$ROLL_X+0 \) \
|
||||
-flatten -crop 300x60 +repage -quality 500 -depth 11 png:-
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
# This script is an example captcha script.
|
||||
# It takes the text to recognize in the captcha image as a parameter.
|
||||
|
@ -15,6 +15,8 @@
|
|||
|
||||
INPUT=$1
|
||||
|
||||
TRANSFORMATIONS=(DECOUPE.A DECOUPE.B INTRUS.A INTRUS.B SOMME.A SOMME.B)
|
||||
|
||||
if test -n ${BASH_VERSION:-''} ; then
|
||||
get_random ()
|
||||
{
|
||||
|
@ -29,82 +31,144 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
DECOUPE.A()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
MID=$((LENGTH / 2))
|
||||
|
||||
echo Tapez "${INPUT:0:$MID}" suivi de "${INPUT:$MID:$MID}"
|
||||
}
|
||||
|
||||
DECOUPE.B()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
MID=$((LENGTH / 2))
|
||||
|
||||
echo Saisissez "${INPUT:0:$MID}" puis "${INPUT:$MID:$MID}"
|
||||
}
|
||||
|
||||
INTRUS.A()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ')
|
||||
SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ')
|
||||
INTRUS=-1
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9
|
||||
do
|
||||
if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then
|
||||
INTRUS=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Worst case
|
||||
if [[ $INTRUS -eq "-1" ]]
|
||||
then
|
||||
echo Tapez "$INPUT sans changement"
|
||||
return
|
||||
fi
|
||||
|
||||
for num in ${NUMBERS[@]}
|
||||
do
|
||||
get_random
|
||||
WAVE1_AMPLITUDE=$((2 + $R % 5))
|
||||
R=$(($R % 100))
|
||||
|
||||
if [[ $R -lt 60 ]]; then
|
||||
NEWINPUT=${NEWINPUT}${num}${INTRUS}
|
||||
else
|
||||
NEWINPUT=${NEWINPUT}${num}
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Tapez $NEWINPUT en supprimant\n les $INTRUS"
|
||||
}
|
||||
|
||||
INTRUS.B()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ')
|
||||
SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ')
|
||||
INTRUS=-1
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9
|
||||
do
|
||||
if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then
|
||||
INTRUS=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Worst case
|
||||
if [[ $INTRUS -eq "-1" ]]
|
||||
then
|
||||
echo Tapez "$INPUT sans changement"
|
||||
return
|
||||
fi
|
||||
|
||||
for num in ${NUMBERS[@]}
|
||||
do
|
||||
get_random
|
||||
WAVE1_LENGTH=$((50 + $R % 25))
|
||||
get_random
|
||||
WAVE2_AMPLITUDE=$((2 + $R % 5))
|
||||
get_random
|
||||
WAVE2_LENGTH=$((50 + $R % 25))
|
||||
get_random
|
||||
WAVE3_AMPLITUDE=$((2 + $R % 5))
|
||||
get_random
|
||||
WAVE3_LENGTH=$((50 + $R % 25))
|
||||
get_random
|
||||
W1_LINE_START_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W1_LINE_STOP_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W2_LINE_START_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W2_LINE_STOP_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W3_LINE_START_Y=$((10 + $R % 40))
|
||||
get_random
|
||||
W3_LINE_STOP_Y=$((10 + $R % 40))
|
||||
R=$(($R % 100))
|
||||
|
||||
if [[ $R -lt 60 ]]; then
|
||||
NEWINPUT=${NEWINPUT}${num}${INTRUS}
|
||||
else
|
||||
NEWINPUT=${NEWINPUT}${num}
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Saisissez $NEWINPUT en enlevant\n les $INTRUS"
|
||||
}
|
||||
|
||||
SOMME.A()
|
||||
{
|
||||
if [[ $(($INPUT % 2)) -eq 0 ]]; then
|
||||
A=$(($INPUT / 2))
|
||||
B=$A
|
||||
else
|
||||
A=$(($INPUT / 2))
|
||||
B=$(($A+1))
|
||||
fi
|
||||
|
||||
get_random
|
||||
B1_LINE_START_Y=$(($R % 40))
|
||||
get_random
|
||||
B1_LINE_STOP_Y=$(($R % 40))
|
||||
get_random
|
||||
B2_LINE_START_Y=$(($R % 40))
|
||||
get_random
|
||||
B2_LINE_STOP_Y=$(($R % 40))
|
||||
#B3_LINE_START_Y=$(($R % 40))
|
||||
#B3_LINE_STOP_Y=$(($R % 40))
|
||||
R=$(($R % 100))
|
||||
A=$(($A - $R))
|
||||
B=$(($B + $R))
|
||||
|
||||
echo Tapez le résultat de "$A" + "$B"
|
||||
}
|
||||
|
||||
SOMME.B()
|
||||
{
|
||||
if [[ $(($INPUT % 2)) -eq 0 ]]; then
|
||||
A=$(($INPUT / 2))
|
||||
B=$A
|
||||
else
|
||||
A=$(($INPUT / 2))
|
||||
B=$(($A+1))
|
||||
fi
|
||||
|
||||
get_random
|
||||
B1_LINE_START_X=$(($R % 20))
|
||||
get_random
|
||||
B1_LINE_STOP_X=$((100 + $R % 40))
|
||||
get_random
|
||||
B2_LINE_START_X=$(($R % 20))
|
||||
get_random
|
||||
B2_LINE_STOP_X=$((100 + $R % 40))
|
||||
#B3_LINE_START_X=$(($R % 20))
|
||||
#B3_LINE_STOP_X=$((100 + $R % 40))
|
||||
R=$(($R % 100))
|
||||
A=$(($A - $R))
|
||||
B=$(($B + $R))
|
||||
|
||||
echo Saisissez le résultat de "$A" + "$B"
|
||||
}
|
||||
|
||||
get_random
|
||||
RAND_A=$(($R % 10 + 40))
|
||||
RAND_ITALIC=$(($R % 25))
|
||||
get_random
|
||||
RAND_B=$(($R % 14))
|
||||
RAND_ANGLE=$(($R % 5))
|
||||
get_random
|
||||
RAND_C=$(($R % 10 + 60))
|
||||
get_random
|
||||
RAND_D=$(($R % 20))
|
||||
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
||||
|
||||
convert -size 180x60 xc:none -pointsize 40 \
|
||||
\( -clone 0 -stroke plasma:fractal \
|
||||
-strokewidth 1 -draw \
|
||||
"line $B1_LINE_START_X,$B1_LINE_START_Y $B1_LINE_STOP_X,$B1_LINE_STOP_Y" \
|
||||
-strokewidth 1 -draw \
|
||||
"line $B2_LINE_START_X,$B2_LINE_START_Y $B2_LINE_STOP_X,$B2_LINE_STOP_Y" \
|
||||
-wave "$WAVE2_AMPLITUDE"x"$WAVE2_LENGTH" \) \
|
||||
\( -clone 0 -stroke plasma:fractal \
|
||||
-strokewidth 2 -draw "line 0,$W1_LINE_START_Y 140,$W1_LINE_STOP_Y" \
|
||||
-strokewidth 2 -draw "line 0,$W2_LINE_START_Y 140,$W2_LINE_STOP_Y" \
|
||||
-strokewidth 2 -draw "line 0,$W3_LINE_START_Y 140,$W3_LINE_STOP_Y" \
|
||||
-wave "$WAVE3_AMPLITUDE"x"$WAVE3_LENGTH" \) \
|
||||
\( -clone 0 -fill plasma:fractal \
|
||||
-stroke plasma:fractal -strokewidth 3 -annotate "2x0+0+$RAND_A" "$INPUT" \
|
||||
-stroke plasma:fractal -strokewidth 4 -annotate "2x0+0+$RAND_A" "$INPUT" \
|
||||
convert -size 300x60 xc:none -pointsize 20 \
|
||||
\( -clone 0 -fill black \
|
||||
-stroke black -strokewidth 1 \
|
||||
-annotate "${RAND_ANGLE}x${RAND_ITALIC}+0+0" "\n $(${TRANSFORMATIONS[$RAND_INDEX]})" \
|
||||
-roll +$ROLL_X+0 \
|
||||
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
||||
-roll -$ROLL_X+0 \
|
||||
-distort Perspective "0,0,0,0 0,$RAND_C,0,80 80,0,80,5 80,80,80,55" \
|
||||
-rotate "+$RAND_D" \) \
|
||||
\( -size 140x60 xc: +noise Random -alpha set -channel A -evaluate set 40% \) \
|
||||
-compose add \
|
||||
-flatten -crop 140x60 +repage -quality 500 -depth 11 png:-
|
||||
-roll -$ROLL_X+0 \) \
|
||||
-flatten -crop 300x60 +repage -quality 500 -depth 11 png:-
|
||||
|
|
|
@ -12,7 +12,7 @@ service.logo=https://www.chapril.org/.well-known/chaprilinfos/chapril-logo-mini.
|
|||
service.legal.url=https://www.chapril.org/cgu.html
|
||||
service.guide.technical=https://admin.chapril.org/doku.php?id=admin:services:xmpp.chapril.org
|
||||
service.guide.user=https://www.chapril.org/XMPP
|
||||
service.contact.url=https://www.chapril.org/contact.xhtml
|
||||
service.contact.url=https://www.chapril.org/contact.html
|
||||
service.contact.email=xmpp-support@chapril.org
|
||||
service.startDate=08/03/2020
|
||||
service.endDate=
|
||||
|
|
Loading…
Reference in New Issue