Skip to content

Latest commit

 

History

History
87 lines (42 loc) · 2.91 KB

任意文件上传.md

File metadata and controls

87 lines (42 loc) · 2.91 KB

ThinkCMF 6.0.9 File upload vulnerability

Source code information

ThinkCMF: ThinkCMF是一款支持Swoole的开源内容管理框架,基于ThinkPHP开发,同时支持PHP-FPM和Swoole双模式,让WEB开发更快! (gitee.com)

image-2024222466948.png

code analysis

Vulnerability file:ThinkCMF-master/vendor/thinkcmf/cmf-app/src/user/controller/UeditorController.php

Found an editor function point on the site image-20242223652626.png

Find the image upload to capture the corresponding function to find the code file image-2024222383526.png image-2024222402749.png

Enter ueditorUpload("image") according to the code in the upload function and the $action value of the requested package parameter; , 273 lines of code in the ueditorUpload function process the uploaded file and return the value to $result

image-20242225114529.png

The file Upload and the content returned by the return package are completed in the upload class, and the suffix of the uploaded file is mainly detected in lines 103-110

image-2024222304310.png

103 lines of code are

image-20242223324481.png

105 lines of code are image-20242223449314.png

This if determines whether the suffix is not in the allowed suffix and determines whether the suffix is equal to php, requires that both conditions are not satisfied, and if one of them is met, it directly returns "illegal file type".

if (!in_array($strFileExtension, $arrAllowedExtensions) || $strFileExtension == 'php') {  
    $this->error = "非法文件类型!";  
    return false;  
}

if you bypass the above if judgment, you can execute the following code to complete the file upload

image-20242223947934.png

Add 'php::$dada' to the upload Settings (using windows features to create a' php::$dada' suffix file will eventually create a' php' suffix file) so uploading a' php::$dada' suffix file can bypass the above filtering

image-20242225429938.png

Successfully bypass filtering to upload a php file

image-2024222289201.png

image-20242222339965.png

Exploits

Change a php file containing shell code to a png suffix to bypass front-end restrictions and upload

image-20242223556823.png

Change the png suffix to 'php::$data', send the request packet to complete the upload, and upload successfully image-2024222380861.png image-20242223841316.png

After accessing the url address, use the webshell tool to make a shell connection

image-2024222432993.png