MrFreeze
02-04-2005, 03:49 PM
I haven't found a good directory browse script that will browse through a folder and all of its subfolders, but NOT to any folders that are above it, all using a single page that makes calls back to itself. The idea is to have a single page that can be dropped into any folder and that will return folder listings for all folders under it but nothing above it. Actually, I don't know if it's possible to securely do this...but here's my attempt. Nearly all of the code that performs the actual operation comes from this MS KB article:
http://support.microsoft.com/kb/q224364/
You can see that code in action here:
http://www.ie.usf.edu/dev/dirbrowse/
I've modified the code to accept a query string that is passed back to the script if a folder is selected from the listing. Then, it will take that new folder's path and enumerate all of the subfolders and files under that directory.
For example, take a look at the "dirbrowse" page I posted above. If I wanted to view the folder "testfolder," the script would be called as http://www.ie.usf.edu/dev/dirbrowse/default.asp?folder=newfolder/
The script would then list all of the subfolders/files under /dev/dirbrowse/newfolder/.
The problem is this: if you pass a ../ to the script at the end of the querystring, it will move up a directory. For example, passing default.asp?folder=newfolder/../ will actually not change directories. If you pass default.asp?folder=newfolder/../../ then the new directory listing will be from /dev/. Passing default.asp?folder=newfolder/../../../ would get you a listing from the root of the entire website.
The real issue is that it will continue to move up folders until you get directory listings from the root of the drive. Then you see Inetpub, System Information, and the Recycle Bin (I've got InetPub on a separate disk from the OS, so you don't see any "critical" items, but this is a huge risk nonetheless).
Here's a link to the code...obviously I can't include a working model as this is a security issue, but you can try it out on your own server if you'd like:
http://www.ie.usf.edu/dev/dirbrowse/default.txt
Please help :confused: Any ideas on this? I don't want to enable directory browsing...that defeats the whole purpose and is rather insecure itself.
Thanks!
Travis
http://support.microsoft.com/kb/q224364/
You can see that code in action here:
http://www.ie.usf.edu/dev/dirbrowse/
I've modified the code to accept a query string that is passed back to the script if a folder is selected from the listing. Then, it will take that new folder's path and enumerate all of the subfolders and files under that directory.
For example, take a look at the "dirbrowse" page I posted above. If I wanted to view the folder "testfolder," the script would be called as http://www.ie.usf.edu/dev/dirbrowse/default.asp?folder=newfolder/
The script would then list all of the subfolders/files under /dev/dirbrowse/newfolder/.
The problem is this: if you pass a ../ to the script at the end of the querystring, it will move up a directory. For example, passing default.asp?folder=newfolder/../ will actually not change directories. If you pass default.asp?folder=newfolder/../../ then the new directory listing will be from /dev/. Passing default.asp?folder=newfolder/../../../ would get you a listing from the root of the entire website.
The real issue is that it will continue to move up folders until you get directory listings from the root of the drive. Then you see Inetpub, System Information, and the Recycle Bin (I've got InetPub on a separate disk from the OS, so you don't see any "critical" items, but this is a huge risk nonetheless).
Here's a link to the code...obviously I can't include a working model as this is a security issue, but you can try it out on your own server if you'd like:
http://www.ie.usf.edu/dev/dirbrowse/default.txt
Please help :confused: Any ideas on this? I don't want to enable directory browsing...that defeats the whole purpose and is rather insecure itself.
Thanks!
Travis