### 简要描述:
tipask注入漏洞
### 详细说明:
漏洞细节:
tipask url格式类似如此 index.php?classname/methodname
然后再初始化的index.php 会实例化名为classname 的类, run 后面的方法在method 名前面加上字符串on
这个是个$_FILES 注入吧。漏洞比较奇葩。
tipask 有全局的过率机制,虽然过率了post get 等数据可是忽略了$_FIELS ,但是这个地方
```
function onuploadimage() {
//上传配置
$config = array(
"uploadPath" => "data/attach/", //保存路径
"fileType" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp"),
"fileSize" => 2048
);
//原始文件名,表单名固定,不可配置
$oriName = htmlspecialchars($this->post['fileName'], ENT_QUOTES);
//上传图片框中的描述表单名称,
$title = htmlspecialchars($this->post['pictitle'], ENT_QUOTES);
//文件句柄
$file = $_FILES["upfile"];//全局绕过
//文件上传状态,当成功时返回SUCCESS,其余值将直接返回对应字符窜并显示在图片预览框,同时可以在前端页面通过回调函数获取对应字符窜
$state = "SUCCESS";
//格式验证
$current_type = strtolower(strrchr($file["name"], '.'));
if (!in_array($current_type, $config['fileType'])) {//白名单限制
$state = $current_type;
}
//大小验证
$file_size = 1024 * $config['fileSize'];
if ($file["size"] > $file_size) {
$state = "b";
}
//保存图片
if ($state == "SUCCESS") {
$targetfile = $config['uploadPath'] . gmdate('ym', $this->time) . '/' . random(8) . strrchr($file["name"], '.');//后缀限制
$result = $_ENV['attach']->movetmpfile($file, $targetfile);
if (!$result) {
$state = "c";
} else {
//文件名未过滤
$_ENV['attach']->add($file["name"], $current_type, $file["size"], $targetfile);
}
}
echo "{'url':'" . $targetfile . "','title':'" . $title . "','original':'" . $oriName . "','state':'" . $state . "'}";
}
```
可以看到$file 数组变量 直接从$_FILES 当中获取的,在进行入库操作的时候,并没有过率。
下面是入库操作代码:
```
function add($filename,$ftype,$fsize,$location,$isimage=1) {
$uid=$this->base->user['uid'];
$this->db->query("INSERT INTO ".DB_TABLEPRE."attach(time,filename,filetype,filesize,location,isimage,uid) VALUES ({$this->base->time},'$filename','$ftype','$fsize','$location',$isimage,$uid)");
return $this->db->insert_id();
}
```
### 漏洞证明:
然后以下是利用过程,
[<img src="https://images.seebug.org/upload/201508/012314494f24232d4d1b5f0bd33d097c1535ab20.png" alt="选区_117.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201508/012314494f24232d4d1b5f0bd33d097c1535ab20.png)
[<img src="https://images.seebug.org/upload/201508/012315549519161063f40402b78d696b309127c9.png" alt="选区_118.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201508/012315549519161063f40402b78d696b309127c9.png)
暂无评论