From 88ffd1366f05fa2523be3b6e05401f0289d8126c Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 23 Jul 2018 12:15:01 +0900 Subject: [PATCH] Update exectool.php --- helper/exectool.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/helper/exectool.php b/helper/exectool.php index e9e4274..4b2a3e7 100644 --- a/helper/exectool.php +++ b/helper/exectool.php @@ -2,7 +2,8 @@ /** * @file exectool.php * @date 2018-07-22 - * @author forked from https://github.com/scipag/PHPUtilities + * @auther Go Namhyeon + * @forked from https://github.com/scipag/PHPUtilities * @brief ExecTool helper */ @@ -103,9 +104,10 @@ if(!function_exists("exec_test")) { * exec_command() executes a command (like "whoami") with the submited method */ if(!function_exists("exec_command")) { - function exec_command($command, $method) { + function exec_command($command, $method) { + $return = false; + if ($method == "") { - // ob_start() will turn on output buffering to collect all output from // exec_test() and ob_end_clean() will clean the buffer afterwards ("garbage collection") ob_start(); @@ -114,13 +116,14 @@ if(!function_exists("exec_command")) { if (is_array($methodArray)) { $method = $methodArray[0]; - } - else { + } else { echo "[!] No method available"; exit; } } + ob_start(); + switch ($method) { case "system": system("$command 2>&1"); @@ -169,5 +172,9 @@ if(!function_exists("exec_command")) { echo "[!] No method defined"; break; } + + $return = ob_get_clean(); + + return $return; } }