Is it possible to count files under a directory when you're only reading to https url? or only possible through ftp?
Asked
Active
Viewed 423 times
0
-
depends on the site, if directory listing is enabled, yes, but its probably not the best method. – Mar 01 '12 at 02:34
-
1... and even if directory listing is "enabled" - it still could show something different rather than directory listing. So I'd say it is impossible due to inability to trust the results – zerkms Mar 01 '12 at 02:37
2 Answers
2
Only through ftp
http
& https
are protocols to view web applications. Features like directory listing
are done from server, not through such protocols.
Explanation in case of php & apache server
When you are using commands like scandir()
to read file and directory, its the server that does the reading for you. not any http
or https
link. The page you browse through such protocols will only deliver the output markup on the page.
Through these protocols, all files except server-side files can be delivered on their actual format.
-
@Ryan: I didn't do that but probably because http and https can serve files perfectly – zerkms Mar 01 '12 at 02:42
-
-
I guess maybe if you consider that if directory listing is enabled you could sit there and count the files. Other than that no clue. – jprofitt Mar 01 '12 at 02:43
-
@jprofitt: how can you be sure that directory listing is a real directory listing? ;-) – zerkms Mar 01 '12 at 02:44
-
Even FTP can fake the file count (although it usually doesn't). – Ignacio Vazquez-Abrams Mar 01 '12 at 02:47
-
@zerkms, How can you deliver files like `.php` through `http` or `https`? It will be parsed first. Right? Am I missing something? – Starx Mar 01 '12 at 02:47
-
@jprofitt: Yep, a bit. But put this http://pastebin.com/smbTsWHZ as an index.html and magically every directory will be empty... :-S – zerkms Mar 01 '12 at 02:48
-
@Starx: you're missing a lot of other file types that are delivered as-is. It is just a rare exception that `.php` is pre-processed before sent back (and only in case if web server is configured for doing so) – zerkms Mar 01 '12 at 02:48
-
@zerkms,I know every server script is pre-processed and everything else is delivered as is. But the directory listings is something a server does, not the `http` or `https`. – Starx Mar 01 '12 at 02:52
-
@Starx: Well, http and https don't do anything themselves. All the work is done by web server. And the phrase `http & https are used to browse web application not files.` is a bit incorrect, by definition – zerkms Mar 01 '12 at 02:58
-
@zerkms, I see where I step out-of-bounds. Hope you like the updated answer. – Starx Mar 01 '12 at 03:00
1
Typically directory listings are disabled on websites.
wget can be used crawl a site. Using wget to recursively fetch a directory with arbitrary files in it
If directory listings aren't disabled on a site then you could download the page and parse the html to get the file count.

Community
- 1
- 1

Thomas Schultz
- 2,446
- 3
- 25
- 36
-
"Typically directory listings are disabled on websites." --- and even if it is "enabled" - you never can be sure that it is the real listing, not just a fake response – zerkms Mar 01 '12 at 02:42