Thinkphp 缓存RCE
|
?5.0.0<=ThinkPHP5<=5.0.10?。 ? 漏洞利用条件: 1.基于tp5开发的代码中使用了Cache::set 进行缓存 2.在利用版本范围内 3.runtime目录可以访问 ? 扩展: 1.不可访问,可以考虑包含。前提要找到包含处。//Tp有一个Cache一个包含 2.利用缓存,做一个长期的shell动态生成。 ? 漏洞原因:缓存名,可以预测,缓存内容用户可控。 ? 造成漏洞代码 <?php namespace appindexcontroller; use thinkCache; class Index { public function index() { Cache::set("name",input("get.username")); return ‘Cache success‘; } } ? use thinkCache; 跟到thinkCache.php thinkCache.php 文件内容 use thinkcacheDriver; set 方法
return self::init()->set($name,$value,$expire); ? 自动缓存
? 在init 方法里 ?
?
Config::get(‘cache.type‘)
? ? 默认为File类型 程序获取cache type 以后
?
? 这样就加载了 thinkcachedriverFile.php ? ? return self::init()->set($name,$expire); 通过Init() 调用file 下的set方法
if (is_null($expire)) {
? 那么$expire=0 ? 目录名以及文件名: protected function getCacheKey($name,$auto = false) ? $filename
找到set 的缓存名 就可以了 进行md5加密 前2位 为目录名,后30位 为文件名
?
来dump一下 serialize 前后变化 ?
? 文件的写入,这里为tp5.0.15 版本,作者对$data 进行了位置修改,并在$data 前,做了 exit()来避免用户输入的数据,被代码执行。 并且在$expire 这处,做了一个%012d强制的类型转换
? 在tp5.0.10 之前,这段代码是这样的 ?
?
写入的数据,之前没有exit,并且对$data 没有做过滤 导致利用%0a换行,进行代码执行。
我们访问一下文件
成功可以代码执行 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |



















