Recently my server got hacked and files were uploaded. Right now I'm trying to locate the weak spots, which brought me to php injection. I use the following code to include files:
if (isset($_GET['page'])) {
$page = $_GET['page'];
include("./php/$page.php");
}
I've tried something like:
http://badsite.com/badcode.php
example.php");include(...BADCODE HERE...);//
"allow_url_fopen=0" is disabled in the server configuration. I think a white list and/or php functions (htmlentities, strip...) to filter special charecters and code by default would make it bulletproof. But still I'm wondering if it is possible to inject bad code anyway as the value of $page is treated as a string?
Is there anything a "user" could enter, that will not end up in php warning "...failed to open stream: No such file or directory..."?
eval(). It just interprets the value and puts it into a variable. Your only real risk lies with traversal attacks that might try putting../into the path to try and include a file that shouldn't be included.inculdecan you fix that typo please? unless it isn't one?