[SPIP] ~v3.0.17-->v3.0.19
[ptitvelo/web/www.git] / www / config / ecran_securite.php
index 51e48df..bcf6179 100644 (file)
@@ -5,7 +5,7 @@
  * ------------------
  */
 
-define('_ECRAN_SECURITE', '1.1.5'); // 8 mars 2013
+define('_ECRAN_SECURITE', '1.2.2'); // 2014-12-01
 
 /*
  * Documentation : http://www.spip.net/fr_article4200.html
@@ -23,8 +23,14 @@ if (isset($_GET['test_ecran_securite']))
 if (!defined('_IS_BOT'))
        define('_IS_BOT',
                isset($_SERVER['HTTP_USER_AGENT'])
-               AND preg_match(',bot|slurp|crawler|spider|webvac|yandex|INA dlweb|EC2LinkFinder|80legs,i',
-                       (string) $_SERVER['HTTP_USER_AGENT'])
+               AND preg_match(
+           // mots generiques
+           ',bot|slurp|crawler|spider|webvac|yandex|'
+           // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
+           . 'MSIE 6\.0|'
+           // UA plus cibles
+           . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
+           . ',i',(string) $_SERVER['HTTP_USER_AGENT'])
        );
 
 /*
@@ -32,15 +38,19 @@ if (!defined('_IS_BOT'))
  * soit pas numérique (ce qui bloque l'exploitation de divers trous
  * de sécurité, dont celui de toutes les versions < 1.8.2f)
  * (sauf pour id_table, qui n'est pas numérique jusqu'à [5743])
+ * (id_base est une variable de la config des widgets de WordPress)
  */
 foreach ($_GET as $var => $val)
-       if ($_GET[$var] AND strncmp($var,"id_",3)==0 AND $var!='id_table')
+       if ($_GET[$var] AND strncmp($var,"id_",3)==0
+       AND !in_array($var, array('id_table','id_base')))
                $_GET[$var] = is_array($_GET[$var])?@array_map('intval',$_GET[$var]):intval($_GET[$var]);
 foreach ($_POST as $var => $val)
-       if ($_POST[$var] AND strncmp($var,"id_",3)==0 AND $var!='id_table')
+       if ($_POST[$var] AND strncmp($var,"id_",3)==0
+       AND !in_array($var, array('id_table','id_base')))
                $_POST[$var] = is_array($_POST[$var])?@array_map('intval',$_POST[$var]):intval($_POST[$var]);
 foreach ($GLOBALS as $var => $val)
-       if ($GLOBALS[$var] AND strncmp($var,"id_",3)==0 AND $var!='id_table')
+       if ($GLOBALS[$var] AND strncmp($var,"id_",3)==0
+       AND !in_array($var, array('id_table','id_base')))
                $GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval',$GLOBALS[$var]):intval($GLOBALS[$var]);
 
 /*
@@ -66,6 +76,14 @@ if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
        $file = addslashes((string)$_GET['file']);
 }
 
+/*
+ * Pas d'inscription abusive
+ */
+if (isset($_REQUEST['mode']) AND isset($_REQUEST['page'])
+AND !in_array($_REQUEST['mode'],array("6forum","1comite"))
+AND $_REQUEST['page'] == "identifiants")
+       $ecran_securite_raison = "identifiants";
+
 /*
  * Agenda joue à l'injection php
  */
@@ -212,6 +230,15 @@ if (count($_FILES)){
                        unset($_FILES[$k]);
        }
 }
+/*
+ * et Contact trop laxiste avec une variable externe
+ * on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout
+ */
+if (isset($_REQUEST['pj_enregistrees_nom']) AND $_REQUEST['pj_enregistrees_nom']){
+       unset($_REQUEST['pj_enregistrees_nom']);
+       unset($_GET['pj_enregistrees_nom']);
+       unset($_POST['pj_enregistrees_nom']);
+}
 
 /*
  * reinstall=oui un peu trop permissif
@@ -241,13 +268,13 @@ if (strpos($_SERVER['REQUEST_URI'],"ecrire/")!==false){
 if (isset($_REQUEST['connect'])
        AND
        // cas qui permettent de sortir d'un commentaire PHP
-       (strpos($_REQUEST['connect'], "?".">")!==false
+       (strpos($_REQUEST['connect'], "?")!==false
+        OR strpos($_REQUEST['connect'], "<")!==false
+        OR strpos($_REQUEST['connect'], ">")!==false
         OR strpos($_REQUEST['connect'], "\n")!==false
         OR strpos($_REQUEST['connect'], "\r")!==false)
        ) {
-       $_REQUEST['connect'] = str_replace(array("?".">", "\r", "\n"), "", $_REQUEST['connect']);
-       if (isset($_GET['connect'])) $_GET['connect'] = $_REQUEST['connect'];
-       if (isset($_POST['connect'])) $_POST['connect'] = $_REQUEST['connect'];
+       $ecran_securite_raison = "malformed connect argument";
 }
 
 /*
@@ -304,4 +331,4 @@ if (
 }
 
 
-?>
+?>
\ No newline at end of file