Discuz教程网

Discuz! X系列远程代码执行漏洞分析

[复制链接]
authicon dly 发表于 2016-2-27 00:50:10 | 显示全部楼层 |阅读模式
api/uc.php 中有这个函数

  1. function updatebadwords($get, $post) {
  2.     global $_G;

  3.     if(!API_UPDATEBADWORDS) {
  4.         return API_RETURN_FORBIDDEN;
  5.     }

  6.     $data = array();
  7.     if(is_array($post)) {
  8.         foreach($post as $k => $v) {
  9.             $data['findpattern'][$k] = $v['findpattern'];
  10.             $data['replace'][$k] = $v['replacement'];
  11.         }
  12.     }
  13.     $cachefile = DISCUZ_ROOT.'./uc_client/data/cache/badwords.php';
  14.     $fp = fopen($cachefile, 'w');
  15.     $s = "<?php\r\n";
  16.     $s .= '$_CACHE[\'badwords\'] = '.var_export($data, TRUE).";\r\n";
  17.     fwrite($fp, $s);
  18.     fclose($fp);

  19.     return API_RETURN_SUCCEED;
  20. }
复制代码

本来是匹配字符串中不文明的字符,

  1. function check_usernamecensor($username) {
  2.     $_CACHE['badwords'] = $this->base->cache('badwords');
  3.     $censorusername = $this->base->get_setting('censorusername');
  4.     $censorusername = $censorusername['censorusername'];
  5.     $censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($censorusername = trim($censorusername)), '/')).')$/i';
  6.     $usernamereplaced = isset($_CACHE['badwords']['findpattern']) && !empty($_CACHE['badwords']['findpattern']) ? @preg_replace($_CACHE['badwords']['findpattern'], $_CACHE['badwords']['replace'], $username) : $username;
  7.     if(($usernamereplaced != $username) || ($censorusername && preg_match($censorexp, $username))) {
  8.         return FALSE;
  9.     } else {
  10.         return TRUE;
  11.     }
  12. }
复制代码

但是在uc_client/model/user.php 中使用了preg_replace()函数进行匹配,我们知道在preg_[match|replace|matchall]中如果匹配字符中有/e参数的话,是可以把第二个参数当作命令执行的。

discuz中的用户交互都是用uc_key进行加密的。所以我们要先输出一下我们加密后的url。这样是因为之后会使用action之后的参数作为要执行的函数。,而time是因为要进行时间判断,如果超过60分钟就会提示 Authracation has expiried 时间超时

  1. $a = "time=". time() ."&action=updatebadwords";
  2. echo _authcode($a, 'ENCODE', UC_KEY);
  3. exit();
复制代码

输出的是 4d28h0SBx+FkZPHcVochr3dMqShRmTiXl/75Z94JxgCuzBYpx6BcjXRnbr5q04fH/EWN/VPC51iJArv2hn2tlvxK

然后我们需要发送post请求,因为有$post = xml_unserialize(file_get_contents('php://input'));

1.png

这个会接受所有的post值然后进行xml的反序列化,就是我们发送一个xml格式的数据,然后被他反序列化成数组。之后就会写入到uc_client/data/cache/badwords.php  
2.png

然后在新建一个用户什么的,就触发了。

3.png






上一篇:Discuz教程网签到记录贴-2016年2月27日
下一篇:在线考试手机触屏版 触屏版 价值190元(2016.02.27更新)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-5-4 09:44

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表