그누보드4 보안패치 일괄 적용

This commit is contained in:
gnuboard
2013-03-20 15:53:44 +09:00
parent 6180493eb6
commit b072f9fe23
7 changed files with 1578 additions and 1436 deletions

View File

@ -4,6 +4,8 @@ include_once('./_common.php');
if (!$member[mb_id])
alert('회원만 이용하실 수 있습니다.');
$me_id = (int)$_REQUEST['me_id'];
$sql = " select * from {$g4[memo_table]} where me_id = '{$me_id}' ";
$row = sql_fetch($sql);
if (!$row[mb_read_datetime][0]) // 메모 받기전이면

View File

@ -4,6 +4,8 @@ include_once('./_common.php');
if (!$is_member)
alert('회원만 이용하실 수 있습니다.');
$me_id = (int)$_REQUEST['me_id'];
if ($kind == 'recv')
{
$t = '받은';

View File

@ -3,8 +3,8 @@ include_once('./_common.php');
include_once(G4_CKEDITOR_PATH.'/ckeditor.lib.php');
include_once(G4_GCAPTCHA_PATH.'/gcaptcha.lib.php');
set_session('ss_bo_table', $bo_table);
set_session('ss_wr_id', $wr_id);
set_session('ss_bo_table', $_REQUEST['bo_table']);
set_session('ss_wr_id', $_REQUEST['wr_id']);
if (!$board['bo_table']) {
alert('존재하지 않는 게시판입니다.', G4_URL);

View File

@ -42,8 +42,8 @@ if (empty($_POST)) {
}
$w = $_POST['w'];
$wr_link1 = mysql_real_escape_string($_POST['wr_link1']);
$wr_link2 = mysql_real_escape_string($_POST['wr_link2']);
$wr_link1 = escape_trim(strip_tags($_POST['wr_link1']));
$wr_link2 = escape_trim(strip_tags($_POST['wr_link2']));
$notice_array = explode(',', trim($board['bo_notice']));

2965
bbs/zip.db

File diff suppressed because it is too large Load Diff

View File

@ -212,6 +212,7 @@ if (isset($_REQUEST['sca'])) {
if (isset($_REQUEST['sfl'])) {
$sfl = escape_trim($_REQUEST['sfl']);
$sfl = preg_replace("/[\<\>\'\"\%\=\(\)\s]/", "", $sfl);
if ($sfl)
$qstr .= '&amp;sfl=' . urlencode($sfl); // search field (검색 필드)
} else {

View File

@ -477,6 +477,13 @@ function bad120422($matches)
return $matches['0'];
}
// tag 내의 주석문 무효화 하기
function bad130128($matches)
{
$str = $matches[2];
return '<'.$matches[1].preg_replace('#(\/\*|\*\/)#', '', $str).'>';
}
// 내용을 변환
function conv_content($content, $html)
{
@ -503,14 +510,18 @@ function conv_content($content, $html)
$content .= "</table>";
}
$content = preg_replace_callback("/<([^>]+)>/s", 'bad130128', $content);
$content = preg_replace($source, $target, $content);
$content = bad_tag_convert($content);
// XSS (Cross Site Script) 막기
// 완벽한 XSS 방지는 없다.
// 이런 경우를 방지함 <IMG STYLE="xss:expr/*XSS*/ession(alert('XSS'))">
$content = preg_replace("#\/\*.*\*\/#iU", "", $content);
//$content = preg_replace("#\/\*.*\*\/#iU", "", $content);
// 위의 정규식이 아래와 같은 내용을 통과시키므로 not greedy(비탐욕수량자?) 옵션을 제거함. ignore case 옵션도 필요 없으므로 제거
// <IMG STYLE="xss:ex//*XSS*/**/pression(alert('XSS'))"></IMG>
$content = preg_replace("#\/\*.*\*\/#", "", $content);
// object, embed 태그에서 javascript 코드 막기
$content = preg_replace_callback("#<(object|embed)([^>]+)>#i", "bad120422", $content);
@ -520,7 +531,8 @@ function conv_content($content, $html)
$content = preg_replace("/(lo)(wsrc)/i", "&#108;&#111;$2", $content);
$content = preg_replace("/(sc)(ript)/i", "&#115;&#99;$2", $content);
$content = preg_replace_callback("#<([^>]+)#", create_function('$m', 'return "<".str_replace("<", "&lt;", $m[1]);'), $content);
$content = preg_replace("/\<(\w|\s|\?)*(xml)/i", "", $content);
//$content = preg_replace("/\<(\w|\s|\?)*(xml)/i", "", $content);
$content = preg_replace("/\<(\w|\s|\?)*(xml)/i", "_$1$2_", $content);
// 플래시의 액션스크립트와 자바스크립트의 연동을 차단하여 악의적인 사이트로의 이동을 막는다.
// value="always" 를 value="never" 로, allowScriptaccess="always" 를 allowScriptaccess="never" 로 변환하는데 목적이 있다.
@ -532,6 +544,9 @@ function conv_content($content, $html)
$content = preg_replace("/<(img[^>]+logout\.php[^>]+)/i", "*** CSRF 감지 : &lt;$1", $content);
$content = preg_replace("/<(img[^>]+download\.php[^>]+bo_table[^>]+)/i", "*** CSRF 감지 : &lt;$1", $content);
$content = preg_replace_callback("#style\s*=\s*[\"\']?[^\"\']+[\"\']?#i",
create_function('$matches', 'return str_replace("\\\\", "", stripslashes($matches[0]));'), $content);
$pattern = "";
$pattern .= "(e|&#(x65|101);?)";
$pattern .= "(x|&#(x78|120);?)";
@ -540,10 +555,15 @@ function conv_content($content, $html)
$pattern .= "(e|&#(x65|101);?)";
$pattern .= "(s|&#(x73|115);?)";
$pattern .= "(s|&#(x73|115);?)";
$pattern .= "(i|&#(x6a|105);?)";
//$pattern .= "(i|&#(x6a|105);?)";
$pattern .= "(i|&#(x69|105);?)";
$pattern .= "(o|&#(x6f|111);?)";
$pattern .= "(n|&#(x6e|110);?)";
$content = preg_replace("/".$pattern."/i", "__EXPRESSION__", $content);
//$content = preg_replace("/".$pattern."/i", "__EXPRESSION__", $content);
$content = preg_replace("/<[^>]*".$pattern."/i", "__EXPRESSION__", $content);
// <IMG STYLE="xss:e\xpression(alert('XSS'))"></IMG> 와 같은 코드에 취약점이 있어 수정함. 121213
$content = preg_replace("/(?<=style)(\s*=\s*[\"\']?xss\:)/i", '="__XSS__', $content);
$content = bad_tag_convert($content);
}
else // text 이면
{
@ -1526,9 +1546,7 @@ function bad_tag_convert($code)
$code);
}
//return preg_replace("/\<([\/]?)(script|iframe)([^\>]*)\>/i", "&lt;$1$2$3&gt;", $code);
// script 나 iframe 태그를 막지 않는 경우 필터링이 되도록 수정
return preg_replace("/\<([\/]?)(script|iframe)([^\>]*)\>?/i", "&lt;$1$2$3&gt;", $code);
return preg_replace("/\<([\/]?)(script|iframe|form)([^\>]*)\>?/i", "&lt;$1$2$3&gt;", $code);
}