### 简要描述: 愉快地打脸打脸打脸,厂商你真的考虑周到了吗? 我已不在乎你是否忽略,给多少rank,我是来宣传我们团队的:parsec.me~~ ### 详细说明: 依旧是finecms用户头像上传部分:/member/controller/Account.php 412行: ``` public function upload() { // 大众版头像上传处理 2014-6-15 if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { exit(function_exists('iconv') ? iconv('UTF-8', 'GBK', '环境不支持') : 'The php does not support'); } // 创建图片存储文件夹 $dir = FCPATH.'member/uploadfile/member/'.$this->uid.'/'; if (!file_exists($dir)) { mkdir($dir, 0777, true); } $filename = $dir.'avatar.zip'; // 存储flashpost图片 file_put_contents($filename, $GLOBALS['HTTP_RAW_POST_DATA']); // 解压缩文件 $this->load->library('Pclzip'); $this->pclzip->PclFile($filename); $content = $this->pclzip->listContent(); if (!$content) { @unlink($filename); exit(function_exists('iconv') ? iconv('UTF-8', 'GBK', '文件已损坏') : 'The file has damaged'); } // 验证文件 foreach ($content as $t) { if (strpos($t['stored_filename'], '..') !== FALSE || strpos($t['filename'], '..') !== FALSE || strpos($t['filename'], '/') !== FALSE ||...
### 简要描述: 愉快地打脸打脸打脸,厂商你真的考虑周到了吗? 我已不在乎你是否忽略,给多少rank,我是来宣传我们团队的:parsec.me~~ ### 详细说明: 依旧是finecms用户头像上传部分:/member/controller/Account.php 412行: ``` public function upload() { // 大众版头像上传处理 2014-6-15 if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { exit(function_exists('iconv') ? iconv('UTF-8', 'GBK', '环境不支持') : 'The php does not support'); } // 创建图片存储文件夹 $dir = FCPATH.'member/uploadfile/member/'.$this->uid.'/'; if (!file_exists($dir)) { mkdir($dir, 0777, true); } $filename = $dir.'avatar.zip'; // 存储flashpost图片 file_put_contents($filename, $GLOBALS['HTTP_RAW_POST_DATA']); // 解压缩文件 $this->load->library('Pclzip'); $this->pclzip->PclFile($filename); $content = $this->pclzip->listContent(); if (!$content) { @unlink($filename); exit(function_exists('iconv') ? iconv('UTF-8', 'GBK', '文件已损坏') : 'The file has damaged'); } // 验证文件 foreach ($content as $t) { if (strpos($t['stored_filename'], '..') !== FALSE || strpos($t['filename'], '..') !== FALSE || strpos($t['filename'], '/') !== FALSE || strpos($t['stored_filename'], '/') !== FALSE) { @unlink($filename); exit(function_exists('iconv') ? iconv('UTF-8', 'GBK', '非法名称的文件') : 'llegal name file'); } if (substr(strrchr($t['stored_filename'], '.'), 1) != 'jpg') { @unlink($filename); exit(function_exists('iconv') ? iconv('UTF-8', 'GBK', '文件格式校验不正确') : 'The document format verification is not correct'); } } // 解压文件 if ($this->pclzip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REPLACE_NEWER) == 0) { @dr_dir_delete($dir); exit($this->pclzip->zip(true)); } @unlink($filename); if (!is_file($dir.'45x45.jpg') || !is_file($dir.'90x90.jpg')) { exit('文件创建失败'); } ``` 看逻辑,首先将zip文件写入目录,然后用$this->pclzip->listContent();先将文件中内容列出来,然后逐一判断: 1.含有..、/的不允许解压,也就是说不能再通过../../../的方式解压到首页了 2.后缀不是.jpg不允许解压 3.之前的删除操作没有了,以上判断完成后就直接解压。 且不深入研究zip内部的格式,只需要按照小白的想法想一下,这样真的过滤周到了么? 在IIS6中,可以利用解析漏洞来绕过这个限制: 文件名改成1.php;.jpg即可 一个分号解决各种问题。 详见漏洞证明。 ### 漏洞证明: 我手上没有IIS6服务器,就只演示说明一下可以解压为1.php;.jpg就行了。 先本地把压缩包弄好: [<img src="https://images.seebug.org/upload/201408/061944481a142b150bbba5fcae6601890d098b02.jpg" alt="01.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/061944481a142b150bbba5fcae6601890d098b02.jpg) 上传抓包: [<img src="https://images.seebug.org/upload/201408/0619450010e31f4e6bc8fffb58f77ae42615895d.jpg" alt="02.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/0619450010e31f4e6bc8fffb58f77ae42615895d.jpg) 上传成功,查看网站目录即可看到文件: [<img src="https://images.seebug.org/upload/201408/0619453490179e3fb6bc6cf85b41cd10f97fcfd7.jpg" alt="03.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/0619453490179e3fb6bc6cf85b41cd10f97fcfd7.jpg) [<img src="https://images.seebug.org/upload/201408/061948120f3c95af30042d76fe0cfddff753deb2.jpg" alt="04.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/061948120f3c95af30042d76fe0cfddff753deb2.jpg) 因为我本地是apache就不演示代码执行的了,在IIS6下可以通过解析漏洞来执行代码。