asp 判断上传文件中是否存在危险代码
来源:asp之家 时间:2011-03-17 11:19:00
代码如下:
<%
function CheckFileContent(FileName)
dim ClientFile,ClientText,ClientContent,DangerString,DSArray,AttackFlag,k
set ClientFile=Server.CreateObject("Scripting.FileSystemObject")
set ClientText=ClientFile.OpenTextFile(Server.MapPath(FileName),1)
ClientContent=LCase(ClientText.ReadAll)
set ClientText=nothing
set ClientFile=nothing
AttackFlag=false
DangerString=".getfolder|.createfolder|.deletefolder|.createdirectory|.deletedirectory|.saveas|wscript.shell|script.encode|server.|.createobject|execute|activexobject|language=|include|filesystemobject|shell.application"
DSArray=split(DangerString,"|")
for k=0 to UBound(DSArray)
if InStr(ClientContent,DSArray(k))>0 then '判断文件内容中是否包含有危险的操作字符,如有,则必须删除该文件。
AttackFlag=true
exit for
end if
next
CheckFileContent=AttackFlag
end function
If CheckFileContent("0.jpg")=true then
Response.Write "危险"
else
Response.Write "安全"
end if
%>
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
用ASP实现Google在线文章翻译的功能
详细讲解MySQL数据库对文件操作的封装
JavaScript文档生成工具
[译]艺术和设计的差异 (1)
表单特殊输入js验证
js关于 byval 与 byref 的区别
IE9报“DOM Exception: INVALID_CHARACTER_ERR (5)”错误的原因及解决办法
asp如何将产生的密码记录并发送给用户?
漂亮的title提示信息
IE下,事件触发那点破烂事儿
sql exist的妙用
整理各种js按比例缩放图片方法
HTML和SEO基础知识:H标签全透视
![](https://img.aspxhome.com/file/UploadPic/20109/21/1412060-45s.jpg)
DreamweaverMX Ultradev探索:技巧荟萃
细化解析:MySQL 搜索中的大小写敏感性
表单设计中的网页视觉体验
![](https://img.aspxhome.com/file/UploadPic/20086/26/2008626134221567s.jpg)