环境搭建
1 | composer create-project topthink/think tp 6.0.12 |
将composer.json中的topthink/framework依赖改为1
2
3
4
5"require": {
"php": ">=7.2.5",
"topthink/framework": "6.0.12",
"topthink/think-orm": "^2.0"
},
tip:去掉^,不然会自动更新到最新版本
开启多语言功能
文件包含
在public目录下新建test.php1
2
echo "iloveflag";
访问http://127.0.0.1/tp/public/index.php?lang=../../../../../public/test
入口文件tp\vendor\topthink\framework\src\think\middleware\LoadLangPack.php中
handle函数中使用了detect函数检测传入的$request对象
进入detect()函数在91行if检测语言列表的时候发现$this->config[‘allow_lang_list’]为空且 $langSet为../../../../../public/test不在匹配列表中
返回detect函数$range值与 $this->lang->defaultLangSet()相比较
下一步关键处:1
$this->lang->switchLangSet($langset);
进入查看load函数,中间变量拼接成了文件包含的地址
跟进load()函数
遍历出$file 为 $name变量
跟进parse()函数,明显进行了include操作造成漏洞
RCE
参照此文
docker-php-include-getshell.html#0x06-pearcmdphp
进行文件写入,然后文件包含getshell
pecl是PHP中用于管理扩展而使用的命令行工具,而pear是pecl依赖的类库。在7.3及以前,pecl/pear是默认安装的;在7.4及以后,需要我们在编译PHP的时候指定—with-pear才会安装
Docker环境下的PHP会开启register_argc_argv这个配置