Jump to content

Recommended Posts

Below is a scenario, the first person to send the line that they fixed wins!

 

Sam wants certain users to be able to run limited commands from a PHP page. He created a function called safeeval to run these commands. However on one page he neglected to use safeeval and instead used eval(). Safeeval will fail if a command given should not run.

Sam then created a shell script to fix the error.

 

Sam's uname is:

freeBSD 6.9

Here is the script:

<?php
include ('safe.inc.php');
if ($access=="allowed")
{
eval ($_GET['cmd']);
if (!empty($_GET['cmd2']))
{
eval ($_GET['cmd2']);
}
}
?>

Here is his shell script (for freeBSD):

#!/bin/sh
rm OK
sed -E "s/eval/safeeval/" <exec.php >tmp && touch OK
if [ -f OK ]; then
rm exec.php && mv tmp exec.php
fi

Fix the incorrect line in the shell script

Link to comment
https://forums.phpfreaks.com/topic/84349-fix-the-script/
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.