충돌 수정

This commit is contained in:
thisgun
2018-05-23 13:51:59 +09:00
18 changed files with 315 additions and 20 deletions

View File

@ -355,6 +355,18 @@ function get_admin_token()
return $token;
}
// 관리자가 자동등록방지를 사용해야 할 경우
function get_admin_captcha_by($type='get'){
$captcha_name = 'ss_admin_use_captcha';
if($type === 'remove'){
set_session($captcha_name, '');
}
return get_session($captcha_name);
}
//input value 에서 xss 공격 filter 역할을 함 ( 반드시 input value='' 타입에만 사용할것 )
function get_sanitize_input($s, $is_html=false){

7
adm/ajax.use_captcha.php Normal file
View File

@ -0,0 +1,7 @@
<?php
include_once('./_common.php');
if( isset($_POST['admin_use_captcha']) ){
set_session('ss_admin_use_captcha', true);
}
?>

View File

@ -850,6 +850,22 @@ $pg_anchor = '<ul class="anchor">
<label for="chk_all_include_tail">전체적용</label>
</td>
</tr>
<tr id="admin_captcha_box" style="display:none;">
<th scope="row">자동등록방지</th>
<td>
<?php
echo help("파일 경로를 입력 또는 수정시 캡챠를 반드시 입력해야 합니다.");
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
$captcha_html = captcha_html();
$captcha_js = chk_captcha_js();
echo $captcha_html;
?>
<script>
jQuery("#captcha_key").removeAttr("required").removeClass("required");
</script>
</td>
</tr>
<tr>
<th scope="row"><label for="bo_content_head">상단 내용</label></th>
<td>
@ -1310,6 +1326,52 @@ function set_point(f) {
}
}
var captcha_chk = false;
function use_captcha_check(){
$.ajax({
type: "POST",
url: g5_admin_url+"/ajax.use_captcha.php",
data: { admin_use_captcha: "1" },
cache: false,
async: false,
dataType: "json",
success: function(data) {
}
});
}
function frm_check_file(){
var bo_include_head = "<?php echo $board['bo_include_head']; ?>";
var bo_include_tail = "<?php echo $board['bo_include_tail']; ?>";
var head = jQuery.trim(jQuery("#bo_include_head").val());
var tail = jQuery.trim(jQuery("#bo_include_tail").val());
if(bo_include_head !== head || bo_include_tail !== tail){
// 캡챠를 사용합니다.
jQuery("#admin_captcha_box").show();
captcha_chk = true;
use_captcha_check();
return false;
} else {
jQuery("#admin_captcha_box").hide();
}
return true;
}
jQuery(function($){
if( window.self !== window.top ){ // frame 또는 iframe을 사용할 경우 체크
$("#bo_include_head, #bo_include_tail").on("change paste keyup", function(e) {
frm_check_file();
});
use_captcha_check();
}
});
function fboardform_submit(f)
{
<?php echo get_editor_js("bo_content_head"); ?>
@ -1329,6 +1391,10 @@ function fboardform_submit(f)
return false;
}
if( captcha_chk ) {
<?php echo isset($captcha_js) ? $captcha_js : ''; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함 ?>
}
return true;
}
</script>

View File

@ -17,6 +17,15 @@ if (!$_POST['bo_subject']) { alert('게시판 제목을 입력하세요.'); }
$_POST['bo_include_head'] = preg_replace("#[\\\]+$#", "", substr($_POST['bo_include_head'], 0, 255));
$_POST['bo_include_tail'] = preg_replace("#[\\\]+$#", "", substr($_POST['bo_include_tail'], 0, 255));
// 관리자가 자동등록방지를 사용해야 할 경우
if ($board && ($board['bo_include_head'] !== $_POST['bo_include_head'] || $board['bo_include_tail'] !== $_POST['bo_include_tail']) && function_exists('get_admin_captcha_by') && get_admin_captcha_by()){
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
if (!chk_captcha()) {
alert('자동등록방지 숫자가 틀렸습니다.');
}
}
if ($file = $_POST['bo_include_head']) {
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
@ -426,5 +435,8 @@ if ($all_fields) {
delete_cache_latest($bo_table);
if(function_exists('get_admin_captcha_by'))
get_admin_captcha_by('remove');
goto_url("./board_form.php?w=u&bo_table={$bo_table}&amp;{$qstr}");
?>

View File

@ -126,6 +126,22 @@ include_once (G5_ADMIN_PATH.'/admin.head.php');
<input type="text" name="co_include_tail" value="<?php echo $co['co_include_tail']; ?>" id="co_include_tail" class="frm_input" size="60">
</td>
</tr>
<tr id="admin_captcha_box" style="display:none;">
<th scope="row">자동등록방지</th>
<td>
<?php
echo help("파일 경로를 입력 또는 수정시 캡챠를 반드시 입력해야 합니다.");
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
$captcha_html = captcha_html();
$captcha_js = chk_captcha_js();
echo $captcha_html;
?>
<script>
jQuery("#captcha_key").removeAttr("required").removeClass("required");
</script>
</td>
</tr>
<tr>
<th scope="row"><label for="co_himg">상단이미지</label></th>
<td>
@ -185,7 +201,56 @@ include_once (G5_ADMIN_PATH.'/admin.head.php');
</form>
<?php
// [KVE-2018-2089] 취약점 으로 인해 파일 경로 수정시에만 자동등록방지 코드 사용
?>
<script>
var captcha_chk = false;
function use_captcha_check(){
$.ajax({
type: "POST",
url: g5_admin_url+"/ajax.use_captcha.php",
data: { admin_use_captcha: "1" },
cache: false,
async: false,
dataType: "json",
success: function(data) {
}
});
}
function frm_check_file(){
var co_include_head = "<?php echo $co['co_include_head']; ?>";
var co_include_tail = "<?php echo $co['co_include_tail']; ?>";
var head = jQuery.trim(jQuery("#co_include_head").val());
var tail = jQuery.trim(jQuery("#co_include_tail").val());
if(co_include_head !== head || co_include_tail !== tail){
// 캡챠를 사용합니다.
jQuery("#admin_captcha_box").show();
captcha_chk = true;
use_captcha_check();
return false;
} else {
jQuery("#admin_captcha_box").hide();
}
return true;
}
jQuery(function($){
if( window.self !== window.top ){ // frame 또는 iframe을 사용할 경우 체크
$("#co_include_head, #co_include_tail").on("change paste keyup", function(e) {
frm_check_file();
});
use_captcha_check();
}
});
function frmcontentform_check(f)
{
errmsg = "";
@ -204,6 +269,11 @@ function frmcontentform_check(f)
errfld.focus();
return false;
}
if( captcha_chk ) {
<?php echo $captcha_js; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함 ?>
}
return true;
}
</script>

View File

@ -12,6 +12,23 @@ else
check_admin_token();
if ($w == "" || $w == "u")
{
if(preg_match("/[^a-z0-9_]/i", $co_id)) alert("ID 는 영문자, 숫자, _ 만 가능합니다.");
$sql = " select * from {$g5['content_table']} where co_id = '$co_id' ";
$co_row = sql_fetch($sql);
}
// 관리자가 자동등록방지를 사용해야 할 경우
if (($co_row['co_include_head'] !== $_POST['co_include_head'] || $co_row['co_include_tail'] !== $_POST['co_include_tail']) && function_exists('get_admin_captcha_by') && get_admin_captcha_by()){
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
if (!chk_captcha()) {
alert('자동등록방지 숫자가 틀렸습니다.');
}
}
@mkdir(G5_DATA_PATH."/content", G5_DIR_PERMISSION);
@chmod(G5_DATA_PATH."/content", G5_DIR_PERMISSION);
@ -21,17 +38,19 @@ if ($co_timg_del) @unlink(G5_DATA_PATH."/content/{$co_id}_t");
$error_msg = '';
if( $co_include_head ){
$purl = parse_url($co_include_head);
$file = $purl['path'];
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
$file_ext = pathinfo($co_include_head, PATHINFO_EXTENSION);
if( ! $file_ext || ! in_array($file_ext, array('php', 'htm', 'html')) ) {
alert('상단 파일 경로의 확장자는 php, html 만 허용합니다.');
}
}
if( $co_include_tail ){
$purl = parse_url($co_include_tail);
$file = $purl['path'];
if (!preg_match("/\.(php|htm['l']?)$/i", $file)) {
$file_ext = pathinfo($co_include_tail, PATHINFO_EXTENSION);
if( ! $file_ext || ! in_array($file_ext, array('php', 'htm', 'html')) ) {
alert('하단 파일 경로의 확장자는 php, html 만 허용합니다.');
}
}
@ -58,11 +77,7 @@ $sql_common = " co_include_head = '$co_include_head',
if ($w == "")
{
//if(eregi("[^a-z0-9_]", $co_id)) alert("ID 는 영문자, 숫자, _ 만 가능합니다.");
if(preg_match("/[^a-z0-9_]/i", $co_id)) alert("ID 는 영문자, 숫자, _ 만 가능합니다.");
$sql = " select co_id from {$g5['content_table']} where co_id = '$co_id' ";
$row = sql_fetch($sql);
$row = $co_row;
if ($row['co_id'])
alert("이미 같은 ID로 등록된 내용이 있습니다.");
@ -87,6 +102,9 @@ else if ($w == "d")
sql_query($sql);
}
if(function_exists('get_admin_captcha_by'))
get_admin_captcha_by('remove');
if ($w == "" || $w == "u")
{
if ($_FILES['co_himg']['name'])

View File

@ -1014,6 +1014,15 @@ box-shadow: 2px 2px 3px 0px rgba(0,0,0,0.2);}
.svc_sms .svc_btn2{position:absolute;top:0;right:0}
.svc_sms .svc_btn2 a{display:inline-block; width:220px; height:91px; background:#fbfbfb; text-align:center; padding:20px 0 0;}
/* 캡챠 */
#captcha {display:inline-block;position:relative}
#captcha legend {position:absolute;margin:0;padding:0;font-size:0;line-height:0;text-indent:-9999em;overflow:hidden;}
#captcha #captcha_img {;height:40px;border:1px solid #898989;vertical-align:top;padding:0;margin:0}
#captcha #captcha_mp3 {;margin:0;padding:0;width:40px;height:40px;border:0;background:transparent;vertical-align:middle;overflow:hidden;cursor:pointer;background:url('../../img/captcha2.png') no-repeat;text-indent:-999px;border-radius:3px}
#captcha #captcha_reload {margin:0;padding:0;width:40px;height:40px;border:0;background:transparent;vertical-align:middle;overflow:hidden;cursor:pointer;background:url('../../img/captcha2.png') no-repeat 0 -40px;text-indent:-999px;border-radius:3px}
#captcha #captcha_key {margin:0 0 0 3px;padding:0 5px;width:90px;height:40px;border:1px solid #ccc;background:#fff;font-size:1.333em;font-weight:bold;text-align:center;border-radius:3px;vertical-align:top}
#captcha #captcha_info {display:block;margin:5px 0 0;font-size:0.95em;letter-spacing:-0.1em}
/*테마*/
.theme_p{margin:0 0 10px }
#theme_list{padding:0;margin:0;list-style:none; width: 1000px;position:relative}

View File

@ -5,6 +5,9 @@ include_once(G5_EDITOR_LIB);
auth_check($auth[$sub_menu], "w");
$fm_id = (int) $fm_id;
$fa_id = isset($fa_id) ? (int) $fa_id : 0;
$sql = " select * from {$g5['faq_master_table']} where fm_id = '$fm_id' ";
$fm = sql_fetch($sql);

View File

@ -263,6 +263,22 @@ if(!isset($qaconfig['qa_include_head'])) {
<input type="text" name="qa_include_tail" value="<?php echo $qaconfig['qa_include_tail'] ?>" id="qa_include_tail" class="frm_input" size="50">
</td>
</tr>
<tr id="admin_captcha_box" style="display:none;">
<th scope="row">자동등록방지</th>
<td>
<?php
echo help("파일 경로를 입력 또는 수정시 캡챠를 반드시 입력해야 합니다.");
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
$captcha_html = captcha_html();
$captcha_js = chk_captcha_js();
echo $captcha_html;
?>
<script>
jQuery("#captcha_key").removeAttr("required").removeClass("required");
</script>
</td>
</tr>
<tr>
<th scope="row"><label for="qa_content_head">상단 내용</label></th>
<td>
@ -316,6 +332,53 @@ if(!isset($qaconfig['qa_include_head'])) {
</form>
<script>
var captcha_chk = false;
function use_captcha_check(){
$.ajax({
type: "POST",
url: g5_admin_url+"/ajax.use_captcha.php",
data: { admin_use_captcha: "1" },
cache: false,
async: false,
dataType: "json",
success: function(data) {
}
});
}
function frm_check_file(){
var qa_include_head = "<?php echo $qaconfig['qa_include_head']; ?>";
var qa_include_tail = "<?php echo $qaconfig['qa_include_tail']; ?>";
var head = jQuery.trim(jQuery("#qa_include_head").val());
var tail = jQuery.trim(jQuery("#qa_include_tail").val());
if(qa_include_head !== head || qa_include_tail !== tail){
// 캡챠를 사용합니다.
jQuery("#admin_captcha_box").show();
captcha_chk = true;
use_captcha_check();
return false;
} else {
jQuery("#admin_captcha_box").hide();
}
return true;
}
jQuery(function($){
if( window.self !== window.top ){ // frame 또는 iframe을 사용할 경우 체크
$("#qa_include_head, #qa_include_tail").on("change paste keyup", function(e) {
frm_check_file();
});
use_captcha_check();
}
});
function fqaconfigform_submit(f)
{
<?php echo get_editor_js("qa_content_head"); ?>
@ -323,6 +386,10 @@ function fqaconfigform_submit(f)
<?php echo get_editor_js("qa_mobile_content_head"); ?>
<?php echo get_editor_js("qa_mobile_content_tail"); ?>
if( captcha_chk ) {
<?php echo isset($captcha_js) ? $captcha_js : ''; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함 ?>
}
f.action = "./qa_config_update.php";
return true;
}

View File

@ -10,6 +10,17 @@ check_admin_token();
$error_msg = '';
$qaconfig = get_qa_config();
// 관리자가 자동등록방지를 사용해야 할 경우
if ($board && ($qaconfig['qa_include_head'] !== $_POST['qa_include_head'] || $qaconfig['qa_include_tail'] !== $_POST['qa_include_tail']) && function_exists('get_admin_captcha_by') && get_admin_captcha_by()){
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
if (!chk_captcha()) {
alert('자동등록방지 숫자가 틀렸습니다.');
}
}
if( $qa_include_head ){
$file_ext = pathinfo($qa_include_head, PATHINFO_EXTENSION);
@ -75,6 +86,9 @@ $sql = " update {$g5['qa_config_table']}
qa_5 = '{$_POST['qa_5']}' ";
sql_query($sql);
if(function_exists('get_admin_captcha_by'))
get_admin_captcha_by('remove');
if($error_msg){
alert($error_msg, './qa_config.php');
} else {

View File

@ -4,7 +4,7 @@ include_once("./_common.php");
auth_check($auth[$sub_menu], "w");
check_token();
check_admin_token();
if($atype == "del"){
$count = count($_POST['fo_no']);
@ -14,7 +14,7 @@ if($atype == "del"){
for ($i=0; $i<$count; $i++)
{
// 실제 번호를 넘김
$fo_no = $_POST['fo_no'][$i];
$fo_no = (int) $_POST['fo_no'][$i];
if (!trim($fo_no)) continue;
$res = sql_fetch("select * from {$g5['sms5_form_table']} where fo_no='$fo_no'");

View File

@ -13,6 +13,8 @@ $g5['title'] = "휴대폰번호 관리";
if ($page < 1) $page = 1;
$bg_no = isset($bg_no) ? (int) $bg_no : 0;
if (is_numeric($bg_no))
$sql_group = " and bg_no='$bg_no' ";
else

View File

@ -2,6 +2,8 @@
// 코멘트 삭제
include_once('./_common.php');
$comment_id = (int) $comment_id;
$delete_comment_token = get_session('ss_delete_comment_'.$comment_id.'_token');
set_session('ss_delete_comment_'.$comment_id.'_token', '');

View File

@ -67,11 +67,18 @@ if (!get_session($ss_name))
insert_point($member['mb_id'], $board['bo_download_point'], "{$board['bo_subject']} $wr_id 파일 다운로드", $bo_table, $wr_id, "다운로드");
}
set_session($ss_name, TRUE);
}
// 이미 다운로드 받은 파일인지를 검사한 후 다운로드 카운트 증가 ( SIR 그누위즈 님 코드 제안 )
$ss_name = 'ss_down_'.$bo_table.'_'.$wr_id.'_'.$no;
if (!get_session($ss_name))
{
// 다운로드 카운트 증가
$sql = " update {$g5['board_file_table']} set bf_download = bf_download + 1 where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$no' ";
sql_query($sql);
set_session($ss_name, TRUE);
// 다운로드 카운트를 증가시키고 세션을 생성
$_SESSION[$ss_name] = true;
}
$g5['title'] = '다운로드 &gt; '.conv_subject($write['wr_subject'], 255);

View File

@ -5,7 +5,7 @@
********************/
define('G5_VERSION', '그누보드5');
define('G5_GNUBOARD_VER', '5.3.1.2');
define('G5_GNUBOARD_VER', '5.3.1.3');
define('G5_YOUNGCART_VER', '5.3.1.2');
// 이 상수가 정의되지 않으면 각각의 개별 페이지는 별도로 실행될 수 없음

View File

@ -3453,7 +3453,7 @@ function is_include_path_check($path='', $is_input='')
if( $path ){
if ($is_input){
if( strpos($path, 'php://') !== false || strpos($path, 'zlib://') !== false || strpos($path, 'bzip2://') !== false || strpos($path, 'zip://') !== false ){
if( stripos($path, 'php://') !== false || stripos($path, 'zlib://') !== false || stripos($path, 'bzip2://') !== false || stripos($path, 'zip://') !== false || stripos($path, 'data:text/') !== false || stripos($path, 'data://') !== false ){
return false;
}
@ -3500,7 +3500,7 @@ function is_include_path_check($path='', $is_input='')
$extension = pathinfo($path, PATHINFO_EXTENSION);
if($extension && preg_match('/(jpg|jpeg|png|gif|bmp|conf)$/', $extension)) {
if($extension && preg_match('/(jpg|jpeg|png|gif|bmp|conf)$/i', $extension)) {
return false;
}
}

View File

@ -4,8 +4,11 @@ include_once('./_common.php');
// 금일 인증시도 회수 체크
certify_count_check($member['mb_id'], 'hp');
include_once('./hpcert.config.php');
//include_once('./hpcert.config.php');
// KISA 취약점 내용(KVE-2018-0291) hpcert1.php의 $cmd 함수에 대한 인자 값은 hpcert_config.php 파일에서 설정되나, 이를 다른 페이지에서 포함한 뒤 호출할 시 임의 값 설정 가능
// 이에 include_once 를 include 로 수정함
include('./hpcert.config.php');
/**************************************************************************
okname 실행
**************************************************************************/

View File

@ -1,7 +1,10 @@
<?php
include_once('./_common.php');
include_once('./hpcert.config.php');
//include_once('./hpcert.config.php');
// KISA 취약점 내용(KVE-2018-0291) hpcert1.php의 $cmd 함수에 대한 인자 값은 hpcert_config.php 파일에서 설정되나, 이를 다른 페이지에서 포함한 뒤 호출할 시 임의 값 설정 가능
// 이에 include_once 를 include 로 수정함
include('./hpcert.config.php');
/**************************************************************************
파일명 : safe_hs_cert3.php