Jump to content

Les spams russes reviennent, malgré recaptcha de google


Recommended Posts

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

 

Capture.PNG

Link to comment
Share on other sites

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&amp;[email protected]&amp;message=test&amp;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

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();

 

  • Like 1
Link to comment
Share on other sites

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

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

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

  • 3 months later...

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

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

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');

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...