yannick.81 Posted January 2, 2019 Share Posted January 2, 2019 Bonjour à tous Depuis quelques jours le site de mon client sous prestashop 1.6 est à nouveau attaqué par les spams russes alors que j'avais réglé tout ça il y a bien longtemps avec le racaptcha de google... Je mets en PJ les attaques, ce ne sont pas des mails en .ru mais des gmail.com 😕 La page de contact du site de mon client pour vous montrer que le captcha de google fonctionne bien (testé sur firefox, ie, chrome ainsi que sur android, si on ne clique pas sur le captcha, le mail ne s'envoie pas) : gdegdesign page de contact Et le code dans le index.php (entre les commentaires et le premier header) if(isset($_REQUEST['submitMessage'])){ if (empty($_REQUEST['g-recaptcha-response'])){ sleep(25); die('not human'); } $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query( array( 'secret' => 'XXX', /* TODO: tune this https://www.google.com/recaptcha/admin */ 'response' => $_REQUEST['g-recaptcha-response'], ) ), ), ); $stream = stream_context_create($opts); $captcha = @json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $stream), true); if (empty($captcha) || empty($captcha['success']) || !$captcha['success']){ sleep(25); die('not human'.PHP_EOL.print_r($captcha,1)); } } Et celui dans le contact form, au tout début après les commentaires de page <!-- Google ReCaptcha on contact form --> <script> var googlecaptchasitekey = 'XXX'; /* TODO: tune this https://www.google.com/recaptcha/admin */ $(document).ready(function(){ var $forms = $('form.contact-form-box'); if ($forms.length > 0){ var captcha = $('<div class="g-recaptcha" data-sitekey="'+ googlecaptchasitekey + '">'); var $submit = $forms.find('#submitMessage'); $submit.before(captcha); $submit.click(function(event){ if ($forms.find('#g-recaptcha-response').val().length == 0) { event.preventDefault(); event.stopPropagation(); return false; } }); } }); </script> <script src='https://www.google.com/recaptcha/api.js?hl={$language_code}'></script> <!-- /Google ReCaptcha --> J'ai bien sûr remplacé les clés par XXX les russes seraient trop forts ? comment faire ? Merci d'avance pour vos réponse Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 vous avez bien généré vos clés avec le recaptcha V2 et non V3 ? (la V3 a des soucis semble-t-il) Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 Oui c'est bien du V2 que j'avais utilisé à l'époque il me semble (ça doit faire un an). C'est même sûr vu que le V2 c'est une case à cocher alors que le V3 serait une validation de score. Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 Y a forcément un souci dans votre index.php car je peux vous envoyer autant de spam que je veux en cliquant ici https://www.gdegdesign.com/nous-contacter?id_contact=2&[email protected]&message=test&submitMessage 1 Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 1 minute ago, Eolia said: Y a forcément un souci dans votre index.php car je peux vous envoyer autant de spam que je veux en cliquant ici https://www.gdegdesign.com/nous-contacter?id_contact=2&[email protected]&message=test&submitMessage ah oui joli... et le message est bien dans la liste... Voici le code exact de index.php avec la clé, et en réduisant le commentaire <?php /* * ... * * @author PrestaShop SA <[email protected]> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if(isset($_REQUEST['submitMessage'])){ if (empty($_REQUEST['g-recaptcha-response'])){ sleep(25); die('not human'); } $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query( array( 'secret' => '6LfHR0cUAAAAACVFup0e2pDvkqpBLbxFRTP8SYcf', /* TODO: tune this https://www.google.com/recaptcha/admin */ 'response' => $_REQUEST['g-recaptcha-response'], ) ), ), ); $stream = stream_context_create($opts); $captcha = @json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $stream), true); if (empty($captcha) || empty($captcha['success']) || !$captcha['success']){ sleep(25); die('not human'.PHP_EOL.print_r($captcha,1)); } } header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Location: ../"); exit; Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 ben là on est pas du tout dans le index.php à la racine du site mais plutot dans celui du thème donc ca ne sert à rien^^ Le contenu du index.php du site c'est : <?php /* * 2007-2015 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); 1 Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 Oh le couillon que je suis 😂 Honte à moi --' Donc voilà désormais le vrai code du fichier index.php que je viens de mettre en place, hem ^^ <!-- Google ReCaptcha on contact form --> <script> var googlecaptchasitekey = '6LfHR0cUAAAAALknPjZM_9x7wGzk2EiYHcr9-BNZ'; /* TODO: tune this https://www.google.com/recaptcha/admin */ $(document).ready(function(){ var $forms = $('form.contact-form-box'); if ($forms.length > 0){ var captcha = $('<div class="g-recaptcha" data-sitekey="'+ googlecaptchasitekey + '">'); var $submit = $forms.find('#submitMessage'); $submit.before(captcha); $submit.click(function(event){ if ($forms.find('#g-recaptcha-response').val().length == 0) { event.preventDefault(); event.stopPropagation(); return false; } }); } }); </script> <script src='https://www.google.com/recaptcha/api.js?hl={$language_code}'></script> <!-- /Google ReCaptcha --> <?php /* * 2007-2016 PrestaShop * ... * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2016 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 Là il ne semble plus qu'on puisse envoyer de mail avec juste une url non ? j'aimerai bien savoir pourquoi ce que j'avais fait il y a un an fonctionnait avec cette erreur 😕 Link to comment Share on other sites More sharing options...
P i l o u Posted January 2, 2019 Share Posted January 2, 2019 Salut, Je crois que tu dois mettre le code juste avant le "require(dirname...." Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 C'est pas trop grave la licence est en commentaire donc pas interprétée. Mais c'est vrai que c'est mieux de suivre ce qu'on a dit^^ Pour le reste, le fait d'avoir ajouté un captcha a bloqué les spams "humains" et ton site avait la chance de ne pas encore être la cible des robots. Pour rappel le tuto est ici: https://shop.devcustom.net/fr/content/9-mise-en-place-captcha?content_only=1 Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 (edited) En fait tu t'es encore planté, tu as mis le code js dans le php. Relis le tuto dans l'ordre stp, parce que là, tout ton site est inaccessible^^ Edited January 2, 2019 by Eolia (see edit history) Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 je viens de le déplacer jusque avant le require(dirname, le site a quand même reçu une quinzaine de spams malgré le changement de code dans le bon index.php Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 (edited) relis mon message précédent stp, tu as mélangé les scripts (ou pas débourré du nouvel an^^) Pour rappel le tuto est ici: https://shop.devcustom.net/fr/content/9-mise-en-place-captcha?content_only=1 Edited January 2, 2019 by Eolia (see edit history) 1 Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 6 minutes ago, Eolia said: relis mon message précédent stp, tu as mélangé les scripts (ou pas débourré du nouvel an^^) Pour rappel le tuto est ici: https://shop.devcustom.net/fr/content/9-mise-en-place-captcha?content_only=1 oulala, en fait je sors de maladie, cela doit être ça plutôt 😂 Bon voilà je refais un point : Dans le fichier index.php, celui de la racine : <?php /* * ... * * @author PrestaShop SA <[email protected]> * @copyright 2007-2016 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if(isset($_REQUEST['submitMessage'])){ if (empty($_REQUEST['g-recaptcha-response'])){ sleep(25); die('not human'); } $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query( array( 'secret' => 'XXX', /* TODO: tune this https://www.google.com/recaptcha/admin */ 'response' => $_REQUEST['g-recaptcha-response'], ) ), ), ); $stream = stream_context_create($opts); $captcha = @json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $stream), true); if (empty($captcha) || empty($captcha['success']) || !$captcha['success']){ sleep(25); die('not human'.PHP_EOL.print_r($captcha,1)); } } require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); Et dans le fichier contact-form.tpl {* * ... * * @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} {capture name=path}{l s='Contact'}{/capture} <!-- Google ReCaptcha on contact form --> <script> var googlecaptchasitekey = 'XXX'; /* TODO: tune this https://www.google.com/recaptcha/admin */ $(document).ready(function(){ var $forms = $('form.contact-form-box'); if ($forms.length > 0){ var captcha = $('<div class="g-recaptcha" data-sitekey="'+ googlecaptchasitekey + '">'); var $submit = $forms.find('#submitMessage'); $submit.before(captcha); $submit.click(function(event){ if ($forms.find('#g-recaptcha-response').val().length == 0) { event.preventDefault(); event.stopPropagation(); return false; } }); } }); </script> <script src='https://www.google.com/recaptcha/api.js?hl={$language_code}'></script> <!-- /Google ReCaptcha --> <h1 class="page-heading bottom-indent"> Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 Bon après c'est l'ancien code que j'ai mis, pas celui du lien, tu me conseilles d'utiliser le code de ton lien ? Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 le code mis en place semble fonctionner donc vu ton état on va laisser comme ça, ok ? Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 ok je surveille les spams, voir s'ils reviennent comment as tu pu tester que le code mis en place fonctionnait ? Link to comment Share on other sites More sharing options...
Eolia Posted January 2, 2019 Share Posted January 2, 2019 clique sur l'url que je t'ai mis plus haut^^ 1 Link to comment Share on other sites More sharing options...
yannick.81 Posted January 2, 2019 Author Share Posted January 2, 2019 6 minutes ago, Eolia said: clique sur l'url que je t'ai mis plus haut^^ ah oui en effet merci pour ton aide précieuse en tout cas Link to comment Share on other sites More sharing options...
Epicapo Posted April 20, 2019 Share Posted April 20, 2019 bonjour a tous et a toutes, je m’incruste sur ce sujet car dans mon cas c'est un robot qui s'inscrit en tant que clients... sans cesse avec nouvelle adresse email évidemment :/ du coup je me demandais si ce systeme bloquait aussi ce genre de spam? J'ai le module iecaptcha qui affiche une erreur lors du test : the module is not registered in hook header Je me demande ce que je dois faire... la méthode ci-dessus necessite ce module ou dois-je le désinstaller? Enfin, dans le tuto, il parle du fichier contact-form.tpl où est situé ce fichier svp? Joyeuse Pâques à toutes et à tous ;) Merci d'avance. Link to comment Share on other sites More sharing options...
Janett Posted April 20, 2019 Share Posted April 20, 2019 (edited) Pour le problème des spams sur les comptes clients, ce n’est pas en rapport avec les spams russes. C’est encore d’autres casse-pieds. une solution est disponible la : https://www.prestashop.com/forums/topic/981158-securite-validation-des-clients-13-17/ Edited April 20, 2019 by Janett (see edit history) 1 Link to comment Share on other sites More sharing options...
Eolia Posted April 20, 2019 Share Posted April 20, 2019 Pour info le module eicaptcha ne controle rien en php et donc n'arrête pas les scripts robots. La seule solution gratuite qui fonctionne est celle-là https://shop.devcustom.net/fr/content/9-mise-en-place-captcha?content_only=1 Link to comment Share on other sites More sharing options...
Epicapo Posted April 20, 2019 Share Posted April 20, 2019 super merci de vos réponses hyper rapides!! c'est agaçant c'est trucs!! joyeuses paques, forcez pas trop sur le chocolat ahaha Link to comment Share on other sites More sharing options...
artistik Posted April 20, 2019 Share Posted April 20, 2019 4 hours ago, Eolia said: Pour info le module eicaptcha ne controle rien en php et donc n'arrête pas les scripts robots. La seule solution gratuite qui fonctionne est celle-là https://shop.devcustom.net/fr/content/9-mise-en-place-captcha?content_only=1 Eolia, j'ai teste cette methode aujourd'hui et elle a pas fonctionner pour le spam d'inscription... Link to comment Share on other sites More sharing options...
P i l o u Posted April 21, 2019 Share Posted April 21, 2019 Pour les inscriptions de bots, la solution est là : https://www.prestashop.com/forums/topic/981158-securite-validation-des-clients-13-17/ Link to comment Share on other sites More sharing options...
Eolia Posted April 21, 2019 Share Posted April 21, 2019 Il y a 9 heures, artistik a dit : Eolia, j'ai teste cette methode aujourd'hui et elle a pas fonctionner pour le spam d'inscription... Ah oui c'est vrai que j'ai oublié de préciser qu'il fallait utiliser son cerveau aussi... Cette méthode est générique et est applicable pour le formulaire de contact. Si vous ajoutez l'id de n'importe quel formulaire dans ces 2 scripts cela le rajoutera au formulaire. Exemple pour le formulaire d'inscription standard: if (isset($_REQUEST['submitMessage']) || isset($_REQUEST['submitAccount'])) { ... Et var $forms = $('form.contact-form-box,form#sendOrderMessage,form#account-creation_form'); 1 Link to comment Share on other sites More sharing options...
Eolia Posted April 21, 2019 Share Posted April 21, 2019 Les scripts ont été mis à jour pour ceux qui n'y arrivent pas tout seuls Link to comment Share on other sites More sharing options...
Epicapo Posted April 22, 2019 Share Posted April 22, 2019 bonjour et merci de vos réponses ultra rapide. je me rends de ce pas sur l'autre sujet du forum. Considérons que ma demande est réglé, si besoin j'interviendrai sur l'autre sujet bonne semaine ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now