Using PHP 5.6, I stumbled upon the command execution via backticks and I was wondering how that could prove to be a vulnerability in PHP powered websites.
I can understand that the following code:
<?php
$output = `ls -al`;
echo "<pre>$output</pre>";
?>
allows the $output variable contents to be executed in shell.
My question now is, are the backticks needed to be hardcoded around the variable value or can they be also part of the value?
For example, in the previous code block the backticks are hardcoded around the value but what if the $output variable was set via a GET/POST REQUEST like so:
http://example.com/index.php?arg=`exec code`
or
http://example.com/index.php?arg=%60exec%20code%60
and in php:
<?php
$output = $_REQUEST['arg']
echo "<pre>$output</pre>";
?>
Is that vulnerable code?
Thank you in advance