Originally posted by nemik
i think i have an idea...what if you found someone's config.php. you could make your own test.php somewhere on yourdomain.com/test.php and do an include("http://www.victim.com/config.php")
and inside your test.php you write echo $pass; echo $password; etc to see if you can find any of them.
that is if the config.php is located in the root directory, no? or does include() and require() only accept files from your root directory and not other domains?
either way, by putting the config.php somewhere in usr/private or something like that inaccessible to the outside world, it should be much more secure.
just my 2 cents...
No, you can't do that. If you're getting the file from another site (through http as you would have to in this scenario) it is the webserver that is serving up the file, it is the webserver which commands PHP to be executed on certain pages and therefore all you would be given is what the webserver serves up to you, not the file itself. In short, calling include('http....') would give you the same result as opening the same url in yor browser. There is a lot to be said for keeping important files out of your webroot though. As has been already been mentioned, there is no reason for it to be in the webroot so why have it there. Also, you are relying on your webservers recognition that that file is a php file to secure it which is unnecesarry when you can just leave it outside of the scope of files to be served.
I would say only keep files which are being served directly in your webroot as then you are only relying on your server to know which directories it's allowed to server, something far easier for it to di than to figure out which specific files should be served.
Let's look at a scenario. Let's say that for some reason the PHP install goes down (prehpase someone messes up an upgrade and it all goes doolaly) for that period the webserver would continue to attempt to server the files through PHP but there's no working PHP there. It may (depending on the webserver) decide to just serve them up as-is instead. if you had your config files in your webroot that would mean that, for the time that PHP is down they are being served up as plain text and therefore viewable to the public. Needless to say, that would be a bad thing.