Skip to content

Commit

Permalink
XSS 및 Blind SQL Injection 취약점 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chicpro committed Jul 7, 2015
1 parent 78169b3 commit 3bbbe96
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion bbs/db_table.optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@

// 탈퇴회원 자동 삭제
if($config['cf_leave_day'] > 0) {
$sql = " select mb_id from {$g5['member_table']} where (TO_DAYS('".G5_TIME_YMDHIS."') - TO_DAYS(mb_leave_date)) > '{$config['cf_leave_day']}' ";
$sql = " select mb_id from {$g5['member_table']}
where (TO_DAYS('".G5_TIME_YMDHIS."') - TO_DAYS(mb_leave_date)) > '{$config['cf_leave_day']}'
and mb_memo not regexp '^[0-9]{8}.*삭제함' ";
$result = sql_query($sql);
while ($row=sql_fetch_array($result))
{
Expand Down
8 changes: 5 additions & 3 deletions bbs/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
else if ($view == "c")
$sql_common .= " and a.wr_id <> a.wr_parent ";

$mb_id = isset($_GET['mb_id']) ? strip_tags($_GET['mb_id']) : "";
$mb_id = isset($_GET['mb_id']) ? ($_GET['mb_id']) : '';
$mb_id = substr(preg_replace('#[^a-z0-9_]#i', '', $mb_id), 0, 20);

if ($mb_id) {
$sql_common .= " and a.mb_id = '{$mb_id}' ";
}
Expand All @@ -28,9 +30,9 @@
$row = sql_fetch($sql);
$total_count = $row['cnt'];

$rows = $config['cf_new_rows'];
$rows = G5_IS_MOBILE ? $config['cf_mobile_page_rows'] : $config['cf_new_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
if ($page < 1) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함

$group_select = '<label for="gr_id" class="sound_only">그룹</label><select name="gr_id" id="gr_id"><option value="">전체그룹';
Expand Down
2 changes: 1 addition & 1 deletion bbs/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$stx = preg_replace('/\//', '\/', trim($stx));
$sop = strtolower($sop);
if (!$sop || !($sop == 'and' || $sop == 'or')) $sop = 'and'; // 연산자 and , or
$srows = isset($_GET['srows']) ? $_GET['srows'] : 10;
$srows = isset($_GET['srows']) ? preg_replace('#[^0-9]#', '', $_GET['srows']) : 10;
if (!$srows) $srows = 10; // 한페이지에 출력하는 검색 행수

$g5_search['tables'] = Array();
Expand Down
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
********************/

define('G5_VERSION', '그누보드5');
define('G5_GNUBOARD_VER', '5.0.38');
define('G5_GNUBOARD_VER', '5.0.39');

// 이 상수가 정의되지 않으면 각각의 개별 페이지는 별도로 실행될 수 없음
define('_GNUBOARD_', true);
Expand Down
7 changes: 6 additions & 1 deletion lib/common.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2747,14 +2747,19 @@ function member_delete($mb_id)

$sql = " select mb_name, mb_nick, mb_ip, mb_recommend, mb_memo, mb_level from {$g5['member_table']} where mb_id= '".$mb_id."' ";
$mb = sql_fetch($sql);

// 이미 삭제된 회원은 제외
if(preg_match('#^[0-9]{8}.*삭제함#', $mb['mb_memo']))
return;

if ($mb['mb_recommend']) {
$row = sql_fetch(" select count(*) as cnt from {$g5['member_table']} where mb_id = '".addslashes($mb['mb_recommend'])."' ");
if ($row['cnt'])
insert_point($mb['mb_recommend'], $config['cf_recommend_point'] * (-1), $mb_id.'님의 회원자료 삭제로 인한 추천인 포인트 반환', "@member", $mb['mb_recommend'], $mb_id.' 추천인 삭제');
}

// 회원자료는 정보만 없앤 후 아이디는 보관하여 다른 사람이 사용하지 못하도록 함 : 061025
$sql = " update {$g5['member_table']} set mb_password = '', mb_level = 1, mb_email = '', mb_homepage = '', mb_tel = '', mb_hp = '', mb_zip1 = '', mb_zip2 = '', mb_addr1 = '', mb_addr2 = '', mb_birth = '', mb_sex = '', mb_signature = '', mb_memo = '".date('Ymd', G5_SERVER_TIME)." 삭제함\n{$mb['mb_memo']}', mb_leave_date = '".date('Ymd', G5_SERVER_TIME)."' where mb_id = '{$mb_id}' ";
$sql = " update {$g5['member_table']} set mb_password = '', mb_level = 1, mb_email = '', mb_homepage = '', mb_tel = '', mb_hp = '', mb_zip1 = '', mb_zip2 = '', mb_addr1 = '', mb_addr2 = '', mb_birth = '', mb_sex = '', mb_signature = '', mb_memo = '".date('Ymd', G5_SERVER_TIME)." 삭제함\n{$mb['mb_memo']}' where mb_id = '{$mb_id}' ";
sql_query($sql);

// 포인트 테이블에서 삭제
Expand Down

0 comments on commit 3bbbe96

Please sign in to comment.