CwsCaptcha est une classe PHP qui vous permettra de générer un captcha afin d'éviter le spam.
De nombreux paramètres sont adaptables comme :
- Les dimensions de l'image finale.
- Le nombre min et max de lettres dans le captcha.
- La couleur des lettres.
- La couleur de fond (transparente ou non).
- Les polices d'écriture.
- Les effets à appliquer sur l'image (blur, emboss ou pixelate).
- Le niveau de rotation, d'amplitude, de période et d'échelle des lettres (géométrie dans l'espace).
- Le format de sortie (PNG ou JPEG).
Le code est disponible sur GitHub. Si vous rencontrez des problèmes ou si avez des idées d'améliorations, merci de poster une issue sur GitHub.
J'ai effectué quelques tests avec PWNtcha qui est une librairie pour décoder les captchas.
Pour ceux qui veulent tester mon captcha, vous pouvez télécharger gratuitement PWNtcha via SVN ou Git sur le site officiel. Il est disponible sur Backtrack mais le mieux est de l'installer depuis les sources :
root@bt:~# cd /tmp/ root@bt:/tmp# git clone git://git.zoy.org/pwntcha.git pwntcha root@bt:/tmp# cd /pwntcha root@bt:/tmp/pwntcha# ./bootstrap root@bt:/tmp/pwntcha# ./configure root@bt:/tmp/pwntcha# make install
Ensuite vous n'aurez plus qu'à enregistrer un captcha généré et à le tester avec les différents modes disponibles. Par exemple avec ce captcha voici ce que ça donne :
root@bt:/tmp/pwntcha# pwntcha --mode authimage /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours 1ALLLA root@bt:/tmp/pwntcha# pwntcha --mode clubic /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours 411504 root@bt:/tmp/pwntcha# pwntcha --mode java /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours pwntcha: sorry, decoding failed root@bt:/tmp/pwntcha# pwntcha --mode linuxfr /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours pwntcha: sorry, decoding failed root@bt:/tmp/pwntcha# pwntcha --mode lmt /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours YLL root@bt:/tmp/pwntcha# pwntcha --mode paypal /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours AAAWWAAA root@bt:/tmp/pwntcha# pwntcha --mode phpbb /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours 111111 root@bt:/tmp/pwntcha# pwntcha --mode scode /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours pwntcha: don't know about checksum 201883 pwntcha: don't know about checksum 52742 ?? root@bt:/tmp/pwntcha# pwntcha --mode slashdot /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours root@bt:/tmp/pwntcha# pwntcha --mode vbulletin /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours 777777 root@bt:/tmp/pwntcha# pwntcha --mode xanga /tmp/captcha/01.png pwntcha: image size 250x60, 143 colours udiijy
Comme vous pouvez le voir le test est concluant mais se base sur des canvas prédéfinis (modes). Et si vous êtes paranoïaque, vous pouvez toujours appliquer les différents effets disponibles ou bien amplifier la distorsion de l'image.