Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry,


I recently came across an attempted hack via the index.php module (pages 57...).


I checked the logs and they added additional stuff to the $_GET['p'] data.


In case it is of interest, I think the code I have added should avoid that in the future:


if (isset($_GET['p']))
     	$p = $_GET['p'];
	// if there's any characters in there that shouldn't be, exit
	if (!preg_match("/^[a-z\_]/", $p))
			exit ("Invalid attempt to access this module");
    $p = NULL;
Can you suggest a better way?


Thanks, and Cheers

Link to comment
Share on other sites

That sounds good, however, I'm not sure it's necessary. The code as written, I believe, checks against static values and serves a default value if there's no match. So it doesn't matter what a user provides that doesn't match. 


But if you want to use the regex, that's fine, too, just make sure you keep it up to date as you add or change modules. (Or make sure your modules always fit within that definition.)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...