### 简要描述: 又把20140618的补丁看了一看。 ### 详细说明: 顺便把之前发的任意文件删除的确认了一下? 之前图片贴错了 现在更新过来了。 这个绝对是从官网上刚下的20140618的补丁, 这次真的别再说618的补丁已经修复了。 my_goods.app.php中 ``` function _upload_image($goods_id) { import('image.func'); import('uploader.lib'); $uploader = new Uploader(); $uploader->allowed_type(IMAGE_FILE_TYPE); $uploader->allowed_size(SIZE_GOODS_IMAGE); // 400KB /* 取得剩余空间(单位:字节),false表示不限制 */ $store_mod =& m('store'); $settings = $store_mod->get_settings($this->_store_id); $upload_mod =& m('uploadedfile'); $remain = $settings['space_limit'] > 0 ? $settings['space_limit'] * 1024 * 1024 - $upload_mod->get_file_size($this->_store_id) : false; $files = $_FILES['new_file']; foreach ($files['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { /* 处理文件上传 */ $file = array( 'name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key], 'error' => $files['error'][$key] ); $uploader->addFile($file); if (!$uploader->file_info()) {...
### 简要描述: 又把20140618的补丁看了一看。 ### 详细说明: 顺便把之前发的任意文件删除的确认了一下? 之前图片贴错了 现在更新过来了。 这个绝对是从官网上刚下的20140618的补丁, 这次真的别再说618的补丁已经修复了。 my_goods.app.php中 ``` function _upload_image($goods_id) { import('image.func'); import('uploader.lib'); $uploader = new Uploader(); $uploader->allowed_type(IMAGE_FILE_TYPE); $uploader->allowed_size(SIZE_GOODS_IMAGE); // 400KB /* 取得剩余空间(单位:字节),false表示不限制 */ $store_mod =& m('store'); $settings = $store_mod->get_settings($this->_store_id); $upload_mod =& m('uploadedfile'); $remain = $settings['space_limit'] > 0 ? $settings['space_limit'] * 1024 * 1024 - $upload_mod->get_file_size($this->_store_id) : false; $files = $_FILES['new_file']; foreach ($files['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { /* 处理文件上传 */ $file = array( 'name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key], 'error' => $files['error'][$key] ); $uploader->addFile($file); if (!$uploader->file_info()) { $this->_error($uploader->get_error()); return false; } /* 判断能否上传 */ if ($remain !== false) { if ($remain < $file['size']) { $this->_error('space_limit_arrived'); return false; } else { $remain -= $file['size']; } } $uploader->root_dir(ROOT_PATH); $dirname = 'data/files/store_' . $this->_store_id . '/goods_' . (time() % 200); $filename = $uploader->random_filename(); $file_path = $uploader->save($dirname, $filename); $thumbnail = dirname($file_path) . '/small_' . basename($file_path); make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $thumbnail, THUMB_WIDTH, THUMB_HEIGHT, THUMB_QUALITY); /* 处理文件入库 */ $data = array( 'store_id' => $this->_store_id, 'file_type' => $file['type'], 'file_size' => $file['size'], 'file_name' => $file['name'], 'file_path' => $file_path, 'add_time' => gmtime(), ); $uf_mod =& m('uploadedfile'); $file_id = $uf_mod->add($data); ``` 重点看这里 ``` $data = array( 'store_id' => $this->_store_id, 'file_type' => $file['type'], 'file_size' => $file['size'], 'file_name' => $file['name'], 'file_path' => $file_path, 'add_time' => gmtime(), ); ``` $file_id = $uf_mod->add($data) 然后就直接带入到了add函数中 ``` foreach ($files['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { /* 处理文件上传 */ $file = array( 'name' => $files['name'][$key], ``` 这里 $file['name'] 就是上传来的文件名。而且没做任何过滤就带入到了add函数中。 files 变量无视gpc。 来看看哪里调用了这函数 依旧在my_goods.app.php中 ``` function _save_post_data($data, $id = 0) { /* 保存商品 */ if ($id > 0) { // edit if (!$this->_goods_mod->edit($id, $data['goods'])) { $this->_error($this->_goods_mod->get_error()); return false; } $goods_id = $id; } else { ``` 省略点 ``` /* 保存商品图片 */ if (!$this->_upload_image($goods_id)) { return false; } ``` 再看看哪里调用了。 还是这文件 ``` function edit() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); if (!IS_POST) { $this->assign('goods', $this->_get_goods_info($id)); ``` 省略点 ``` else { /* 取得数据 */ $data = $this->_get_post_data($id); /* 检查数据 */ if (!$this->_check_post_data($data, $id)) { $this->show_warning($this->get_error()); return; } /* 保存商品 */ if (!$this->_save_post_data($data, $id))//欧克这里终于调用了 { $this->show_warning($this->get_error()); return; } $this->show_message('edit_ok', ``` 找到了调用这函数的地方 就来注入把。 ### 漏洞证明: ``` POST /web/ecmall/index.php?app=my_goods&act=edit&id=1 HTTP/1.1 Host: web.com ``` [<img src="https://images.seebug.org/upload/201407/2023460441b27e909a6176b33bca43df27df7da7.jpg" alt="e1.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/2023460441b27e909a6176b33bca43df27df7da7.jpg) 成功了。