gongfuxiang / shopxo

ShopXO企业级免费开源商城系统,可视化DIY拖拽装修、包含PC、H5、多端小程序(微信+支付宝+百度+头条&抖音+QQ+快手)、APP、多仓库、多商户、多门店、IM客服,进销存遵循MIT开源协议发布、基于ThinkPHP8框架研发
https://shopxo.net
MIT License
2.64k stars 799 forks source link

There is a File upload vulnerability that can getshell #47

Open lavon321 opened 4 years ago

lavon321 commented 4 years ago

The file upload vulnerability here lies in the blacklist method used when verifying the suffix of the uploaded file. This verification method is not strict and is often bypassed by attackers in various ways The PluginsUpload method in the application\service\PluginsAdminService.php file has a file creation operation, in which the input of the file_put_contents function is controllable image Line 1072 checks the file suffix name, here is the blacklist check image The value in the private static variable $exclude_ext is ‘.php’, which can easily be bypassed image There are many ways to bypass the blacklist verification of suffix names. Taking my local Windows system environment as an example, you can upload file names that do not conform to the Windows file naming rules

shell.php::$DATA shell.php::$DATA……. shell.php. shell.php(空格) shell.php:1.jpg

The windows system will automatically remove the content behind the symbols that do not conform to the rules. You can change the file suffix in the linux environment and upload it to the website Through the audit of the PluginsUpload method in the PluginsAdminService.php file When the zip archive does not match the resource directory, it will jump out of the loop of reading the archive file image image image And the resource directory cannot be controller, because the directory corresponding to controller exists, and the compressed package will be closed directly without entering the subsequent file writing operation image Finally, the method is called in the Upload method of the application\admin\controller\Pluginsadmin.php file image

The attacker can upload such a compressed package after logging into the background system image And upload the compressed package at Application Center -> Application Management -> Upload Application image Visit public\static\upload\file_uploadfile_\shell.php image

In application\service\ThemeService.php there is also the same blacklist verification problem for uploaded files image The processing logic is very similar to the above file After logging in to the system, upload the zip archive at the site management -> theme management -> theme installation image Visit public\static\index\test.php after uploading image