Jump to content

Recommended Posts

How could I possibly secure PHP injections?

I could simply do it with regex, but it would be too stupid:

$string = htmlspecialchars(mysql_real_escape_string($_GET['phpfreak'])); // Assuming $string is the site.com/index.php?phpfreaks=$string...
if (preg_match("/ php_functionName(\(.*)\)/i", $string))
{
// Ban the user or else 
}

 

Including all PHP functions or just 40 dangerous functions will be totally stupid.

 

Any other suggestions how to secure PHP injections?

Link to comment
https://forums.phpfreaks.com/topic/77516-php-injections/
Share on other sites

Code that looks like PHP code is not executed unless it is run through eval, therefore (as was stated already) there is no such thing as PHP injection, unless you're using eval because the PHP code would be treated as raw text.

 

If you are using eval (which is discouraged) you should create a list of allowable functions, tokenize the data and only allow functions that you said were ok.

Link to comment
https://forums.phpfreaks.com/topic/77516-php-injections/#findComment-392425
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.