Fix command bash injection using filename + add constant to disable commands
This commit is contained in:
parent
3839742f58
commit
39caa92a62
|
@ -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);
|
||||
|
||||
|
|
|
@ -27,6 +27,14 @@ namespace controllers\publics;
|
|||
$this->internal_event = new \controllers\internals\Event($bdd);
|
||||
|
||||
\controllers\internals\Tool::verifyconnect();
|
||||
|
||||
if (!ENABLE_COMMAND)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Les commandes sont désactivées.');
|
||||
$this->redirect(\descartes\Router::url('Dashboard', 'show'));
|
||||
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -80,9 +80,11 @@
|
|||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li <?php echo $page == 'commands' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('Command', 'list'); ?>"><i class="fa fa-fw fa-terminal"></i> Commandes</a>
|
||||
</li>
|
||||
<?php if (ENABLE_COMMAND) { ?>
|
||||
<li <?php echo $page == 'commands' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('Command', 'list'); ?>"><i class="fa fa-fw fa-terminal"></i> Commandes</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if ($_SESSION['user']['settings']['webhook'] ?? false) { ?>
|
||||
<li <?php echo $page == 'webhooks' ? 'class="active"' : ''; ?>>
|
||||
<a href="<?php echo \descartes\Router::url('Webhook', 'list'); ?>"><i class="fa fa-fw fa-plug"></i> Webhooks</a>
|
||||
|
|
Loading…
Reference in New Issue