Skip to content
Extraits de code Groupes Projets
Valider 771909c1 rédigé par marcimat's avatar marcimat
Parcourir les fichiers

Un peu de PSR sur l’écran de sécu, notamment particulièrement ajouter les accolades sur les if !

parent 8a5a315e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -8,14 +8,15 @@ ...@@ -8,14 +8,15 @@
define('_ECRAN_SECURITE', '1.3.13'); // 2019-12-04 define('_ECRAN_SECURITE', '1.3.13'); // 2019-12-04
/* /*
* Documentation : http://www.spip.net/fr_article4200.html * Documentation : https://www.spip.net/fr_article4200.html
*/ */
/* /*
* Test utilisateur * Test utilisateur
*/ */
if (isset($_GET['test_ecran_securite'])) if (isset($_GET['test_ecran_securite'])) {
$ecran_securite_raison = 'test '._ECRAN_SECURITE; $ecran_securite_raison = 'test ' . _ECRAN_SECURITE;
}
/* /*
* Monitoring * Monitoring
...@@ -23,215 +24,221 @@ if (isset($_GET['test_ecran_securite'])) ...@@ -23,215 +24,221 @@ if (isset($_GET['test_ecran_securite']))
* var_isbot=1 peut etre utilise pour monitorer la disponibilite pour les bots (sujets a 503 de delestage si * var_isbot=1 peut etre utilise pour monitorer la disponibilite pour les bots (sujets a 503 de delestage si
* le load depasse ECRAN_SECURITE_LOAD) * le load depasse ECRAN_SECURITE_LOAD)
*/ */
if (!defined('_IS_BOT') and isset($_GET['var_isbot'])){ if (!defined('_IS_BOT') and isset($_GET['var_isbot'])) {
define('_IS_BOT', $_GET['var_isbot'] ? true : false); define('_IS_BOT', $_GET['var_isbot'] ? true : false);
} }
/* /*
* Détecteur de robot d'indexation * Détecteur de robot d'indexation
*/ */
if (!defined('_IS_BOT')){ if (!defined('_IS_BOT')) {
define('_IS_BOT', define(
'_IS_BOT',
isset($_SERVER['HTTP_USER_AGENT']) isset($_SERVER['HTTP_USER_AGENT'])
and preg_match(',' and preg_match(
. implode ('|', array( ','
// mots generiques . implode('|', array(
'bot', // mots generiques
'slurp', 'bot',
'crawler', 'slurp',
'crwlr', 'crawler',
'java', 'crwlr',
'monitoring', 'java',
'spider', 'monitoring',
'webvac', 'spider',
'yandex', 'webvac',
'MSIE 6\.0', // botnet 99,9% du temps 'yandex',
// UA plus cibles 'MSIE 6\.0', // botnet 99,9% du temps
'200please', // UA plus cibles
'80legs', '200please',
'a6-indexer', '80legs',
'aboundex', 'a6-indexer',
'accoona', 'aboundex',
'acrylicapps', 'accoona',
'addthis', 'acrylicapps',
'adressendeutschland', 'addthis',
'alexa', 'adressendeutschland',
'altavista', 'alexa',
'analyticsseo', 'altavista',
'antennapod', 'analyticsseo',
'arachnys', 'antennapod',
'archive', 'arachnys',
'argclrint', 'archive',
'aspseek', 'argclrint',
'baidu', 'aspseek',
'begunadvertising', 'baidu',
'bing', 'begunadvertising',
'bloglines', 'bing',
'buck', 'bloglines',
'browsershots', 'buck',
'bubing', 'browsershots',
'butterfly', 'bubing',
'changedetection', 'butterfly',
'charlotte', 'changedetection',
'chilkat', 'charlotte',
'china', 'chilkat',
'coccoc', 'china',
'crowsnest', 'coccoc',
'dataminr', 'crowsnest',
'daumoa', 'dataminr',
'dlvr\.it', 'daumoa',
'dlweb', 'dlvr\.it',
'drupal', 'dlweb',
'ec2linkfinder', 'drupal',
'eset\.com', 'ec2linkfinder',
'estyle', 'eset\.com',
'exalead', 'estyle',
'ezooms', 'exalead',
'facebookexternalhit', 'ezooms',
'facebookplatform', 'facebookexternalhit',
'fairshare', 'facebookplatform',
'feedfetcher', 'fairshare',
'feedfetcher-google', 'feedfetcher',
'feedly', 'feedfetcher-google',
'fetch', 'feedly',
'flipboardproxy', 'fetch',
'genieo', 'flipboardproxy',
'google', 'genieo',
'go-http-client', 'google',
'grapeshot', 'go-http-client',
'hatena-useragent', 'grapeshot',
'head', 'hatena-useragent',
'hosttracker', 'head',
'hubspot', 'hosttracker',
'ia_archiver', 'hubspot',
'ichiro', 'ia_archiver',
'iltrovatore-setaccio', 'ichiro',
'immediatenet', 'iltrovatore-setaccio',
'ina', 'immediatenet',
'inoreader', 'ina',
'infegyatlas', 'inoreader',
'infohelfer', 'infegyatlas',
'instapaper', 'infohelfer',
'jabse', 'instapaper',
'james', 'jabse',
'jersey', 'james',
'kumkie', 'jersey',
'linkdex', 'kumkie',
'linkfluence', 'linkdex',
'linkwalker', 'linkfluence',
'litefinder', 'linkwalker',
'loadimpactpageanalyzer', 'litefinder',
'ltx71', 'loadimpactpageanalyzer',
'luminate', 'ltx71',
'lycos', 'luminate',
'lycosa', 'lycos',
'mediapartners-google', 'lycosa',
'msai', 'mediapartners-google',
'myapp', 'msai',
'nativehost', 'myapp',
'najdi', 'nativehost',
'netcraftsurveyagent', 'najdi',
'netestate', 'netcraftsurveyagent',
'netseer', 'netestate',
'netnewswire', 'netseer',
'newspaper', 'netnewswire',
'newsblur', 'newspaper',
'nuhk', 'newsblur',
'nuzzel', 'nuhk',
'okhttp', 'nuzzel',
'otmedia', 'okhttp',
'owlin', 'otmedia',
'owncloud', 'owlin',
'panscient', 'owncloud',
'paper\.li', 'panscient',
'parsijoo', 'paper\.li',
'protopage', 'parsijoo',
'plukkie', 'protopage',
'proximic', 'plukkie',
'pubsub', 'proximic',
'python', 'pubsub',
'qirina', 'python',
'qoshe', 'qirina',
'qualidator', 'qoshe',
'qwantify', 'qualidator',
'rambler', 'qwantify',
'readability', 'rambler',
'ruby', 'readability',
'sbsearch', 'ruby',
'scoop\.it', 'sbsearch',
'scooter', 'scoop\.it',
'scoutjet', 'scooter',
'scrapy', 'scoutjet',
'scrubby', 'scrapy',
'scrubbybloglines', 'scrubby',
'shareaholic', 'scrubbybloglines',
'shopwiki', 'shareaholic',
'simplepie', 'shopwiki',
'sistrix', 'simplepie',
'sitechecker', 'sistrix',
'siteexplorer', 'sitechecker',
'snapshot', 'siteexplorer',
'sogou', 'snapshot',
'special_archiver', 'sogou',
'speedy', 'special_archiver',
'spinn3r', 'speedy',
'spreadtrum', 'spinn3r',
'steeler', 'spreadtrum',
'subscriber', 'steeler',
'suma', 'subscriber',
'superdownloads', 'suma',
'svenska-webbsido', 'superdownloads',
'teoma', 'svenska-webbsido',
'the knowledge AI', 'teoma',
'thumbshots', 'the knowledge AI',
'tineye', 'thumbshots',
'traackr', 'tineye',
'trendiction', 'traackr',
'trendsmap', 'trendiction',
'tweetedtimes', 'trendsmap',
'tweetmeme', 'tweetedtimes',
'universalfeedparser', 'tweetmeme',
'uaslinkchecker', 'universalfeedparser',
'undrip', 'uaslinkchecker',
'unwindfetchor', 'undrip',
'upday', 'unwindfetchor',
'vedma', 'upday',
'vkshare', 'vedma',
'vm', 'vkshare',
'wch', 'vm',
'webalta', 'wch',
'webcookies', 'webalta',
'webparser', 'webcookies',
'webthumbnail', 'webparser',
'wesee', 'webthumbnail',
'wise-guys', 'wesee',
'woko', 'wise-guys',
'wordpress', 'woko',
'wotbox', 'wordpress',
'y!j-bri', 'wotbox',
'y!j-bro', 'y!j-bri',
'y!j-brw', 'y!j-bro',
'y!j-bsc', 'y!j-brw',
'yahoo', 'y!j-bsc',
'yahoo!', 'yahoo',
'yahooysmcm', 'yahoo!',
'ymobactus', 'yahooysmcm',
'yats', 'ymobactus',
'yeti', 'yats',
'zeerch' 'yeti',
)) . ',i', 'zeerch'
(string)$_SERVER['HTTP_USER_AGENT']) )) . ',i',
(string)$_SERVER['HTTP_USER_AGENT']
)
); );
} }
if (!defined('_IS_BOT_FRIEND')){ if (!defined('_IS_BOT_FRIEND')) {
define('_IS_BOT_FRIEND', define(
'_IS_BOT_FRIEND',
isset($_SERVER['HTTP_USER_AGENT']) isset($_SERVER['HTTP_USER_AGENT'])
and preg_match(',' . implode ('|', array( and preg_match(
'facebookexternalhit', ',' . implode('|', array(
'flipboardproxy', 'facebookexternalhit',
'wordpress' 'flipboardproxy',
)) . ',i', 'wordpress'
(string)$_SERVER['HTTP_USER_AGENT']) )) . ',i',
(string)$_SERVER['HTTP_USER_AGENT']
)
); );
} }
...@@ -242,19 +249,31 @@ if (!defined('_IS_BOT_FRIEND')){ ...@@ -242,19 +249,31 @@ if (!defined('_IS_BOT_FRIEND')){
* (sauf pour id_table, qui n'est pas numérique jusqu'à [5743]) * (sauf pour id_table, qui n'est pas numérique jusqu'à [5743])
* (id_base est une variable de la config des widgets de WordPress) * (id_base est une variable de la config des widgets de WordPress)
*/ */
$_exceptions = array('id_table','id_base','id_parent','id_article_pdf'); $_exceptions = array('id_table', 'id_base', 'id_parent', 'id_article_pdf');
foreach ($_GET as $var => $val) foreach ($_GET as $var => $val) {
if ($_GET[$var] and strncmp($var, "id_", 3) == 0 if (
and !in_array($var, $_exceptions)) $_GET[$var] and strncmp($var, "id_", 3) == 0
$_GET[$var] = is_array($_GET[$var])?@array_map('intval', $_GET[$var]):intval($_GET[$var]); and !in_array($var, $_exceptions)
foreach ($_POST as $var => $val) ) {
if ($_POST[$var] and strncmp($var, "id_", 3) == 0 $_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]);
and !in_array($var, $_exceptions)) }
$_POST[$var] = is_array($_POST[$var])?@array_map('intval', $_POST[$var]):intval($_POST[$var]); }
foreach ($GLOBALS as $var => $val) foreach ($_POST as $var => $val) {
if ($GLOBALS[$var] and strncmp($var, "id_", 3) == 0 if (
and !in_array($var, $_exceptions)) $_POST[$var] and strncmp($var, "id_", 3) == 0
$GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval', $GLOBALS[$var]):intval($GLOBALS[$var]); and !in_array($var, $_exceptions)
) {
$_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 !in_array($var, $_exceptions)
) {
$GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]);
}
}
/* /*
* Interdit la variable $cjpeg_command, qui était utilisée sans * Interdit la variable $cjpeg_command, qui était utilisée sans
...@@ -265,11 +284,13 @@ $cjpeg_command = ''; ...@@ -265,11 +284,13 @@ $cjpeg_command = '';
/* /*
* Contrôle de quelques variables (XSS) * Contrôle de quelques variables (XSS)
*/ */
foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) { foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
if (isset($_GET[$var])) if (isset($_GET[$var])) {
$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]); $_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
if (isset($_POST[$var])) }
if (isset($_POST[$var])) {
$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]); $_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
}
} }
/* /*
...@@ -284,63 +305,93 @@ if (isset($_SERVER['REQUEST_URI'])) { ...@@ -284,63 +305,93 @@ if (isset($_SERVER['REQUEST_URI'])) {
/* /*
* Pas d'inscription abusive * Pas d'inscription abusive
*/ */
if (isset($_REQUEST['mode']) and isset($_REQUEST['page']) if (
and !in_array($_REQUEST['mode'], array("6forum", "1comite")) isset($_REQUEST['mode']) and isset($_REQUEST['page'])
and $_REQUEST['page'] == "identifiants") and !in_array($_REQUEST['mode'], array("6forum", "1comite"))
and $_REQUEST['page'] == "identifiants"
) {
$ecran_securite_raison = "identifiants"; $ecran_securite_raison = "identifiants";
}
/* /*
* Agenda joue à l'injection php * Agenda joue à l'injection php
*/ */
if (isset($_REQUEST['partie_cal']) if (
and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])) isset($_REQUEST['partie_cal'])
and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])
) {
$ecran_securite_raison = "partie_cal"; $ecran_securite_raison = "partie_cal";
if (isset($_REQUEST['echelle']) }
and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])) if (
isset($_REQUEST['echelle'])
and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])
) {
$ecran_securite_raison = "echelle"; $ecran_securite_raison = "echelle";
}
/* /*
* Espace privé * Espace privé
*/ */
if (isset($_REQUEST['exec']) if (
and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])) isset($_REQUEST['exec'])
and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])
) {
$ecran_securite_raison = "exec"; $ecran_securite_raison = "exec";
if (isset($_REQUEST['cherche_auteur']) }
and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])) if (
isset($_REQUEST['cherche_auteur'])
and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])
) {
$ecran_securite_raison = "cherche_auteur"; $ecran_securite_raison = "cherche_auteur";
if (isset($_REQUEST['exec']) }
and $_REQUEST['exec'] == 'auteurs' if (
and preg_match(',[<],', (string)$_REQUEST['recherche'])) isset($_REQUEST['exec'])
and $_REQUEST['exec'] == 'auteurs'
and preg_match(',[<],', (string)$_REQUEST['recherche'])
) {
$ecran_securite_raison = "recherche"; $ecran_securite_raison = "recherche";
if (isset($_REQUEST['exec']) }
and $_REQUEST['exec'] == 'info_plugin' if (
and preg_match(',[<],', (string)$_REQUEST['plugin'])) isset($_REQUEST['exec'])
and $_REQUEST['exec'] == 'info_plugin'
and preg_match(',[<],', (string)$_REQUEST['plugin'])
) {
$ecran_securite_raison = "plugin"; $ecran_securite_raison = "plugin";
if (isset($_REQUEST['exec']) }
and $_REQUEST['exec'] == 'puce_statut' if (
and isset($_REQUEST['id']) isset($_REQUEST['exec'])
and !intval($_REQUEST['id'])) and $_REQUEST['exec'] == 'puce_statut'
and isset($_REQUEST['id'])
and !intval($_REQUEST['id'])
) {
$ecran_securite_raison = "puce_statut"; $ecran_securite_raison = "puce_statut";
if (isset($_REQUEST['action']) }
and $_REQUEST['action'] == 'configurer') { if (
if (@file_exists('inc_version.php') isset($_REQUEST['action'])
or @file_exists('ecrire/inc_version.php')) { and $_REQUEST['action'] == 'configurer'
) {
if (
@file_exists('inc_version.php')
or @file_exists('ecrire/inc_version.php')
) {
function action_configurer() { function action_configurer() {
include_spip('inc/autoriser'); include_spip('inc/autoriser');
if(!autoriser('configurer', _request('configuration'))) { if (!autoriser('configurer', _request('configuration'))) {
include_spip('inc/minipres'); include_spip('inc/minipres');
echo minipres(_T('info_acces_interdit')); echo minipres(_T('info_acces_interdit'));
exit; exit;
} }
require _DIR_RESTREINT.'action/configurer.php'; require _DIR_RESTREINT . 'action/configurer.php';
action_configurer_dist(); action_configurer_dist();
} }
} }
} }
if (isset($_REQUEST['action']) if (
and $_REQUEST['action'] == 'ordonner_liens_documents' isset($_REQUEST['action'])
and isset($_REQUEST['ordre']) and $_REQUEST['action'] == 'ordonner_liens_documents'
and is_string($_REQUEST['ordre'])){ and isset($_REQUEST['ordre'])
and is_string($_REQUEST['ordre'])
) {
$ecran_securite_raison = "ordre a la chaine"; $ecran_securite_raison = "ordre a la chaine";
} }
...@@ -349,59 +400,74 @@ and is_string($_REQUEST['ordre'])){ ...@@ -349,59 +400,74 @@ and is_string($_REQUEST['ordre'])){
* Bloque les requêtes contenant %00 (manipulation d'include) * Bloque les requêtes contenant %00 (manipulation d'include)
*/ */
if (strpos( if (strpos(
(function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc()) ? (function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc())
stripslashes(serialize($_REQUEST)) : serialize($_REQUEST), ? stripslashes(serialize($_REQUEST))
: serialize($_REQUEST),
chr(0) chr(0)
) !== false) ) !== false) {
$ecran_securite_raison = "%00"; $ecran_securite_raison = "%00";
}
/* /*
* Bloque les requêtes fond=formulaire_ * Bloque les requêtes fond=formulaire_
*/ */
if (isset($_REQUEST['fond']) if (
and preg_match(',^formulaire_,i', $_REQUEST['fond'])) isset($_REQUEST['fond'])
and preg_match(',^formulaire_,i', $_REQUEST['fond'])
) {
$ecran_securite_raison = "fond=formulaire_"; $ecran_securite_raison = "fond=formulaire_";
}
/* /*
* Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php) * Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php)
*/ */
if (isset($_REQUEST['GLOBALS'])) if (isset($_REQUEST['GLOBALS'])) {
$ecran_securite_raison = "GLOBALS[GLOBALS]"; $ecran_securite_raison = "GLOBALS[GLOBALS]";
}
/* /*
* Bloque les requêtes des bots sur: * Bloque les requêtes des bots sur:
* les agenda * les agenda
* les paginations entremélées * les paginations entremélées
*/ */
if (_IS_BOT and ( if (_IS_BOT) {
(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type'])) if (
or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI'])) (isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_') ) or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_'))
or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI'])) or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
) ) {
) $ecran_securite_raison = "robot agenda/double pagination";
$ecran_securite_raison = "robot agenda/double pagination"; }
}
/* /*
* Bloque une vieille page de tests de CFG (<1.11) * Bloque une vieille page de tests de CFG (<1.11)
* Bloque un XSS sur une page inexistante * Bloque un XSS sur une page inexistante
*/ */
if (isset($_REQUEST['page'])) { if (isset($_REQUEST['page'])) {
if ($_REQUEST['page'] == 'test_cfg') if ($_REQUEST['page'] == 'test_cfg') {
$ecran_securite_raison = "test_cfg"; $ecran_securite_raison = "test_cfg";
if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) }
if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
$ecran_securite_raison = "xsspage"; $ecran_securite_raison = "xsspage";
if ($_REQUEST['page'] == '404' }
and isset($_REQUEST['erreur'])) if (
$_REQUEST['page'] == '404'
and isset($_REQUEST['erreur'])
) {
$ecran_securite_raison = "xss404"; $ecran_securite_raison = "xss404";
}
} }
/* /*
* XSS par array * XSS par array
*/ */
foreach (array('var_login') as $var) foreach (array('var_login') as $var) {
if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) {
$ecran_securite_raison = "xss ".$var; $ecran_securite_raison = "xss " . $var;
}
}
/* /*
* Parade antivirale contre un cheval de troie * Parade antivirale contre un cheval de troie
...@@ -411,28 +477,33 @@ if (!function_exists('tmp_lkojfghx')) { ...@@ -411,28 +477,33 @@ if (!function_exists('tmp_lkojfghx')) {
function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) { function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
// si jamais on est arrivé ici sur une erreur php // si jamais on est arrivé ici sur une erreur php
// et qu'un autre gestionnaire d'erreur est défini, l'appeller // et qu'un autre gestionnaire d'erreur est défini, l'appeller
if ($b && $GLOBALS['tmp_xhgfjokl']) if ($b && $GLOBALS['tmp_xhgfjokl']) {
call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d); call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
}
} }
} }
if (isset($_POST['tmp_lkojfghx3'])) if (isset($_POST['tmp_lkojfghx3'])) {
$ecran_securite_raison = "gumblar"; $ecran_securite_raison = "gumblar";
}
/* /*
* Outils XML mal sécurisés < 2.0.9 * Outils XML mal sécurisés < 2.0.9
*/ */
if (isset($_REQUEST['transformer_xml'])) if (isset($_REQUEST['transformer_xml'])) {
$ecran_securite_raison = "transformer_xml"; $ecran_securite_raison = "transformer_xml";
}
/* /*
* Outils XML mal sécurisés again * Outils XML mal sécurisés again
*/ */
if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec']=='valider_xml'){ if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec'] == 'valider_xml') {
$url = trim($_REQUEST['var_url']); $url = trim($_REQUEST['var_url']);
if (strncmp($url,'/',1)==0 if (
or (($p=strpos($url,'..'))!==false AND strpos($url,'..',$p+3)!==false) strncmp($url, '/', 1) == 0
or (($p=strpos($url,'..'))!==false AND strpos($url,'IMG',$p+3)!==false) or (($p = strpos($url, '..')) !== false and strpos($url, '..', $p + 3) !== false)
or (strpos($url,'://')!==false or strpos($url,':\\')!==false)) { or (($p = strpos($url, '..')) !== false and strpos($url, 'IMG', $p + 3) !== false)
or (strpos($url, '://') !== false or strpos($url, ':\\') !== false)
) {
$ecran_securite_raison = 'URL interdite pour var_url'; $ecran_securite_raison = 'URL interdite pour var_url';
} }
} }
...@@ -440,37 +511,49 @@ if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['ex ...@@ -440,37 +511,49 @@ if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['ex
/* /*
* Sauvegarde mal securisée < 2.0.9 * Sauvegarde mal securisée < 2.0.9
*/ */
if (isset($_REQUEST['nom_sauvegarde']) if (
and strstr((string)$_REQUEST['nom_sauvegarde'], '/')) isset($_REQUEST['nom_sauvegarde'])
and strstr((string)$_REQUEST['nom_sauvegarde'], '/')
) {
$ecran_securite_raison = 'nom_sauvegarde manipulee'; $ecran_securite_raison = 'nom_sauvegarde manipulee';
if (isset($_REQUEST['znom_sauvegarde']) }
and strstr((string)$_REQUEST['znom_sauvegarde'], '/')) if (
isset($_REQUEST['znom_sauvegarde'])
and strstr((string)$_REQUEST['znom_sauvegarde'], '/')
) {
$ecran_securite_raison = 'znom_sauvegarde manipulee'; $ecran_securite_raison = 'znom_sauvegarde manipulee';
}
/* /*
* op permet des inclusions arbitraires ; * op permet des inclusions arbitraires ;
* on vérifie 'page' pour ne pas bloquer ... drupal * on vérifie 'page' pour ne pas bloquer ... drupal
*/ */
if (isset($_REQUEST['op']) and isset($_REQUEST['page']) if (
and $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op'])) isset($_REQUEST['op']) and isset($_REQUEST['page'])
and $_REQUEST['op'] !== preg_replace('/[^\-\w]/', '', $_REQUEST['op'])
) {
$ecran_securite_raison = 'op'; $ecran_securite_raison = 'op';
}
/* /*
* Forms & Table ne se méfiait pas assez des uploads de fichiers * Forms & Table ne se méfiait pas assez des uploads de fichiers
*/ */
if (count($_FILES)){ if (count($_FILES)) {
foreach($_FILES as $k => $v){ foreach ($_FILES as $k => $v) {
if (preg_match(',^fichier_\d+$,', $k) if (
and preg_match(',\.php,i', $v['name'])) preg_match(',^fichier_\d+$,', $k)
unset($_FILES[$k]); and preg_match(',\.php,i', $v['name'])
) {
unset($_FILES[$k]);
}
} }
} }
/* /*
* et Contact trop laxiste avec une variable externe * 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 * 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']){ if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']) {
unset($_REQUEST['pj_enregistrees_nom']); unset($_REQUEST['pj_enregistrees_nom']);
unset($_GET['pj_enregistrees_nom']); unset($_GET['pj_enregistrees_nom']);
unset($_POST['pj_enregistrees_nom']); unset($_POST['pj_enregistrees_nom']);
...@@ -479,9 +562,12 @@ if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom'] ...@@ -479,9 +562,12 @@ if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']
/* /*
* reinstall=oui un peu trop permissif * reinstall=oui un peu trop permissif
*/ */
if (isset($_REQUEST['reinstall']) if (
and $_REQUEST['reinstall'] == 'oui') isset($_REQUEST['reinstall'])
and $_REQUEST['reinstall'] == 'oui'
) {
$ecran_securite_raison = 'reinstall=oui'; $ecran_securite_raison = 'reinstall=oui';
}
/* /*
* Pas d'action pendant l'install * Pas d'action pendant l'install
...@@ -493,23 +579,26 @@ if (isset($_REQUEST['exec']) and $_REQUEST['exec'] === 'install' and isset($_REQ ...@@ -493,23 +579,26 @@ if (isset($_REQUEST['exec']) and $_REQUEST['exec'] === 'install' and isset($_REQ
/* /*
* Échappement xss referer * Échappement xss referer
*/ */
if (isset($_SERVER['HTTP_REFERER'])) if (isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##'); $_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
}
/* /*
* Echappement HTTP_X_FORWARDED_HOST * Echappement HTTP_X_FORWARDED_HOST
*/ */
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________'); $_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
}
/* /*
* Pas d'erreur dans l'erreur * Pas d'erreur dans l'erreur
*/ */
if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['page'] === 'login') { if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['page'] === 'login') {
if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) {
$ecran_securite_raison = 'var_erreur incorrecte'; $ecran_securite_raison = 'var_erreur incorrecte';
}
} }
...@@ -519,24 +608,27 @@ if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['p ...@@ -519,24 +608,27 @@ if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['p
if ( if (
(isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false) (isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
or isset($_REQUEST['var_memotri']) or isset($_REQUEST['var_memotri'])
){ ) {
$zzzz = implode("", array_keys($_REQUEST)); $zzzz = implode("", array_keys($_REQUEST));
if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) {
$ecran_securite_raison = 'Cle incorrecte en $_REQUEST'; $ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
}
} }
/* /*
* Injection par connect * Injection par connect
*/ */
if (isset($_REQUEST['connect']) if (
and isset($_REQUEST['connect'])
// cas qui permettent de sortir d'un commentaire PHP // cas qui permettent de sortir d'un commentaire PHP
(strpos($_REQUEST['connect'], "?") !== false and (
or 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'], ">") !== false
or strpos($_REQUEST['connect'], "\r") !== false) or strpos($_REQUEST['connect'], "\n") !== false
) { or strpos($_REQUEST['connect'], "\r") !== false
)
) {
$ecran_securite_raison = "malformed connect argument"; $ecran_securite_raison = "malformed connect argument";
} }
...@@ -572,8 +664,9 @@ if (!function_exists('filtre_filtrer_entites_dist')) { ...@@ -572,8 +664,9 @@ if (!function_exists('filtre_filtrer_entites_dist')) {
/* /*
* Bloque les bots quand le load déborde * Bloque les bots quand le load déborde
*/ */
if (!defined('_ECRAN_SECURITE_LOAD')) if (!defined('_ECRAN_SECURITE_LOAD')) {
define('_ECRAN_SECURITE_LOAD', 4); define('_ECRAN_SECURITE_LOAD', 4);
}
if ( if (
defined('_ECRAN_SECURITE_LOAD') defined('_ECRAN_SECURITE_LOAD')
...@@ -583,15 +676,13 @@ if ( ...@@ -583,15 +676,13 @@ if (
and $_SERVER['REQUEST_METHOD'] === 'GET' and $_SERVER['REQUEST_METHOD'] === 'GET'
and ( and (
(function_exists('sys_getloadavg') (function_exists('sys_getloadavg')
and $load = sys_getloadavg() and $load = sys_getloadavg()
and is_array($load) and is_array($load)
and $load = array_shift($load) and $load = array_shift($load))
)
or or
(@is_readable('/proc/loadavg') (@is_readable('/proc/loadavg')
and $load = file_get_contents('/proc/loadavg') and $load = file_get_contents('/proc/loadavg')
and $load = floatval($load) and $load = floatval($load))
)
) )
and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
and rand(0, $load * $load) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD and rand(0, $load * $load) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD
...@@ -605,4 +696,3 @@ if ( ...@@ -605,4 +696,3 @@ if (
header("Content-Type: text/html"); header("Content-Type: text/html");
die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>"); die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>");
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter