无组件上传漏洞的修补方法

sub upload_0()set upload=new UpFile_Class ”建立上传对象
upload.GetDate (int(Forum_Setting(56))*1024) ‘取得上传数据,不限大小
iCount=0

if upload.err > 0 then
select case upload.err
case 1
Response.Write “请先选择你要上传的文件 [ 重新上传 ]”
case 2
Response.Write “图片大小超过了限制 “&Forum_Setting(56)&”K [ 重新上传 ]”
end select
exit sub
else
formPath=upload.form(“filepath”)
”在目录后加(/)
if right(formPath,1)<>”/” then formPath=formPath&”/”

for each formName in upload.file ”列出所有上传了的文件
set file=upload.file(formName) ”生成一个文件对象
if file.filesize<100 then
response.write “请先选择你要上传的图片 [ 重新上传 ]”
response.end
end if

fileExt=lcase(file.FileExt)
if CheckFileExt(fileEXT)=false then
response.write “文件格式不正确 [ 重新上传 ]”
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
‘测试文件字符是否非法

Dim R_Char,R_i
for R_i=1 to Len(filename)
R_Char=ASC(MID(filename,R_i,1))
if R_Char=0 then
response.write “做点有意义的事情好不好,黑客是研究技术的,不是破坏的”
response.end
end if
Next

if file.FileSize>0 then ”如果 FileSize > 0 说明有文件数据
file.SaveToFile Server.mappath(filename) ”保存文件
‘ response.write file.FilePath&file.FileName&” (“&file.FileSize&”) => “&formPath&File.FileName&” 成功!

response.write “
iCount=iCount+1
end if
set file=nothing
next
set upload=nothing
session(“upface”)=”done”
Htmend iCount&” 个文件上传结束!”

end ifend sub


评论: 0 | 引用: 0 | 查看次数: 5535
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 300 字 | UBB代码 开启 | [img]标签 关闭