#13035 refactored password_hash

This commit is contained in:
Daniel Cebrian 2024-04-11 16:11:28 +02:00
parent 22c1b6e872
commit cedead50ac
2 changed files with 7 additions and 71 deletions

View File

@ -328,23 +328,6 @@ if (check_login()) {
if (isset($array_nodes) && is_array($array_nodes)) {
$hash_array_nodes = [];
foreach ($array_nodes as $key => $server) {
$pwd = $server['auth_token'];
$auth_serialized = json_decode($pwd, true);
if (is_array($auth_serialized)) {
$pwd = $auth_serialized['auth_token'];
$api_password = $auth_serialized['api_password'];
$console_user = $auth_serialized['console_user'];
$console_password = $auth_serialized['console_password'];
}
$user = $config['id_user'];
$user_rot13 = str_rot13($config['id_user']);
$hashdata = $user.$pwd;
$hashdata = md5($hashdata);
$url_hash = '&loginhash=auto&loginhash_data='.$hashdata.'&loginhash_user='.$user_rot13;
$hash_array_nodes[$server['id']]['hashurl'] = $url_hash;
$hash_array_nodes[$server['id']]['server_url'] = $server['server_url'];
}
}
@ -355,7 +338,7 @@ if (check_login()) {
$image_status = agents_get_image_status($values['status']);
// Link nodes.
if (is_metaconsole() === true) {
$agent_link = '<a href="'.$hash_array_nodes[$values['id_tmetaconsole_setup']]['server_url'].'/index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$values['id_tagente'].$hash_array_nodes[$values['id_tmetaconsole_setup']]['hashurl'].'">';
$agent_link = '<a href="#" onclick="redirectNode(\''.$hash_array_nodes[$values['id_tmetaconsole_setup']]['server_url'].'/index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$values['id_tagente'].'\')">';
$agent_alias = ui_print_truncate_text(
$values['alias'],
'agent_small',

View File

@ -1721,26 +1721,8 @@ if (empty($result) === false) {
if (in_array('agent', $show_fields) || is_metaconsole()) {
$agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name'];
// TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view
if (is_metaconsole() === true) {
echo "<form id='agent-redirection-".$inc_id."' method='POST' target='_blank' action='".$row['server_url'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row['id_agent']."'>";
html_print_input_hidden(
'loginhash',
'auto',
false
);
html_print_input_hidden(
'loginhash_data',
$row['hashdata'],
false
);
html_print_input_hidden(
'loginhash_user',
str_rot13($row['user']),
false
);
echo '</form>';
$agent_link = "<a target='_blank' href='".$row['server_url'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']).'&id_agente='.$row['id_agent']."'>";
$agent_link = '<a target="_blank" href="#" onclick="redirectNode(\''.$row['server_url'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&loginhash=auto&id_agente='.$row['id_agent'].'\',\'_self\')">';
$agent_alias = ui_print_truncate_text(
$agent_alias,
@ -1773,18 +1755,20 @@ if (empty($result) === false) {
$show_edit_icon = false;
}
$url_edit_module = $row['server_url'].'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']);
$url_edit_module = $row['server_url'].'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1';
} else {
$url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1';
}
}
}
$url_edit_module = ($url_edit_module ?? '#');
if (in_array('module_name', $show_fields) === true || is_metaconsole() === true) {
$data[3] = html_print_anchor(
[
'target' => '_blank',
'href' => ($url_edit_module ?? '#'),
'href' => '#',
'onClick' => ((is_metaconsole() === true) ? 'redirectNode(\''.$url_edit_module.'\',\'_self\')' : ''),
'content' => ui_print_truncate_text($row['module_name'], 'module_small', false, true, true),
],
true
@ -2273,43 +2257,12 @@ if (empty($result) === false) {
$table->cellclass[][12] = 'table_action_buttons';
if (is_metaconsole() === true) {
echo "<form id='agent-edit-redirection-".$inc_id."' target='_blank' method='POST' action='".$row['server_url']."index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&edit_module=1'>";
html_print_input_hidden(
'id_agente',
$row['id_agent'],
false
);
html_print_input_hidden(
'id_agent_module',
$row['id_agente_modulo'],
false
);
html_print_input_hidden(
'loginhash',
'auto',
false
);
html_print_input_hidden(
'loginhash_data',
$row['hashdata'],
false
);
html_print_input_hidden(
'loginhash_user',
str_rot13($row['user']),
false
);
echo '</form>';
$url_edit_module = $row['server_url'];
$url_edit_module .= 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&';
$url_edit_module .= '&id_agente='.$row['id_agent'];
$url_edit_module .= '&tab=module&id_agent_module='.$row['id_agente_modulo'].'&edit_module=1';
$url_edit_module .= '&loginhash=auto&loginhash_data='.$row['hashdata'];
$url_edit_module .= '&loginhash_user='.str_rot13($row['user']);
$agent_link = "<a href='".$url_edit_module."'>";
$agent_link = '<a href="#" onclick="redirectNode(\''.$url_edit_module.'\',\'_self\')">';
$agent_alias = ui_print_truncate_text(
$agent_alias,