ASP网站黑客防范编程技巧(4) if lcase(fileEXT)=lcase(trim(Forumupload(i))) then CheckFileExt=true exit Function else CheckFileExt=false end if next End Function ‘验证文件内容的合法性 set MyFile = server.CreateObject ("Scripting.FileSystemObject") set MyText = MyFile.OpenTextFile (sFile, 1) ' 读取文本文件 sTextAll = lcase(MyText.ReadAll): MyText.close '判断用户文件中的危险操作 sStr ="8 .getfolder .createfolder .deletefolder .createdirectory .deletedirectory" sStr = sStr & " .saveas wscript.shell script.encode" sNoString = split(sStr," ") for i = 1 to sNoString(0) if instr(sTextAll, sNoString(i)) <> 0 then sFile = Upl.Path & sFileSave: fs.DeleteFile sFile Response.write "<center><br><big>"& sFileSave &"文件中含有与操作目录等有关的命令"&_ "<br><font color=red>"& mid(sNoString(i),2) &"</font>,为了安全原因,<b>不能上传。<b>"&_"</big></center></html>" Response.end end if next
程序体(10)
把他们加到你的上传程序里做一次验证,那么你的上传程序安全性将会大大提高.
什么?你还不放心?拿出杀手锏,请你的虚拟主机服务商来帮忙吧。登陆到服务器,将PROG ID 中的"shell.application"项和"shell.application.1"项改名或删除。再将”WSCRIPT.SHELL”项和”WSCRIPT.SHELL.1”这两项都要改名或删除。呵呵,我可以大胆的说,国内可能近半以上的虚拟主机都没改过。只能庆幸你们的用户很合作,否则……我删,我删,我删删删……