ASP防止图片木马上传的代码
2018-10-12 14:06
656 查看
ASP木马防御:
const adTypeBinary=1
dim jpg(1):jpg(0)=CByte(&HFF):jpg(1)=CByte(&HD8)
dim bmp(1):bmp(0)=CByte(&H42):bmp(1)=CByte(&H4D)
dim png(3):png(0)=CByte(&H89):png(1)=CByte(&H50):png(2)=CByte(&H4E):png(3)=CByte(&H47)
dim gif(5):gif(0)=CByte(&H47):gif(1)=CByte(&H49):gif(2)=CByte(&H46):gif(3)=CByte(&H39):gif(4)=CByte(&H38):gif(5)=CByte(&H61)
Response.Write CheckFileType(Server.MapPath("2.gif"))
function CheckFileType(filename)
on error resume next
CheckFileType=false
dim fstream,fileExt,stamp,i
fileExt=mid(filename,InStrRev(filename,".")+1)
set fstream=Server.createobject("ADODB.Stream")
fstream.Open
fstream.Type=adTypeBinary
fstream.LoadFromFile filename
fstream.position=0
select case fileExt
case "jpg","jpeg"
stamp=fstream.read(2)
for i=0 to 1
if ascB(MidB(stamp,i+1,1))=jpg(i) then CheckFileType=true else CheckFileType=false
next
case "gif"
stamp=fstream.read(6)
for i=0 to 5
if ascB(MidB(stamp,i+1,1))=gif(i) then CheckFileType=true else CheckFileType=false
next
case "png"
stamp=fstream.read(4)
for i=0 to 3
if ascB(MidB(stamp,i+1,1))=png(i) then CheckFileType=true else CheckFileType=false
next
case "bmp"
stamp=fstream.read(2)
for i=0 to 1
if ascB(MidB(stamp,i+1,1))=bmp(i) then CheckFileType=true else CheckFileType=false
next
end select
fstream.Close
set fseteam=nothing
if err.number<>0 then CheckFileType=false
end function
%>
您可能感兴趣的文章:
相关文章推荐
- ASP防止图片木马上传的代码
- ASP.NET(C#)上传图片时防止木马的有效策略
- asp防止上传图片木马原理解析
- ASP.NET(C#)上传图片时防止木马的有效策略
- eWebEditor V7.3 for asp.net版本编辑器带后台版本_新增加防止图片木马上传
- asp.net防止上传木马图片
- eWebEditor V7.3 for asp版本编辑器带后的破解码版本,新增加防止图片木马上传
- 再谈Fckeditor(ASP版)防止木马上传——修改上传类
- asp.net(c#)上传图片并生成缩略图的代码
- asp.net批量上传图片代码
- ASP.NET上传图片代码
- ASP.NET中常用功能代码总结(上传图片到数据库,从数据库中读取图片)
- asp.net多图片上传实现程序代码
- ASP.NET中常用功能代码总结(3)——上传图片到数据库
- ASP.NET(C#)实现一次性动态上传多张图片的代码(多个文件)
- 检查上传图片是否合法的函数,木马改后缀名、图片加恶意代码均逃不过
- ASP.NET中常用功能代码总结(3)——上传图片到数据库
- C#判断上传文件是否是图片,防止木马上传
- 在ASP.NET中上传图片并生成缩略图的C#代码
- C#判断上传文件是否是图片以防止木马上传的方法