### 简要描述: EasyTalk任意文件删除漏洞 ### 详细说明: EasyTalk存在两处任意文件删除漏洞。 一处是在SettingAction.class.php文件的doface函数处,已经有人提交过了。 这里是在GuideAction.class.php文件的doface2函数处。 ``` //头像裁剪处理 public function doface2() { $ysw=$_POST['ysw']; if ($ysw>660) { $zoom=intval($ysw)/660; } else { $zoom=1; } $x=$_POST['x']*$zoom; $y=$_POST['y']*$zoom; $w=$_POST['w']*$zoom; $h=$_POST['h']*$zoom; $imgpath=ET_ROOT.$_POST['imgpath']; $ext=strtolower(getExtensionName($imgpath)); import("@.ORG.IoHandler"); $IoHandler = new IoHandler(); if(!isImage($imgpath)) { $IoHandler->DeleteFile($imgpath); setcookie('setok', json_encode(array('lang'=>L('face2'),'ico'=>2)),0,'/'); header('location:'.SITE_URL.'/?m=guide'); exit; } $image_path = ET_ROOT.'/Public/attachments/head/'.date('Ymd').'/'; if(!is_dir($image_path)) { mkdir($image_path); } $f=date('His'); //大图片 import("@.ORG.makethumb"); $makethumb=new makethumb(); $filename=$f.'_big.'.$ext; $dst_file = $image_path.$filename; $make_result =...
### 简要描述: EasyTalk任意文件删除漏洞 ### 详细说明: EasyTalk存在两处任意文件删除漏洞。 一处是在SettingAction.class.php文件的doface函数处,已经有人提交过了。 这里是在GuideAction.class.php文件的doface2函数处。 ``` //头像裁剪处理 public function doface2() { $ysw=$_POST['ysw']; if ($ysw>660) { $zoom=intval($ysw)/660; } else { $zoom=1; } $x=$_POST['x']*$zoom; $y=$_POST['y']*$zoom; $w=$_POST['w']*$zoom; $h=$_POST['h']*$zoom; $imgpath=ET_ROOT.$_POST['imgpath']; $ext=strtolower(getExtensionName($imgpath)); import("@.ORG.IoHandler"); $IoHandler = new IoHandler(); if(!isImage($imgpath)) { $IoHandler->DeleteFile($imgpath); setcookie('setok', json_encode(array('lang'=>L('face2'),'ico'=>2)),0,'/'); header('location:'.SITE_URL.'/?m=guide'); exit; } $image_path = ET_ROOT.'/Public/attachments/head/'.date('Ymd').'/'; if(!is_dir($image_path)) { mkdir($image_path); } $f=date('His'); //大图片 import("@.ORG.makethumb"); $makethumb=new makethumb(); $filename=$f.'_big.'.$ext; $dst_file = $image_path.$filename; $make_result = $makethumb->dothumb($imgpath,$dst_file,max(10,min(120,$w)),max(10,min(120,$h)),0,0,$x,$y,$w,$h); //小图片 $filename=$f.'_small.'.$ext; $dst_file = $image_path.$filename; $make_result = $makethumb->dothumb($imgpath,$dst_file,max(10,min(50,$w)),max(10,min(50,$h)),0,0,$x,$y,$w,$h); $IoHandler->DeleteFile($imgpath); M('Users')->where("user_id='".$this->my['user_id']."'")->setField('user_head',date('Ymd').'/'.$filename.'?v='.time()); setcookie('setok', json_encode(array('lang'=>L('face1'),'ico'=>1)),0,'/'); header('location:'.SITE_URL.'/?m=guide'); } ``` 可以看到$imgpath=ET_ROOT.$_POST['imgpath']; 看看函数isImage做了什么: ``` function isImage($filename){ $types = '.gif|.jpg|.jpeg|.png';//定义检查的图片类型 if(file_exists($filename)){ $info = getimagesize($filename); $ext = image_type_to_extension($info['2']); return stripos($types,$ext)>=0?1:0; }else{ return false; } } ``` 如果文件的后缀不是.gif|.jpg|.jpeg|.png这几种类型就返回false。 当返回false的时候,就会删除这里的文件: $IoHandler->DeleteFile($imgpath); 所以只要我们提交的文件不是上面几种就可导致任意文件删除。 ### 漏洞证明: 第一步,先注册一个用户 第二步,会出现向导,此时上传一个头像 [<img src="https://images.seebug.org/upload/201404/17172744e2420efffc1530fe210bae491582d130.png" alt="easy2.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201404/17172744e2420efffc1530fe210bae491582d130.png) 第三步,提交剪裁时,抓包,修改imgpath=%2FPublic%2Finstall.lock 此时已经删除了install.lock文件。 会跳转到安装页面。 [<img src="https://images.seebug.org/upload/201404/1717281894fb15cb7dad943d2cb0ebe92cc82f8c.png" alt="easy3.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201404/1717281894fb15cb7dad943d2cb0ebe92cc82f8c.png) 然后可以重装,后台getshell