Сайт сообщества | Клуб пользователей | О проекте

Имя
Пароль
ПравилаРегистрацияСправка
Сообщения за деньПоиск

Вернуться   Клуб пользователей портальной системы RUNCMS > Портал > Установка

 
 
Опции темы Опции просмотра
iltmpz вне форума iltmpz
Младший участник


| Цитировать Старый #1 10-04-2010, 04:31

Поставил версию 1.6.2 отсюда: http://www.runcms.ru/modules/files/showfile.php?lid=524
Кроме того, поставил модули:
photo: http://www.runcms.ru/modules/files/showfile.php?lid=477
myarticles: http://www.runcms.ru/modules/files/showfile.php?lid=460
запустил, стал тестировать. Оказалось, что практически каждый тестируемый элемент содержит ошибку. Не знаю, зачем настолько сырую версию выложили в общий доступ, но во всяком случае я взялся за исправление ошибок.
Мой фикс не содержит никаких "красивостей" - только исправление того, что работает не так, как предполагалось, плюс максимально доступное мне повышение безопасности.
Пишу на случай, если вдруг кто из новичков решит ставить систему "с нуля". Я потратил на это тестирование 2 месяца - может, кому-нибудь это поможет сэкономить время. Все исправления - в одном месте.
Выложу список в виде diff-файла с комментариями (если кто решит это применить командой patch - сначала уберите мои комментарии, начинающиеся с "#").
PHP код:
# защита от sql-инъекций: http://www.runcms.ru/forum/showthread.php?t=10212
diff -r orig/class/class_sql_inject.php my/class/class_sql_inject.php
95,133c95,143
<         $sRQ = strtolower($sRQ);
<         $this->rq = $sRQ;
<         $aValues = array();
<         $aTemp = array(); // temp array
<         $aWords = array(); //
<         $aSep = array(' and ',' or '); // separators for detect the
<         $sConditions = '(';
<         $matches = array();
<         $sSep = '';
<         // is there an attempt to unused part of the rq?
<         if (is_int((strpos($sRQ,"#")))&&$this->_in_post('#')) return $this->detect();

<         ## Dogman Begin
< //        if (ereg("union select",$sRQ) || ereg("union all",$sRQ))   return $this->detect();
<         if (stristr($sRQ,'/*') || stristr($sRQ,'*/')) return $this->detect();
<         if (stristr($sRQ,'%20union') || stristr($sRQ,'union%20'))   return $this->detect();
<         if (stristr($sRQ,'/union') || stristr($sRQ,'union/'))   return $this->detect();
<         if (ereg("exec",$sRQ) || ereg("cmd",$sRQ))   return $this->detect();
<         if (ereg("concat",$sRQ)) return $this->detect();
<         ## etwas unglьcklich mit den "--" , das geht vielleicht noch besser...

<         ## I'm not happy with this "--"; could be improved....
<         if (ereg("--",$sRQ) || ereg("xp_",$sRQ))   return $this->detect();
<         ## Dogman end

<         // is there a attempt to do a 2nd SQL requete ?
<         ## Tja, leider kommt in einem Text auch schon mal mehr als
<         ## nur ein Semikolon vor...
<         ## Hier muss also noch nachgebessert werden...

<         ## There can be more than just one semicolon...

<         if (is_int(strpos($sRQ,';'))){
<             $aTemp = explode(';',$sRQ);
<             if ($this->_in_post($aTemp[1])) return $this->detect();
<         }


<         $aTemp = explode(" where ",$sRQ);
---
>     // filter rewritten by LARK
>         $this->rq = $sRQ;
>         $sRQ = strtolower(urldecode($sRQ)); // URL Decode
>         $sRQ = str_replace( chr(0) , '' , $sRQ ) ;  // replace NullByte
>         $aValues = array();
>         $aTemp = array(); // temp array
>         $aWords = array(); //
>         $aSep = array(' and ',' or '); // separators for detect the
>         $sConditions = '(';
>         $matches = array();
>         $sSep = '';
>         
>         $sql_inject_patterns = array(
>         '--',
>         '\/\*',
>         '\*\/',
>         '\'',
>         '"',
>         '(union([\s\+\(\n\r\t]+)(select|all))',
>         '[\s\+\n\r\t\(]+select[\s\+\n\r\t\)\'"`]+',
>         '[\s\+\n\r\t\)`]+where[\s\+\n\r\t\(`]*',
>         '[\s\+\n\r\t\)\'"`]+(from|regexp|rlike|delete|update|insert|truncate|drop|create|rename)[\s\+\n\r\t\(`]+',
>         'exec',
>         'cmd',
>         'xp_',
>         'information_schema\.',
>         '[\s\+\n\r\t\)\'"`]*(or|and)[\s\+\n\r\t\(\'"]+(.*?)[\s\+\n\r\t\'"]*[=<>]+[\s\+\n\r\t\'"]*(.*?)',
>         '(concat|load_file|mid|like|ord|ascii|lower|lcase|find_in_set|substring|benchmark|md5)[\s\+\n\r\t]*\('
>         );
>                
>         // is there an attempt to unused part of the rq?
>         if (is_int((strpos($sRQ,"#")))&&$this->_in_post('#')) return $this->detect();
>         
>         if (preg_match('/' . implode('|', $sql_inject_patterns) . '/is', $sRQ, $regs)) return $this->detect();
>         
>         // is there a attempt to do a 2nd SQL requete ?
>         ## Tja, leider kommt in einem Text auch schon mal mehr als
>         ## nur ein Semikolon vor...
>         ## Hier muss also noch nachgebessert werden...

>         ## There can be more than just one semicolon...

>         if (is_int(strpos($sRQ,';'))){
>             $aTemp = explode(';',$sRQ);
>             if ($this->_in_post($aTemp[1])) return $this->detect();
>         }

>         $aTemp = preg_split('/[\s\+\)]+where[\s\+\(]*/i', $sRQ, -1, PREG_SPLIT_NO_EMPTY);  
>     
212c222
< ?>
\ No newline at end of file
---
> ?>
# защита хеша в cookies при авторизации: http://www.runcms.ru/forum/showthread.php?t=10424
# не показывает новые личные сообщения: http://www.runcms.ru/forum/showthread.php?t=10481
diff -r orig/class/sessions.class.php my/class/sessions.class.php
136c136
<         $this->hash = rc_shatool($this->pass.$this->salt);
---
>         $this->hash = rc_shatool($this->pass.$this->salt. rc_shatool($xoopsConfig['dbhost'] . $xoopsConfig['dbuname'] . $xoopsConfig['dbpass'] . $xoopsConfig['dbname']));
238,240c238,251
<         $sql = "SELECT u.*, s.hash, s.online FROM ".RC_USERS_TBL." u
<         LEFT JOIN ".RC_SESS_TBL." s ON u.uid=s.uid
<         WHERE s.uid=".$uid." AND s.hash='".$uhash."'";
---
>          $module = XoopsModule::getByDirname('messages');

>          if ($module && $module->isActivated()) {

>              $sql = "SELECT u.*, s.hash, s.online, (COUNT(m.to_userid) - SUM(m.read_msg)) AS user_new_privmsg, COUNT(m.to_userid) AS user_privmsg FROM ".RC_USERS_TBL." u
>              LEFT JOIN ".RC_SESS_TBL." s ON u.uid=s.uid LEFT JOIN ".$db->prefix("private_msgs")." m ON m.to_userid=u.uid
>              WHERE s.uid=".$uid." AND s.hash='".$uhash."' GROUP BY u.uid";

>          } else {

>              $sql = "SELECT u.*, s.hash, s.online FROM ".RC_USERS_TBL." u
>              LEFT JOIN ".RC_SESS_TBL." s ON u.uid=s.uid
>              WHERE s.uid=".$uid." AND s.hash='".$uhash."'";
>          }
322c333
<         $hash = rc_shatool($this->pass.$this->salt);
---
>         $hash = rc_shatool($this->pass.$this->salt. rc_shatool($xoopsConfig['dbhost'] . $xoopsConfig['dbuname'] . $xoopsConfig['dbpass'] . $xoopsConfig['dbname']));
# комментарий удалившегося пользователя приводил к ошибке, все последующие комментарии обрезались
diff -r orig/class/xoopscomments.php my/class/xoopscomments.php
362a363
>       if($poster!==NULL)
508c509
< ?>
\ No newline at end of file
---
> ?>
# не помню, что это, нашел на форуме, исправление ошибки
diff -r orig/class/xoopstree.php my/class/xoopstree.php
227a228
>      if ($cid == 0) return $idarray;
242c243,244
<                $r_id = $r[$this->pid];
---
>                $r_id = $i[$this->pid];
>            if ($r_id == 0) return $idarray;  
# http://runcms.ru/forum/showthread.php?t=9817
diff -r orig/class/xoopsuser.php my/class/xoopsuser.php
151,153c151,156
<       $uh = xoops_gethandler('user');
<       if($uh->exists($id))
<          return $uh->get($id);
---
>       $uh = xoops_gethandler('user');
>       if($uh->exists($id)) {
>          $_user = $uh->get($id);
>          foreach ($_user->vars as $k => $v) $this->setVar($k, $v['value']);
>          return;
>       }  
1064a1068,1069
>      $rcuser->setVar('pass', $shapwd);
>      $rcuser->setVar('pwdsalt', $myrow['pwdsalt']);
1076c1081
< ?>
\ No newline at end of file
---
> ?>
# дополнительная защита, не помешает: http://www.runcms.ru/forum/showthread.php?t=10203
diff -r orig/include/common.php my/include/common.php
82a83
>    session_name($xoopsConfig['session_name']);
286a288,300
> if (strpos( _SCRIPT_NAME, 'admin')){
>     if ($xoopsUser) {
>        if ( !$xoopsUser->isAdmin(($xoopsModule) ? $xoopsModule->mid(): null) ) {
>             header('Status: 302 Found');
>             header('Location:'.XOOPS_URL.'/abuse.php');
>             exit();
>        }
>     } else {
>        header('Status: 302 Found');
>        header('Location:'.XOOPS_URL.'/abuse.php');
>        exit();
>     }
> }  
# кривые заголовки на каких-то страницах, точно не помню на каких
diff -r orig/include/functions.php my/include/functions.php
43,45c43,45
<    echo "<?xml version=\"1.0\" encoding=\""._CHARSET."\"?>\n";?>
< <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo _LANGCODE;?>" lang="<?php echo _LANGCODE;?>" dir="<?php echo RC_DIR?>">
---
>    ?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
> <html>
637,639c637,638
<?php echo "<?xml version=\"1.0\" encoding=\""._CHARSET."\"?>\n";?>
< <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo _LANGCODE;?>" lang="<?php echo _LANGCODE;?>" dir="<?php echo RC_DIR?>"><head>
---
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
> <html><head>
660c659
<   </head><body>
---
>   </head><body style='background-color: #000000;'>
# файл не нужен для работы движка, когда он присутствует, возникают глюки в IE
Only in orig/include: prototype.js
# При отправке сообщений пропадает текст: http://www.runcms.ru/forum/showthread.php?p=77313
diff -r orig/modules/messages/include/messageform.inc.php my/modules/messages/include/messageform.inc.php
96c96
<   $desc  = new XoopsFormDhtmlTextArea( 'message', $message);
---
>   $desc  = new XoopsFormDhtmlTextArea('', 'message', $message);
# Смайлы в комментариях пользователей: http://www.runcms.ru/forum/showthread.php?t=10306
diff -r orig/modules/myarticles/class/textsanitizer.class.php my/modules/myarticles/class/textsanitizer.class.php
30a31
>             parent::__construct();
# не помню какую именно ошибку исправляет
diff -r orig/modules/mydownloads/submit.php my/modules/mydownloads/submit.php
33a34,36
> } else {
>     $submitter = (int)$_POST['submitter'];
> }  
# сбиваются куки: http://www.runcms.ru/forum/showthread.php?t=6410&page=23
# еще какая-то ошибка исправлена, точно не помню
diff -r orig/modules/newbb_plus/include/newbbplus.js my/modules/newbb_plus/include/newbbplus.js
66c66
<         for (i in collapsed){
---
>         for (i = 0; i < collapsed.length; i++){
118,139c118,142
< var copy_txt = '';

< function copy() {
<     if (document.getSelection) copy_txt = document.getSelection();
<     else if (document.selection) copy_txt = document.selection.createRange().text;
<     else return;
< }

< function ins_in (tex_to) {
<     var txtarea = document.getElementById("message");
<     if (txtarea.createTextRange && txtarea.caretPos) {
<         var caretPos = txtarea.caretPos;
<         caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? tex_to + ' ' : tex_to;
<     } else txtarea.value += tex_to;
<     copy_txt = '';
< }
< function ins_to(by_who) {
<     pm(by_who);
<     if (copy_txt) {
<             ins_in ("[quote]" + copy_txt + " [/quote]\n");
<     } else return;
< }
---
> var copy_txt = '';
> function copy() {
> if (window.getSelection) {
> copy_txt = window.getSelection().toString();
> } else if (document.getSelection) {
> copy_txt = document.getSelection();                
> } else if (document.selection) {
> copy_txt = document.selection.createRange().text;
> }
> else return;
> }
> function ins_in (tex_to) {
> var txtarea = document.getElementById("message");
> if (txtarea.createTextRange && txtarea.caretPos) {
> var caretPos = txtarea.caretPos;
> caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? tex_to + ' ' : tex_to;
> } else txtarea.value += tex_to;
> copy_txt = '';
> }
> function ins_to(by_who) {
> pm(by_who);
> if (copy_txt) {
> ins_in ("[quote]" + copy_txt + " [/quote]\n");
> } else return;
> }
453c456
< }
\ No newline at end of file
---
> }
# эмулятор register_globals для админки photo
diff -r orig/modules/photo/admin/admin_header.php my/modules/photo/admin/admin_header.php
101c101,107
< ?>
\ No newline at end of file
---
> $globals_test = @ini_get('register_globals');
> if (isset($globals_test) && empty($globals_test)) {
>     // These still need some work :: Cookie|Server|Env are ok now.
>     if (!empty($_POST)) { extract($_POST, EXTR_SKIP); }
>     if (!empty($_GET))  { extract($_GET, EXTR_SKIP);  }
> } 
> ?>
# блок открывался и закрывался по-разному - нарушалась структура html
diff -r orig/modules/photo/blocks/block.php my/modules/photo/blocks/block.php
54,55c54,55
<    /*    $block['content'] .= "<br><center>";
<    $block['content'] .= "<table border='".$galerieConfig['block_tb1_bo']."' cellspacing='".$galerieConfig['block_tb1_cspa']."' cellpadding='".$galerieConfig['block_tb1_cpad']."' bordercolor='#".$galerieConfig['block_tb1_bordcol']."' bgcolor='#".$galerieConfig['block_tb1_bgcol']."'>";
---
>        $block['content'] .= "<br><center>";
>    /* $block['content'] .= "<table border='".$galerieConfig['block_tb1_bo']."' cellspacing='".$galerieConfig['block_tb1_cspa']."' cellpadding='".$galerieConfig['block_tb1_cpad']."' bordercolor='#".$galerieConfig['block_tb1_bordcol']."' bgcolor='#".$galerieConfig['block_tb1_bgcol']."'>";
# эмулятор register_globals для админки photo
# мусор перед началом html-страницы
diff -r orig/modules/photo/header.php my/modules/photo/header.php
21,23c21,23
< echo "<style type='text/css'>
<         .textarea, .text, .button, .file {background: #ECECEC top; border: 1px solid #C0C0C0; font-family: Verdana, Tahoma, Arial; font-size: xx-small;}
<     </style>";
---
> //echo "<style type='text/css'>
> //        .textarea, .text, .button, .file {background: #ECECEC top; border: 1px solid #C0C0C0; font-family: Verdana, Tahoma, Arial; font-size: xx-small;}
> //    </style>";
55c55,73
< ?>
\ No newline at end of file
---
> //phpinfo();
> //if(isset($_POST))foreach($_POST as $k=>$v)$HTTP_POST_VARS["$k"]=$v;//echo "$k=>$v<br>";
> //if(isset($_GET ))foreach($_GET  as $k=>$v)$HTTP_GET_VARS["$k"] =$v;//echo "$k=>$v<br>";
> $HTTP_GET_VARS    = $_GET;
> $HTTP_POST_VARS   = $_POST;
> $HTTP_SERVER_VARS = $_SERVER;
> $HTTP_COOKIE_VARS = $_COOKIE;
> $HTTP_POST_FILES  = $_FILES;
> $QUERY_STRING     = $_SERVER['QUERY_STRING'];
> $HTTP_REFERER     = $_SERVER['HTTP_REFERER'];
> //phpinfo();
> //echo "aaa".$HTTP_POST_VARS["titre"];
> $globals_test = @ini_get('register_globals');
> if (isset($globals_test) && empty($globals_test)) {
>     // These still need some work :: Cookie|Server|Env are ok now.
>     if (!empty($_POST)) { extract($_POST, EXTR_SKIP); }
>     if (!empty($_GET))  { extract($_GET, EXTR_SKIP);  }
> } 
> ?>
# в случае ровно N страниц фотографий у меня просто пропала ссылка на последнюю - убрал - все ок. Не понял зачем этот декремент был нужен
diff -r orig/modules/photo/viewcat.php my/modules/photo/viewcat.php
458c458
<       $imgpages = $imgpages - 1;
---
> //      $imgpages = $imgpages - 1;
# исправление глюка с опросами, сам не тестировал
diff -r orig/modules/xoopspoll/admin/index.php my/modules/xoopspoll/admin/index.php
614c614
<    $poll =& new XoopsPoll($poll_id);
---
>    $poll = new XoopsPoll($poll_id);
На данный момент фикспак не содержит решения следующих проблем:
1. не отображаются смайлики в текстах статей: http://www.runcms.ru/forum/showthread.php?t=10306
2. некорретно отображается время на форуме (часовой пояс)
3. при редактировании новости - сбиваются галочки, в визуальном редакторе смайлики превращаются в url, другие связанные с этим ошибки.
4. старые/новые сообщения первыми на форуме - отображаются у кого как попало
5. при изменения порядка форумов в админке форумам могут быть присвоены одинаковые индексы сортировки, в результате для некоторыз пользователей форумы отображаются в неправильном порядке, исправляется только редактированием базы.
6. не работает по-человечески блок "кто на сайте": http://www.runcms.ru/forum/showthread.php?t=10514
7. торможение движка при невыясненных обстоятельствах: http://www.runcms.ru/forum/showthread.php?t=10518

В настоящий момент считаю нецелесообразным продолжать тестирование/исправление движка до решения проблемы п.7 (с торможением), поэтому просто решил выложить список того, что я исправил, а также список того, что еще следует исправить.
О тех же самых (и других) ошибках в других версиях не имею понятия, поскольку тестировал именно 1.6.2

  Сообщения: 50 c 02.08.2010 | Репутация: 14
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Рейтинг@Mail.ru Хостинг провайдер Majordomo. Powered by: vBulletin Version 3.0
Copyright ©2000-2024, Jelsoft Enterprises Ltd.
Все разделы прочитаны - Руководство форума - Архив - Вверх
Rambler's Top100
Output: 173.09 Kb. compressed to 171.44 Kb. by saving 1.65 Kb. (0.95%)
Page generated in 0.10539 seconds with 10 queries