phpcms前台注入导致任意文件读取漏洞

2016年9月27日 建站技术 浏览 3,996 1 条评论 A+

phpcms前台注入导致任意文件读取漏洞 建站技术

漏洞名称phpcms前台注入导致任意文件读取漏洞

文件路径:/phpcms/modules/content/down.php

漏洞描述:phpcms的/phpcms/modules/content/down.php文件中,对输入参数$_GET['a_k']未进行严格过滤,导致SQL注入的发生,黑客可利用该漏洞读取任意文件。

修复区域(1),所在位置约17行

$a_k = trim($_GET['a_k']);
if (!isset($a_k)) {
    showmessage(L('illegal_parameters'));
}
$a_k = sys_auth($a_k, 'DECODE', pc_base::load_config('system', 'auth_key'));
if (empty($a_k)) {
    showmessage(L('illegal_parameters'));
}
unset($i, $m, $f);
parse_str($a_k);
if (isset($i)) {
    $i = $id = intval($i);
}

修改为:

$a_k = trim($_GET['a_k']);
if (!isset($a_k)) {
    showmessage(L('illegal_parameters'));
}
$a_k = sys_auth($a_k, 'DECODE', pc_base::load_config('system', 'auth_key'));
if (empty($a_k)) {
    showmessage(L('illegal_parameters'));
}
unset($i, $m, $f);
parse_str($a_k);
$a_k = safe_replace($a_k); //此处为修补代码,约第17行
if (isset($i)) {
    $i = $id = intval($i);
}

修复区域(2),所在位置约89行

$a_k = trim($_GET['a_k']);
$pc_auth_key = md5(pc_base::load_config('system', 'auth_key') . $_SERVER['HTTP_USER_AGENT'] . 'down');
$a_k = sys_auth($a_k, 'DECODE', $pc_auth_key);
if (empty($a_k)) {
    showmessage(L('illegal_parameters'));
}
unset($i, $m, $f, $t, $ip);
parse_str($a_k);
if (isset($i)) {
    $downid = intval($i);
}

修改为:

$a_k = trim($_GET['a_k']);
$pc_auth_key = md5(pc_base::load_config('system', 'auth_key') . $_SERVER['HTTP_USER_AGENT'] . 'down');
$a_k = sys_auth($a_k, 'DECODE', $pc_auth_key);
if (empty($a_k)) {
    showmessage(L('illegal_parameters'));
}
unset($i, $m, $f, $t, $ip);
parse_str($a_k);
$a_k = safe_replace($a_k); //此处为修补代码,约第89行
if (isset($i)) {
    $downid = intval($i);
}

修复区域(3),所在位置约120行

//处理中文文件
if(preg_match("/^([\s\S]*?)([\x81-\xfe][\x40-\xfe])([\s\S]*?)/", $fileurl)) {
   $filename = str_replace(array("%5C", "%2F", "%3A"), array("\\", "/", ":"), urlencode($fileurl));
   $filename = urldecode(basename($filename));
}
$ext = fileext($filename);
$filename = date('Ymd_his').random(3).'.'.$ext;
file_down($fileurl, $filename);

修改为:

//处理中文文件
if(preg_match("/^([\s\S]*?)([\x81-\xfe][\x40-\xfe])([\s\S]*?)/", $fileurl)) {
    $filename = str_replace(array("%5C", "%2F", "%3A"), array("\\", "/", ":"), urlencode($fileurl));
    $filename = urldecode(basename($filename));
}
$ext = fileext($filename);
$filename = date('Ymd_his').random(3).'.'.$ext;
$fileurl = str_replace(array('<','>'), '',$fileurl); //此处为修补代码,约第120行
file_down($fileurl, $filename);

目前评论:1   其中:访客  1   博主  0

  1. 比特币交易平台 3

    导致SQL注入的发生,黑客可利用该漏洞读取任意文件。

评论加载中...

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: