Exploits / Vulnerability Discovered : 2022-01-05 |
Type : webapps |
Platform : php
This exploit / vulnerability Ritecms 3.1.0 remote code execution (rce) (authenticated) is for educational purposes only and if it is used you will do on your own risk!
# RiteCMS version 3.1.0 and below suffers from a remote code execution in admin panel. An authenticated attacker can upload a php file and bypass the .htacess configuration that deny execution of .php files in media and files directory by default.
# There are 4 ways of bypassing the current file upload protection to achieve remote code execution.
# Method 1: Delete the .htaccess file in the media and files directory through the files manager module and then upload the php file - RCE achieved
# Method 2: Rename .php file extension to .pHp or any except ".php", eg shell.pHp and upload the shell.pHp file - RCE achieved
# Method 3: Chain with Arbitrary File Overwrite vulnerability by uploading .php file to web root because .php execution is allow in web root - RCE achieved
By default, attacker can only upload image in media and files directory only - Arbitrary File Overwrite vulnerability.
Intercept the request, modify file_name param and place this payload "../webrootExec.php" to upload the php file to web root
So, webshell can be accessed in web root via http://localhost/ritecms.v3.1.0/webrootExec.php
# Method 4: Upload new .htaccess to overwrite the old one with content like below for allowing access to one specific php file named "webshell.php" then upload PHP webshell.php - RCE achieved
$ cat .htaccess
<Files *.php>
deny from all
</Files>
<Files ~ "webshell\.php$">
Allow from all
</Files>
###################################
# PoC for webshell using Method 2 #
###################################
Steps to Reproduce:
1. Login as admin
2. Go to Files Manager
3. Choose a directory to upload .php file either media or files directory.
4. Then, click Upload file > Browse..
3. Upload .php file with extension of pHp, eg webshell.pHp - to bypass .htaccess
4. The webshell.pHp is available at http://localhost/ritecms.v3.1.0/media/webshell.pHp - if you choose media directory else switch to files directory