세션 폴더에 접근할수 문제 수정 및 세션 저장경로 수정#175

This commit is contained in:
thisgun
2022-05-23 18:37:23 +09:00
parent 5a4ddbc455
commit f4aa0d0cd8
11 changed files with 124 additions and 17 deletions

View File

@ -274,9 +274,15 @@ function chk_captcha()
return false;
}
if (!isset($_POST['captcha_key'])) return false;
if (!trim($_POST['captcha_key'])) return false;
if ($_POST['captcha_key'] != get_session('ss_captcha_key')) {
$post_captcha_key = (isset($_POST['captcha_key']) && $_POST['captcha_key']) ? trim($_POST['captcha_key']) : '';
if (!trim($post_captcha_key)) return false;
if( $post_captcha_key && function_exists('get_string_encrypt') ){
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
$post_captcha_key = get_string_encrypt($ip.$post_captcha_key);
}
if ($post_captcha_key != get_session('ss_captcha_key')) {
$_SESSION['ss_captcha_count'] = $captcha_count + 1;
return false;
}

View File

@ -3,6 +3,11 @@ include_once("_common.php");
include_once('captcha.lib.php');
$captcha = new KCAPTCHA();
$captcha->setKeyString(get_session("ss_captcha_key"));
$ss_captcha_key = get_session("ss_captcha_key");
if( $ss_captcha_key && !preg_match('/^[0-9]/', $ss_captcha_key) && function_exists('get_string_decrypt') ){
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
$ss_captcha_key = str_replace($ip, '', get_string_decrypt($ss_captcha_key));
}
$captcha->setKeyString($ss_captcha_key);
$captcha->getKeyString();
$captcha->image();

View File

@ -8,6 +8,10 @@ function make_mp3()
$number = get_session("ss_captcha_key");
if ($number == "") return;
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
if( $number && function_exists('get_string_decrypt') ){
$number = str_replace($ip, '', get_string_decrypt($number));
}
if ($number == get_session("ss_captcha_save")) return;
$mp3s = array();
@ -16,7 +20,6 @@ function make_mp3()
$mp3s[] = $file;
}
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
$mp3_file = 'cache/kcaptcha-'.$ip.'_'.G5_SERVER_TIME.'.mp3';
$contents = '';
@ -35,6 +38,9 @@ function make_mp3()
}
}
if( $number && function_exists('get_string_encrypt') ){
$number = get_string_encrypt($ip.$number);
}
set_session("ss_captcha_save", $number);
return G5_DATA_URL.'/'.$mp3_file;

View File

@ -9,5 +9,10 @@ if ($count >= 5) { // 설정값 이상이면 자동등록방지 입력 문자가
echo false;
} else {
set_session("ss_captcha_count", $count + 1);
if( $captcha_key && function_exists('get_string_encrypt') ){
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
$captcha_key = get_string_encrypt($ip.$captcha_key);
}
echo (get_session("ss_captcha_key") === $captcha_key) ? true : false;
}

View File

@ -11,6 +11,11 @@ while(true){
if(!preg_match('/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/', $keystring)) break;
}
if( $keystring && function_exists('get_string_encrypt') ){
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
$keystring = get_string_encrypt($ip.$keystring);
}
set_session("ss_captcha_count", 0);
set_session("ss_captcha_key", $keystring);
$captcha = new KCAPTCHA();

View File

@ -11,6 +11,7 @@ require_once realpath(dirname(__FILE__)) . "/StorageInterface.php";
* HybridAuth storage manager
*/
class Hybrid_Storage implements Hybrid_Storage_Interface {
public static $stores = array();
/**
* Constructor
@ -37,11 +38,21 @@ class Hybrid_Storage implements Hybrid_Storage_Interface {
$key = strtolower($key);
if ($value) {
$_SESSION["HA::CONFIG"][$key] = serialize($value);
$serialize_value = function_exists('get_string_encrypt') ? get_string_encrypt(serialize($value)) : serialize($value);
if( in_array($key, array('php_session_id', 'config')) ){
$this->stores[$key] = $serialize_value;
} else {
$_SESSION["HA::CONFIG"][$key] = $serialize_value;
}
} elseif (isset($this->stores[$key])) {
$unserialize_value = function_exists('get_string_decrypt') ? unserialize(get_string_decrypt($this->stores[$key])) : unserialize($this->stores[$key]);
return $unserialize_value;
} elseif (isset($_SESSION["HA::CONFIG"][$key])) {
return unserialize($_SESSION["HA::CONFIG"][$key]);
$unserialize_value = function_exists('get_string_decrypt') ? unserialize(get_string_decrypt($_SESSION["HA::CONFIG"][$key])) : unserialize($_SESSION["HA::CONFIG"][$key]);
return $unserialize_value;
}
return null;
}
@ -55,7 +66,8 @@ class Hybrid_Storage implements Hybrid_Storage_Interface {
$key = strtolower($key);
if (isset($_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key])) {
return unserialize($_SESSION["HA::STORE"][$key]);
$unserialize_value = function_exists('get_string_decrypt') ? unserialize(get_string_decrypt($_SESSION["HA::STORE"][$key])) : unserialize($_SESSION["HA::STORE"][$key]);
return $unserialize_value;
}
return null;
@ -70,7 +82,8 @@ class Hybrid_Storage implements Hybrid_Storage_Interface {
*/
public function set($key, $value) {
$key = strtolower($key);
$_SESSION["HA::STORE"][$key] = serialize($value);
$serialize_value = function_exists('get_string_encrypt') ? get_string_encrypt(serialize($value)) : serialize($value);
$_SESSION["HA::STORE"][$key] = $serialize_value;
}
/**
@ -138,4 +151,4 @@ class Hybrid_Storage implements Hybrid_Storage_Interface {
$_SESSION["HA::STORE"] = unserialize($sessiondata);
}
}
}

View File

@ -391,7 +391,8 @@ function social_session_exists_check(){
}
if( $provider_name && isset($_SESSION['HA::STORE']['hauth_session.'.strtolower($provider_name).'.is_logged_in']) && !empty($_SESSION['sl_userprofile'][$provider_name]) ){
return json_decode($_SESSION['sl_userprofile'][$provider_name]);
$decode_value = function_exists('get_string_decrypt') ? json_decode(get_string_decrypt($_SESSION['sl_userprofile'][$provider_name])) : json_decode($_SESSION['sl_userprofile'][$provider_name]);
return $decode_value;
}
return false;
@ -485,8 +486,9 @@ function social_check_login_before($p_service=''){
$_SESSION['sl_userprofile'] = array();
}
if( ! $is_member ){
$_SESSION['sl_userprofile'][$provider_name] = json_encode( $user_profile );
if( ! $is_member ){
$encode_value = function_exists('get_string_encrypt') ? get_string_encrypt(json_encode($user_profile)) : json_encode($user_profile);
$_SESSION['sl_userprofile'][$provider_name] = $encode_value;
}
}

View File

@ -3,6 +3,40 @@ if (!defined('_GNUBOARD_')) exit;
class G5_Hybrid_Endpoint extends Hybrid_Endpoint
{
protected function authInit() {
if (!$this->initDone) {
$this->initDone = true;
// Init Hybrid_Auth
try {
if (!class_exists("Hybrid_Storage", false)) {
require_once realpath(dirname(dirname(__FILE__))). "/Hybrid/Storage.php";
}
if (!class_exists("Hybrid_Exception", false)) {
require_once realpath(dirname(dirname(__FILE__))). "/Hybrid/Exception.php";
}
if (!class_exists("Hybrid_Logger", false)) {
require_once realpath(dirname(dirname(__FILE__))). "/Hybrid/Logger.php";
}
$storage = new Hybrid_Storage();
$provider_id = ucfirst(trim(strip_tags($this->request["hauth_start"])));
if(!$provider_id) $provider_id = ucfirst(trim(strip_tags($this->request["hauth_done"])));
$storage->config("CONFIG", social_build_provider_config($provider_id));
// Check if Hybrid_Auth session already exist
if (!$storage->config("CONFIG")) {
$this->dieError("CONFIG FAILED: ", "Unable to get config", array());
}
Hybrid_Auth::initialize($storage->config("CONFIG"));
} catch (Exception $e) {
Hybrid_Logger::error("Endpoint: Error while trying to init Hybrid_Auth: " . $e->getMessage());
$this->dieError("Endpoint Error: ", $e->getMessage(), $e);
}
}
}
protected function processAuthStart(){
try {
parent::processAuthStart();