Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Protecting PHP file access
Name: RTAdams89 Date: May 23, 2008 at 23:20:29 Pacific OS: na CPU/Ram: na Product: na
Comment:
I am building a PHP application. As part of that, I stored all of the frequently used variables (such as the MySQL database login information) in a file called "config.php" and then simply put "include 'config.php';" at the beginning of each page that needs the database info.
Is it possible for an attacker to put a PHP file on their server which contains "include 'http://myserver.com/config.php';" and then echo out all the variables contained in config.php?
If so, these is a major security hole. How do I protect against such an attack?
Name: Michael J (by mjdamato) Date: May 24, 2008 at 12:32:18 Pacific
Reply:
No, you cannot "include" a file on a separate domain like that. If you tried to include a php file on another domain that file is being requested through that web server and the onlly thing you would be including is the output of that file.
For example, if the included PHP file had an echo statement then the externally requesting page would only see the output of that echo.
Example include file:
<?php echo "exit;"; ?>
If a local page included that file it would "print" the test "exit;" to the page. If an external page tried to include it it would just see "exit;" as the content and would exit the script.
Summary: Hello, I'm new to PHP and trying to figure out how to protect PHP include files. I've searched google and got one solution which needs to edit php config to make those files with certain extensions in...
Summary: Hello Forums: I'm looking for a tool / utility that allows the downloading of a PHP file directly from a website, does such one exist? I recently lost FTP access to my website and I need to retrieve s...
Summary: Hi, I am seeking to get a solution for the foll. The only thing is I need an email to come to me as well as the data going into a db table. I need to know : 1) What IP's accessed the site, when the c...