Skip to content

Instantly share code, notes, and snippets.

@carlospolop
Last active March 29, 2019 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlospolop/e3d664c2fef53ba6bf8b7750eff7f6c1 to your computer and use it in GitHub Desktop.
Save carlospolop/e3d664c2fef53ba6bf8b7750eff7f6c1 to your computer and use it in GitHub Desktop.
Check if any function to execute commands (REC) in PHP is available
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
echo "Hello! Trying to execute commands...";
echo "<br>";
if (function_exists('exec')){ exec("echo exec"); echo "<br>";}
if (function_exists('passthru')){ passthru("echo passthru"); echo "<br>";}
if (function_exists('shell_exec')){ shell_exec("echo shell_exec"); echo "<br>";}
if (function_exists('popen')){ $p = popen('/bin/echo popen 2>&1', 'r'); echo fread($p, 2096); pclose($p); echo "<br>";}
if (function_exists('proc_open')) echo "proc_open<br>";
if (function_exists('pcntl_exec')) echo "pcntl_exec<br>";
`echo backtips`; echo "<br>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment