復(fù)制代碼 代碼如下:
%
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 '判斷文件內(nèi)容中是否包含有危險的操作字符,如有,則必須刪除該文件。
AttackFlag=true
exit for
end if
next
CheckFileContent=AttackFlag
end function
If CheckFileContent("0.jpg")=true then
Response.Write "危險"
else
Response.Write "安全"
end if
%>
您可能感興趣的文章:- ASP如何檢測某文件夾是否存在,不存在則自動創(chuàng)建
- ASP檢查文件與目錄是否存在的函數(shù)代碼
- asp判斷某個文件是否存在的函數(shù)