Jump to content

Getting page with out exploiting my server


ev5unleash

Recommended Posts

I was talking to my friend (noob php coder) and I asked him if he knew the code so people could go to (ex. /index.php?request=games) instead of doing /games/index.php. He have me this code

<?php 
$request = $_GET["request"];
include("homepage/".$request);
?>

I checked my site with some people and found the problem with the script. Anyway, does anyone have any alternative? That won't exploit my server

it technically works, but this part:

include("homepage/".$request);

needs cleaning, for instance some malicious cracker could put in a funny url, it'd be better to use a taken and look it up, e.g. index.html?request=xyz, then check for xyz and if you have a reference then substitute for a filename:

$request = $_GET["request"];
if(strcmp($request,"userbob")==0)
{
   include("homepage/bob.php");
}

 

or check the file exists, etc...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.