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 
%>

标签:上传文件,危险代码
0
投稿

猜你喜欢

  • 用ASP实现Google在线文章翻译的功能

    2008-10-11 13:55:00
  • 详细讲解MySQL数据库对文件操作的封装

    2008-12-17 16:08:00
  • JavaScript文档生成工具

    2007-10-26 11:59:00
  • [译]艺术和设计的差异 (1)

    2009-09-25 12:38:00
  • 表单特殊输入js验证

    2008-03-26 12:01:00
  • js关于 byval 与 byref 的区别

    2007-10-13 10:48:00
  • IE9报“DOM Exception: INVALID_CHARACTER_ERR (5)”错误的原因及解决办法

    2011-09-01 19:11:07
  • asp如何将产生的密码记录并发送给用户?

    2009-11-26 20:50:00
  • 漂亮的title提示信息

    2008-08-12 12:51:00
  • IE下,事件触发那点破烂事儿

    2009-04-27 12:31:00
  • sql exist的妙用

    2007-11-08 11:47:00
  • 整理各种js按比例缩放图片方法

    2007-09-27 20:01:00
  • HTML和SEO基础知识:H标签全透视

    2010-09-21 16:45:00
  • DreamweaverMX Ultradev探索:技巧荟萃

    2010-07-13 12:10:00
  • 细化解析:MySQL 搜索中的大小写敏感性

    2008-11-27 15:53:00
  • 表单设计中的网页视觉体验

    2008-06-26 13:35:00
  • 如何避免SQL语句中含有单引号而导致操作失败?

    2009-11-07 18:40:00
  • 豆瓣可以做而且值得做的几件事情

    2009-04-24 12:07:00
  • asp如何用HtmlEncode来显示Unicode编码?

    2010-06-12 12:49:00
  • MySQL时间字段究竟使用INT还是DateTime

    2010-03-09 14:46:00
  • asp之家 网络编程 m.aspxhome.com