
Эксперт
   
Профиль
Группа: Комодератор
Сообщений: 2007
Регистрация: 6.5.2005
Где: Нижние Чигири
Репутация: 15 Всего: 71
|
Jey_k, в 1.3 все уже давно найдено и пофикшено. Я опубликую те баги, которые нашли разработчики после релиза 1.3. #1Если стоит чистый IPB 1.3.x, то можешь скачать обновленный файл: http://forums.invisionpower.com/index.php?...ost&id=5691В файле sources/lib/post_parser.php найти: | Код | else if ($IN['s'] == 'col') { return "<span style='color:".$IN['1']."'>".$IN['2']."</span>"; } else if ($IN['s'] == 'font') { return "<span style='font-family:".$IN['1']."'>".$IN['2']."</span>"; }
|
заменить на: | Код | else if ($IN['s'] == 'col') { $IN[1] = preg_replace( "/[^\d\w\#\s]/s", "", $IN[1] ); return "<span style='color:".$IN['1']."'>".$IN['2']."</span>"; } else if ($IN['s'] == 'font') { $IN['1'] = preg_replace( "/[^\d\w\#\-\_\s]/s", "", $IN['1'] ); return "<span style='font-family:".$IN['1']."'>".$IN['2']."</span>"; }
|
#2Исправление уязвимостей найденных Algol. Уязвимость связанная с extended тэгами [video], [sound]Исправление производится в файле /sources/lib/post_parser.phpнаходим: | Код | $txt = preg_replace( "#\[video\](.+?)\[/video\]#is", "<embed width=\"400\" height=\"300\" src=\\1 type=\"application/x-shockwave-video\">", $txt ); $txt = preg_replace( "#\[sound\](.+?)\[/sound\]#is", "<param name=\"BACKGROUNDCOLOR\" <br /><embed src=\\1 align=\"baseline\" border=\"0\" width=\"275\" height=\"40\" type=\"audio/x-pn-realaudio-plugin\" console=\"Clip1\" controls=\"ControlPanel\" autostart=\"true\">", $txt );
|
заменяем на: | Код | $txt = preg_replace( "#\[video\](\S+?)\[/video\]#ies", "\$this->regex_build_src('\\1', 'video')", $txt ); $txt = preg_replace( "#\[sound\](\S+?)\[/sound\]#ies", "\$this->regex_build_src('\\1', 'sound')", $txt );
|
и перед | Код | function regex_build_url($url=array()) {
|
добавляем | Код | function regex_build_src($src="", $type) {
if (!$src) return; // clean up the ampersands $src = preg_replace( "/&/" , "&" , $src );
// Make sure we don't have a JS link $src = preg_replace( "/javascript:/i", "java script: ", $src );
// Do we have http:// at the front?
if ( ! preg_match("#^(http|ftp)://#", $src ) ) { $src = 'http://'.$src; }
switch ($type) { case 'video': $src="<embed width=\"400\" height=\"300\" src=\"{$src}\" type=\"application/x-shockwave-video\">"; break; case 'sound': $src="<param name=\"BACKGROUNDCOLOR\" <br /><embed src=\"{$src}\" align=\"baseline\" border=\"0\" width=\"275\" height=\"40\" type=\"audio/x-pn-realaudio-plugin\" console=\"Clip1\" controls=\"ControlPanel\" autostart=\"true\">"; break; default: return; }
return $src; }
|
#3Уязвимость связанная с вложением тэгов в [font], [color], [size]Уязвимы форумы: IPB версий 1.х.x и 2.0.х Исправление производится в файле /sources/lib/post_parser.phpнаходим: | Код | while ( preg_match( "#\[size=([^\]]+)\](.+?)\[/size\]#ies", $txt ) ) { $txt = preg_replace( "#\[size=([^\]]+)\](.+?)\[/size\]#ies" , "\$this->regex_font_attr(array('s'=>'size','1'=>'\\1','2'=>'\\2'))", $txt ); } while ( preg_match( "#\[font=([^\]]+)\](.*?)\[/font\]#ies", $txt ) ) { $txt = preg_replace( "#\[font=([^\]]+)\](.*?)\[/font\]#ies" , "\$this->regex_font_attr(array('s'=>'font','1'=>'\\1','2'=>'\\2'))", $txt ); } while( preg_match( "#\[color=([^\]]+)\](.+?)\[/color\]#ies", $txt ) ) { $txt = preg_replace( "#\[color=([^\]]+)\](.+?)\[/color\]#ies" , "\$this->regex_font_attr(array('s'=>'col' ,'1'=>'\\1','2'=>'\\2'))", $txt ); }
|
заменяем на: | Код | while ( preg_match( "#\[size=([0-9]+)\](.+?)\[/size\]#is", $txt ) ) { $txt = preg_replace( "#\[size=([0-9]+)\](.+?)\[/size\]#ies" , "\$this->regex_font_attr(array('s'=>'size','1'=>'\\1','2'=>'\\2'))", $txt ); } while ( preg_match( "#\[font=([a-zA-Z]+)\](.*?)\[/font\]#is", $txt ) ) { $txt = preg_replace( "#\[font=([a-zA-Z]+)\](.*?)\[/font\]#ies" , "\$this->regex_font_attr(array('s'=>'font','1'=>'\\1','2'=>'\\2'))", $txt ); } while( preg_match( "#\[color=([a-zA-Z]+)\](.+?)\[/color\]#is", $txt ) ) { $txt = preg_replace( "#\[color=([a-zA-Z]+)\](.+?)\[/color\]#ies" , "\$this->regex_font_attr(array('s'=>'col' ,'1'=>'\\1','2'=>'\\2'))", $txt ); }
|
Внимание: данный способ решения разрешает только стандартные теги цвета, размера и шрифта. Т.е. те теги которые есть в форме ответа. Тэги вида [color=#c4c4c4], [font='Arial New'], [size=small] работать не будут! #4в post_parser.php меняем это: | Код | $txt = preg_replace( "#\[email\](\S+?)\[/email\]#i" , "<a href='mailto:\\1'>\\1</a>", $txt ); $txt = preg_replace( "#\[email\s*=\s*\"\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\"\;\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt ); $txt = preg_replace( "#\[email\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt );
|
на это: | Код | $txt = preg_replace( "#\[email\]\s*([0-9a-z]([-_.]?[0-9a-z])*@([a-z0-9\-]+\.)+([a-z0-9\-]{2}|net|com|gov|mil|org|edu|int|xxx))\s*\[/email\]#i" , "<a href='mailto:\\1'>\\1</a>", $txt ); $txt = preg_replace( "#\[email\s*=\s*\"\;\s*([0-9a-z]([-_.]?[0-9a-z])*@([a-z0-9\-]+\.)+([a-z0-9\-]{2}|net|com|gov|mil|org|edu|int|xxx))\s*\"\;\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\5</a>", $txt ); $txt = preg_replace( "#\[email\s*=\s*([0-9a-z]([-_.]?[0-9a-z])*@([a-z0-9\-]+\.)+([a-z0-9\-]{2}|net|com|gov|mil|org|edu|int|xxx))\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\5</a>", $txt );
|
#5в post_parser.php после этого: | Код | /**************************************************/ // regex_check_image: Checks, and builds the <img> // html. /**************************************************/
function regex_check_image($url="") { global $ibforums;
if (!$url) return;
$url = trim($url);
$default = "[img]".$url."[/img]";
++$this->image_count;
|
добавляем: | Код | if (strpos(urldecode($url), "`") !== false) { $this->error = 'no_dynamic'; return $default; }
|
#6sources/lib/usercp_functions.php (Строка: 705) Найти: | Код | //----------------------------------------- // Check to make sure we don't just have // http:// in the URL box.. //-----------------------------------------
if ( preg_match( "/^http:\/\/$/i", $ibforums->input['url_avatar'] ) ) { $ibforums->input['url_avatar'] = ""; }
if ( empty($ibforums->input['url_avatar']) )
|
Заменить на: | Код | //----------------------------------------- // Check to make sure we don't just have // http:// in the URL box.. //-----------------------------------------
if ( preg_match( "/^http:\/\/$/i", $ibforums->input['url_avatar'] ) ) { $ibforums->input['url_avatar'] = ""; }
if ( preg_match( "#javascript:#is", $ibforums->input['url_avatar'] ) ) { $ibforums->input['url_avatar'] = ""; }
if ( empty($ibforums->input['url_avatar']) )
|
# По материалам http://www.ibresource.ru
--------------------
Быстро поднятое - упавшим не считаеся
|