Fix command bash injection using filename + add constant to disable commands

This commit is contained in:
osaajani 2020-06-17 19:08:11 +02:00
parent 3839742f58
commit 39caa92a62
3 changed files with 25 additions and 4 deletions

View file

@ -78,6 +78,11 @@ namespace controllers\internals;
*/
public function analyze_and_process (int $id_user, string $message)
{
if (!ENABLE_COMMAND)
{
return false;
}
$extracted_command = [];
$decode_message = json_decode(trim($message), true);
@ -127,7 +132,13 @@ namespace controllers\internals;
$decode_message['password'] = '******';
$updated_text = json_encode($decode_message);
$generated_command = PWD_SCRIPTS . '/' . $find_command['script'];
$script = $find_command['script'];
while (str_replace('..', '', $script) !== $script)
{
$script = str_replace('..', '', $script);
}
$generated_command = PWD_SCRIPTS . '/' . escapeshellarg($script);
$args = $decode_message['args'] ?? '';
$generated_command .= ' ' . escapeshellcmd($args);