记录两个thinkphp的错误类型

背景

在测试一些thinkphp站点的时候,遇到了两个问题,导致忽略了一些漏洞

在无意间,发现,诶这东西哪来的?于是开始回溯

第一种错误

错误如下图所示

1615548542643

测试代码

1
2
3
4
5
6
7
8
9
10
11
12
13
public function test(&$path)
{
$temp = explode('/', $path);
$cur_dir = '';
$max = count($temp) - 1;
for ($i = 0; $i < $max; $i++) {
$cur_dir .= $temp[$i] . '/';
if (@is_dir($cur_dir))
continue;
@mkdir($cur_dir, 0777, true);
@chmod($cur_dir, 0777);
}
}

上面错误的调用堆栈如下

1
2
3
4
5
6
7
1. in App.php line 343
2. at ReflectionMethod->invokeArgs(object(Tasks), ['aaa']) in App.php line 343
3. at App::invokeMethod([object(Tasks), 'test'], []) in App.php line 611
4. at App::module(['api', 'tasks', 'test'], ['app_host' => '', 'app_debug' => true, 'app_trace' => true, ...], true) in App.php line 456
5. at App::exec(['type' => 'module', 'module' => ['api', 'tasks', 'test']], ['app_host' => '', 'app_debug' => true, 'app_trace' => true, ...]) in App.php line 139
6. at App::run() in start.php line 19
7. at require('D:\phpstudy\director...') in index.php line 24

这是没有调用到相应的方法的

根本原因

原因:后来发现也挺简单就是,&$path 存在引用符号,就是说前面需要此变量的定义,如果未定义,则无法引用,导致抛出异常

所以这个样式写的public方法,都是被此控制器的其他方法调用的,无法直接访问

于是乎做了一个比较苟的总结,看到这种调用堆栈没有调用到相应方法的就觉得方法没有被调用

知道遇到下面这个错误

第二种错误

直接在tp框架的内酯类返回错误

且堆栈调用只有四行

1615549323902

测试代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public function test($path)
{
$temp = explode('/', $path);
$cur_dir = '';
$max = count($temp) - 1;
for ($i = 0; $i < $max; $i++) {
$cur_dir .= $temp[$i] . '/';
if (@is_dir($cur_dir))
continue;
@mkdir($cur_dir, 0777, true);
@chmod($cur_dir, 0777);
}
return is_dir($path);
}

发现问题

然后突然发现目录下生成了aaa目录

那就是这个方法最终对调用了,开启流程跟踪

发现确实调用了

1615549474795

那这个问题是什么意思呢

查阅手册,发现response只接受string类型

返回其他类型均会报错

is_dir()会返回一个布尔类型,所以导致错误,但是该走的程序都已经运行完毕

后续通过这个发现某cms的未授权的RCE

end