ESCMS 一个鸡肋的上传漏洞

作者:hack1990 时间:10-12-14 阅读数:579人阅读

之所以说是鸡肋是因为。。。哎 我们还是看代码先:

在admin/downup.asp里面:

<!--#include file="check.asp" -->
<!--#include file="Up3.inc"-->
<html>
<head>
<title>上传</title>
<link href="text.css" rel="stylesheet" type="text/css">
</head>
<body >
<table width=400 border=0 align="center" cellpadding="6" cellspacing="1" bgcolor="#A2A2A2">
<tr><td width=100% height=100% align="center" bgcolor="#F2F2F2" class=tablebody1 >
<%
dim upload,file,formName,formPath,filename,fileExt
dim ranNum
call UpFile()
===========无组件上传(upload_0)====================
sub UpFile()
set upload=new UpFile_Class 建立上传对象
upload.GetData (1500*1024) 取得上传数据,此处即为1500 K

if upload.err > 0 then
select case upload.err
case 1
Response.Write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>请重新上传</a> ]"
case 2
Response.Write "大小超过了限制 1500 K [ <a href=# onclick=history.go(-1)>请重新上传</a> ]"
end select
exit sub
else
formPath=upload.form("filepath") 文件保存目录,此目录必须为程序可读写
if formPath="" then
formPath="Upfile"
end if
在目录后加(/)
if right(formPath,1)<>"/" then
formPath=formPath&"/"
end if
for each formName in upload.file 列出所有上传了的文件
set file=upload.file(formName) 生成一个文件对象
if file.filesize<100 then
response.write "请先选择你要上传的图片! [ <a href=# onclick=history.go(-1)>请重新上传</a> ]"
response.end
end if

fileExt=lcase(file.FileExt)
if CheckFileExt(fileEXT)=false then
response.write "文件格式不正确! [ <a href=# onclick=history.go(-1)>请重新上传</a> ]"
response.end
end if

randomize
ranNum=int(90000*rnd)+10000
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
if file.FileSize>0 then 如果 FileSize > 0 说明有文件数据
result=file.SaveToFile(Server.mappath(filename)) 保存文件
if result="ok" then
response.write "文件:<font color=#ff0000>"&File.FilePath&file.FileName&"</font>上传成功!<br>"
response.write"保存路径:<input type=""text"" style=""border-style: solid; border-width: 1"" value="""&filename&"""><br>[<a href=# onclick=""Addpic("&filename&")"">点击这里把图片路径添加到文本框中</a>]"
Response.Write "Addpic("&filename&")"
%>
<script language="JavaScript">
<!--
var flag=false;
function Addpic(imagePath){
window.opener.AddPro.Down_Url.focus();        
window.opener.document.AddPro.Down_Url.value=imagePath;
    window.opener=null;
    window.close();
}
window.alert("上传成功")
Addpic(<%=filename%>)
//-->
</script>
<%

else
response.write File.FilePath&file.FileName&" 上传失败,"&result&"<br>"
end if
end if
set file=nothing
next
set upload=nothing
end if
end sub

判断文件类型是否合格
Private Function CheckFileExt (fileEXT)
dim Forumupload
Forumupload="gif,jpg,bmp,jpeg,rar,zip,txt"
Forumupload=split(Forumupload,",")
for i=0 to ubound(Forumupload)
if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
CheckFileExt=true
exit Function
else
CheckFileExt=false
end if
next
End Function
%>
</td>
</tr></table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
    <td height="120" align="center"><img src=<%=filename%> border=0 width=100 height=100 onload=javascript:DrawImage(this);></td>
</table>
</body>
</html>

 

核心代码:formPath=upload.form("filepath")        路径没有经过任何过滤 直接传递 用户上传的图片会上传到那个目录   如果web的目录权限够大 足以创建目录的话(绝大部分都可以 除非是极度变态的管理员)

那么我们可以构造一个这样的目录 *.asp 然后 图片就自然上传到那里了 嘿嘿 老到掉牙的2003解析漏洞 再一次华丽的用上。。

 

啥? 方法只有一个? 不不。 即使过滤了 我们还是可以上传的。

试试开动你的nc 熟悉的nc提交 然后残忍地截断. 再然后就拿到shell了.熟悉把。。 截断符号再现~!

这样的话 无论路径在那里 我们还是可以上传asp文件的。。

 

别太兴奋先。。 要记得 这个文件是在admin目录里面的 也就是说。。 要。权。限 才能拿shell

 

我们再看看check.asp:

<%
if session("ES_admin")="" then
Call Err_Show()
Response.End()
End if
错误页面 by foosun
Sub Err_Show()
dim Err_ShowChar
Err_ShowChar = "<html xmlns=""http://www.w3.org/1999/xhtml"">"&chr(10)
Err_ShowChar = Err_ShowChar & "<head>"&chr(10)
Err_ShowChar = Err_ShowChar & "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"" />"&chr(10)
Err_ShowChar = Err_ShowChar & "<title>无标题文档</title>"&chr(10)
Err_ShowChar = Err_ShowChar & "</head>"&chr(10)
Err_ShowChar = Err_ShowChar & "<link href=""Images/admin.css"" rel=""stylesheet"" type=""text/css"">"&chr(10)
Err_ShowChar = Err_ShowChar & "<body topmargin=""80""><p>"&chr(10)
Err_ShowChar = Err_ShowChar & "<table width=""80%"" align=""center"" cellpadding=""10""><tr><td>"&chr(10)
Err_ShowChar = Err_ShowChar & "<li>您没有此页操作权限没有权限!!</li>"&chr(10)
Err_ShowChar = Err_ShowChar & "<li>请与系统管理员联系,<a target=""_top"" href=""admin_login.asp"">点击返回登陆</a></li>"&chr(10)
Err_ShowChar = Err_ShowChar & "<li>Powered by eFsys.Cn</li>"&chr(10)
Err_ShowChar = Err_ShowChar & "</td><tr></table>"&chr(10)
Err_ShowChar = Err_ShowChar & "</body>"&chr(10)
Err_ShowChar = Err_ShowChar & "</html>"&chr(10)
Response.Write Err_ShowChar
Response.end
End Sub
%>

 

还是比较鸡肋熟悉的session没过滤好。。 嗯 我们有两种方案

不过利用范围不大   所以就不说了~ (很有忽悠的嫌疑.)

好啦 文章结束

上一篇:ShopWind 0Day漏洞

下一篇:DEDECMS XDAY

发表评论