0

Today , i've seen some wiered syntax of PHP .

$x="{${phpinfo()}}";

Try to execute the above code and Bammm you will see the phpinfo() is getting executed , My eye brows got raised. however i've declared $x variable as string.

Look this vulnerability PHP code found in the Ebay. I am wondering how this got executed.

http://www.secalert.net/2013/12/13/ebay-remote-code-execution/

user3134488
  • 3
  • 1
  • 3

2 Answers2

4

It's not weird. It's how that's intended to be. phpinfo() will output data in any case. If you want to capture it's output, then use ob_ (output buffering) functions:

ob_start();
phpinfo();
$data = ob_get_contents();
ob_end_clean();
//var_dump($data);

Your problem isn't related to syntax.

Alma Do
  • 37,009
  • 9
  • 76
  • 105
0

PHPinfo is a function that returns information in HTML form about the PHP environment on your server (see http://us2.php.net/phpinfo for more information). To run PHPinfo, you must save the following code in a file on your computer using the text editor:

phpinfo ();

sergio
  • 5,210
  • 7
  • 24
  • 46