来源链接:http://www.cnbraid.com/ ### 0x01 背景 由于默认安装后需要超级管理员权限,故该漏洞很鸡肋,但感觉应该会在其它cms中也存在,所以主要分享下挖掘思路~ PS:使用的测试环境是php5.6(已经移除gpc选项)  ### 0x02 漏洞分析 漏洞起源: yoursite\phpsso_server\phpcms\modules\admin\system.php下的uc函数: ``` <?php public function uc() { if (isset($_POST['dosubmit'])) { $data = isset($_POST['data']) ? $_POST['data'] : ''; $data['ucuse'] = isset($_POST['ucuse']) && intval($_POST['ucuse']) ? intval($_POST['ucuse']) : 0; $filepath = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.'system.php'; $config = include $filepath; $uc_config = '<?php '."\ndefine('UC_CONNECT', 'mysql');\n"; foreach ($data as $k => $v) { $old[] = "'$k'=>'".(isset($config[$k]) ? $config[$k] : $v)."',"; $new[] = "'$k'=>'$v',"; $uc_config .= "define('".strtoupper($k)."', '$v');\n"; } $html = file_get_contents($filepath); $html = str_replace($old, $new, $html); $uc_config_filepath = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.'uc_config.php';...
来源链接:http://www.cnbraid.com/ ### 0x01 背景 由于默认安装后需要超级管理员权限,故该漏洞很鸡肋,但感觉应该会在其它cms中也存在,所以主要分享下挖掘思路~ PS:使用的测试环境是php5.6(已经移除gpc选项)  ### 0x02 漏洞分析 漏洞起源: yoursite\phpsso_server\phpcms\modules\admin\system.php下的uc函数: ``` <?php public function uc() { if (isset($_POST['dosubmit'])) { $data = isset($_POST['data']) ? $_POST['data'] : ''; $data['ucuse'] = isset($_POST['ucuse']) && intval($_POST['ucuse']) ? intval($_POST['ucuse']) : 0; $filepath = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.'system.php'; $config = include $filepath; $uc_config = '<?php '."\ndefine('UC_CONNECT', 'mysql');\n"; foreach ($data as $k => $v) { $old[] = "'$k'=>'".(isset($config[$k]) ? $config[$k] : $v)."',"; $new[] = "'$k'=>'$v',"; $uc_config .= "define('".strtoupper($k)."', '$v');\n"; } $html = file_get_contents($filepath); $html = str_replace($old, $new, $html); $uc_config_filepath = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.'uc_config.php'; @file_put_contents($uc_config_filepath, $uc_config); @file_put_contents($filepath, $html); $this->db->insert(array('name'=>'ucenter', 'data'=>array2string($data)), 1,1); showmessage(L('operation_success'), HTTP_REFERER); } $data = array(); $r = $this->db->get_one(array('name'=>'ucenter')); if ($r) { $data = string2array($r['data']); } include $this->admin_tpl('system_uc'); } ... ``` 将表单中的数据$data按照键值对遍历并以如下形式存储到$uc_config变量里: ``` $uc_config .= "define('".strtoupper($k)."', '$v');\n"; ``` 上面只是对$k变量进行了字母转大写处理,然后就写到`yoursite\phpsso_server\caches\configs\uc_config.php`中了,所以这里应该可以构造一句话木马写入到uc_config.php中,从而拿到webshell。 ### 0x03 漏洞证明 通过观察uc_config.php,我们构造一句话木马的方法如下(审查元素或者代理改包均可):  获取shell  本文由HackBraid整理总结,原文链接:http://www.cnbraid.com/