Forum Moderators: phranque
How did they find out the structure to these files? They are includes and are unpublished. How can I stop them from inserting this file?
[edited by: trillianjedi at 5:24 pm (utc) on July 29, 2007]
[edit reason] Please see TOS re specifics, thanks... [/edit]
Try adding this to the absolute beginning of all pages that shouldn't be viewed directly:
if (!isset( $RaNdOmVaRnAmE ) )
{
/* Insert some code here to log the attempted connection's IP for tracing, if desired */
die();
}
Then, add a line to all of the pages that need to include these pages...
$RaNdOmVaRnAmE = "";
This way, anyone who attempts to visit the page in question directly instead of through a normal channel is met with a blank page that won't do anything.
The most likely suspect if you're on a shared server is one of the other occupants of the server--since PHP can scan through directories, another site on the same server might be able to (either purposefully or from having themselves been hacked) scan through your website folder's contents.
Also, if you use any of the most commonly-known CMSs, you might as well assume that everyone under the sun knows the location of every page in your site--since PHP CMSs are easily downloadable and generally easy to reverse-engineer, their folder structure is extremely easy to discover.
2. Included source files don't need to be accessed by your users - only by the PHP (or other language) interpreter running on your server. Make sure that they are NOT accessible to users! One easy way to do this (if you are writing your own code) is to put them in a subdirectory, and don't map a URL to that subdirectory. Otherwise, you might have to do some fiddling with .htaccess. Users should get a "404" error when trying to access included files.
ANY included file, BTW, not just executables. Why should users be able to see bits and pieces of headers, menus, etc. that are put-together by the server? They shouldn't.
3. Whether on a dedicated, shared, or VPS server, give only user permissions to source files - make sure there are no group or world permissions. This may not be practical, though, if your web server runs as a different user.