diff --git a/pandora_console/extras/mr/33.sql b/pandora_console/extras/mr/33.sql new file mode 100644 index 0000000000..eeca8ed5d7 --- /dev/null +++ b/pandora_console/extras/mr/33.sql @@ -0,0 +1,9 @@ +START TRANSACTION; + +INSERT INTO `ttipo_modulo` VALUES +(34,'remote_cmd', 10, 'Remote execution, numeric data', 'mod_remote_cmd.png'), +(35,'remote_cmd_proc', 10, 'Remote execution, boolean data', 'mod_remote_cmd_proc.png'), +(36,'remote_cmd_string', 10, 'Remote execution, alphanumeric data', 'mod_remote_cmd_string.png'), +(37,'remote_cmd_inc', 10, 'Remote execution, incremental data', 'mod_remote_cmd_inc.png'); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 6476e79e2b..0b309cfd84 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1654,7 +1654,12 @@ INSERT INTO tmodule VALUES (8, 'Wux module'); -- Table `ttipo_modulo` -- --------------------------------------------------------------------- -INSERT INTO ttipo_modulo VALUES (25,'web_analysis', 8, 'Web analysis data', 'module-wux.png'); +INSERT INTO `ttipo_modulo` VALUES +(25,'web_analysis', 8, 'Web analysis data', 'module-wux.png'), +(34,'remote_cmd', 10, 'Remote execution, numeric data', 'mod_remote_cmd.png'), +(35,'remote_cmd_proc', 10, 'Remote execution, boolean data', 'mod_remote_cmd_proc.png'), +(36,'remote_cmd_string', 10, 'Remote execution, alphanumeric data', 'mod_remote_cmd_string.png'), +(37,'remote_cmd_inc', 10, 'Remote execution, incremental data', 'mod_remote_cmd_inc.png'); -- --------------------------------------------------------------------- -- Table `tdashboard` @@ -2293,3 +2298,4 @@ CREATE TABLE `tdeployment_hosts` ( FOREIGN KEY (`target_agent_version_id`) REFERENCES `tagent_repository`(`id`) ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + diff --git a/pandora_console/general/subselect_data_module.php b/pandora_console/general/subselect_data_module.php index 416897ea15..fca56c692c 100644 --- a/pandora_console/general/subselect_data_module.php +++ b/pandora_console/general/subselect_data_module.php @@ -13,7 +13,8 @@ switch ($_GET['module']) { $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo - WHERE categoria between 3 and 5 ' + WHERE categoria between 3 and 5 + OR categoria = 10 ' ); break; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 55116f940a..664b173748 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1330,7 +1330,7 @@ if ($update_module || $create_module) { // Change double quotes by single. $snmp_oid = preg_replace('/"/', ''', $snmp_oid); - if (empty($snmp_oid)) { + if (empty($snmp_oid) === true) { // The user did not set any OID manually but did a SNMP walk. $snmp_oid = (string) get_parameter('select_snmp_oid'); } @@ -1339,18 +1339,30 @@ if ($update_module || $create_module) { // New support for snmp v3. $tcp_send = (string) get_parameter('snmp_version'); $plugin_user = (string) get_parameter('snmp3_auth_user'); - $plugin_pass = io_input_password((string) get_parameter('snmp3_auth_pass')); + $plugin_pass = io_input_password( + (string) get_parameter('snmp3_auth_pass') + ); $plugin_parameter = (string) get_parameter('snmp3_auth_method'); $custom_string_1 = (string) get_parameter('snmp3_privacy_method'); - $custom_string_2 = io_input_password((string) get_parameter('snmp3_privacy_pass')); + $custom_string_2 = io_input_password( + (string) get_parameter('snmp3_privacy_pass') + ); $custom_string_3 = (string) get_parameter('snmp3_security_level'); + } else if ($id_module_type >= 34 && $id_module_type <= 37) { + $tcp_send = (string) get_parameter('command_text'); + $custom_string_1 = (string) get_parameter( + 'command_credential_identifier' + ); + $custom_string_2 = (string) get_parameter('command_os'); } else { $plugin_user = (string) get_parameter('plugin_user'); if (get_parameter('id_module_component_type') == 7) { $plugin_pass = (int) get_parameter('plugin_pass'); } else { - $plugin_pass = io_input_password((string) get_parameter('plugin_pass')); + $plugin_pass = io_input_password( + (string) get_parameter('plugin_pass') + ); } $plugin_parameter = (string) get_parameter('plugin_parameter'); diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 13c313892a..874fe3a9d1 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -1,16 +1,32 @@ = 15 + && $component['type'] <= 18 + ) { + // New support for snmp v3. + $component['snmp_version'] = $component['tcp_send']; + $component['snmp3_auth_user'] = io_safe_output( + $component['plugin_user'] + ); + // Must use io_output_password. + $component['snmp3_auth_pass'] = io_safe_output( + $component['plugin_pass'] + ); + $component['snmp3_auth_method'] = io_safe_output( + $component['plugin_parameter'] + ); + $component['snmp3_privacy_method'] = io_safe_output( + $component['custom_string_1'] + ); + $component['snmp3_privacy_pass'] = io_safe_output( + $component['custom_string_2'] + ); + $component['snmp3_security_level'] = io_safe_output( + $component['custom_string_3'] + ); + } else if ($component['type'] >= 34 + && $component['type'] <= 37 + ) { + $component['command_text'] = io_safe_output( + $component['tcp_send'] + ); + $component['command_credential_identifier'] = io_safe_output( + $component['custom_string_1'] + ); + $component['command_os'] = io_safe_output( + $component['custom_string_2'] + ); + } $component['str_warning'] = io_safe_output($component['str_warning']); $component['str_critical'] = io_safe_output($component['str_critical']); @@ -83,33 +146,29 @@ if (is_ajax()) { $component = db_get_row('tlocal_component', 'id', $id_component); foreach ($component as $index => $element) { - $component[$index] = html_entity_decode($element, ENT_QUOTES, 'UTF-8'); + $component[$index] = html_entity_decode( + $element, + ENT_QUOTES, + 'UTF-8' + ); } - $typeName = local_components_parse_module_extract_value('module_type', $component['data']); + $typeName = local_components_parse_module_extract_value( + 'module_type', + $component['data'] + ); - switch ($config['dbtype']) { - case 'mysql': - $component['type'] = db_get_value_sql( - ' - SELECT id_tipo - FROM ttipo_modulo - WHERE nombre LIKE "'.$typeName.'"' - ); - break; + $component['type'] = db_get_value_sql( + ' + SELECT id_tipo + FROM ttipo_modulo + WHERE nombre LIKE "'.$typeName.'"' + ); - case 'postgresql': - case 'oracle': - $component['type'] = db_get_value_sql( - ' - SELECT id_tipo - FROM ttipo_modulo - WHERE nombre LIKE \''.$typeName.'\'' - ); - break; - } - - $component['throw_unknown_events'] = !local_components_is_disable_type_event($id_component, EVENTS_GOING_UNKNOWN); + $component['throw_unknown_events'] = !local_components_is_disable_type_event( + $id_component, + EVENTS_GOING_UNKNOWN + ); echo io_json_mb_encode($component); return; @@ -136,7 +195,9 @@ if (is_ajax()) { $snmp3_auth_method = get_parameter('snmp3_auth_method'); $snmp3_auth_pass = io_safe_output(get_parameter('snmp3_auth_pass')); $snmp3_privacy_method = get_parameter('snmp3_privacy_method'); - $snmp3_privacy_pass = io_safe_output(get_parameter('snmp3_privacy_pass')); + $snmp3_privacy_pass = io_safe_output( + get_parameter('snmp3_privacy_pass') + ); $snmp_port = get_parameter('snmp_port'); $snmpwalk = get_snmpwalk( @@ -177,7 +238,7 @@ require_once 'include/functions_exportserver.php'; require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_agents.php'; -// Reading a module +// Reading a module. if ($id_agent_module) { $module = modules_get_agentmodule($id_agent_module); $moduletype = $module['id_modulo']; @@ -202,19 +263,25 @@ if ($id_agent_module) { $snmp_community = $module['snmp_community']; $snmp_oid = $module['snmp_oid']; - // New support for snmp v3 + // New support for snmp v3. $snmp_version = $module['tcp_send']; $snmp3_auth_user = $module['plugin_user']; $snmp3_auth_pass = io_output_password($module['plugin_pass']); - // Auth method could be MD5 or SHA + // Auth method could be MD5 or SHA. $snmp3_auth_method = $module['plugin_parameter']; - // Privacy method could be DES or AES + // Privacy method could be DES or AES. $snmp3_privacy_method = $module['custom_string_1']; $snmp3_privacy_pass = io_output_password($module['custom_string_2']); - // Security level Could be noAuthNoPriv | authNoPriv | authPriv + // For Remote cmd fields are reused: + // tcp_send, custom_string_1, custom_string_2. + $command_text = $module['tcp_send']; + $command_credential_identifier = $module['custom_string_1']; + $command_os = $module['custom_string_2']; + + // Security level Could be noAuthNoPriv | authNoPriv | authPriv. $snmp3_security_level = $module['custom_string_3']; $ip_target = $module['ip_target']; @@ -265,39 +332,39 @@ if ($id_agent_module) { $id_category = $module['id_category']; $cron_interval = explode(' ', $module['cron_interval']); - if (isset($cron_interval[4])) { + if (isset($cron_interval[4]) === true) { $minute_from = $cron_interval[0]; $minute = explode('-', $minute_from); $minute_from = $minute[0]; - if (isset($minute[1])) { + if (isset($minute[1]) === true) { $minute_to = $minute[1]; } $hour_from = $cron_interval[1]; $h = explode('-', $hour_from); $hour_from = $h[0]; - if (isset($h[1])) { + if (isset($h[1]) === true) { $hour_to = $h[1]; } $mday_from = $cron_interval[2]; $md = explode('-', $mday_from); $mday_from = $md[0]; - if (isset($md[1])) { + if (isset($md[1]) === true) { $mday_to = $md[1]; } $month_from = $cron_interval[3]; $m = explode('-', $month_from); $month_from = $m[0]; - if (isset($m[1])) { + if (isset($m[1]) === true) { $month_to = $m[1]; } $wday_from = $cron_interval[4]; $wd = explode('-', $wday_from); $wday_from = $wd[0]; - if (isset($wd[1])) { + if (isset($wd[1]) === true) { $wday_to = $wd[1]; } } else { @@ -315,14 +382,17 @@ if ($id_agent_module) { } $module_macros = null; - if (isset($module['module_macros'])) { - $module_macros = json_decode(base64_decode($module['module_macros']), true); + if (isset($module['module_macros']) === true) { + $module_macros = json_decode( + base64_decode($module['module_macros']), + true + ); } } else { - if (!isset($moduletype)) { + if (isset($moduletype) === false) { $moduletype = (string) get_parameter('moduletype'); - // Clean up specific network modules fields + // Clean up specific network modules fields. $name = ''; $description = ''; $id_module_group = 1; @@ -374,7 +444,7 @@ if ($id_agent_module) { $str_critical = ''; $ff_event = 0; - // New support for snmp v3 + // New support for snmp v3. $snmp_version = 1; $snmp3_auth_user = ''; $snmp3_auth_pass = ''; @@ -383,6 +453,11 @@ if ($id_agent_module) { $snmp3_privacy_pass = ''; $snmp3_security_level = ''; + // For Remote CMD. + $command_text = ''; + $command_credential_identifier = ''; + $command_os = ''; + $critical_instructions = ''; $warning_instructions = ''; $unknown_instructions = ''; @@ -418,7 +493,9 @@ if ($id_agent_module) { } } -$is_function_policies = enterprise_include_once('include/functions_policies.php'); +$is_function_policies = enterprise_include_once( + 'include/functions_policies.php' +); if ($is_function_policies !== ENTERPRISE_NOT_HOOK) { $relink_policy = get_parameter('relink_policy', 0); @@ -428,19 +505,32 @@ if ($is_function_policies !== ENTERPRISE_NOT_HOOK) { $policy_info = policies_info_module_policy($id_agent_module); $policy_id = $policy_info['id_policy']; - if ($relink_policy && policies_get_policy_queue_status($policy_id) == STATUS_IN_QUEUE_APPLYING) { - ui_print_error_message(__('This policy is applying and cannot be modified')); + if ($relink_policy + && policies_get_policy_queue_status($policy_id) == STATUS_IN_QUEUE_APPLYING + ) { + ui_print_error_message( + __('This policy is applying and cannot be modified') + ); } else { $result = policies_relink_module($id_agent_module); - ui_print_result_message($result, __('Module will be linked in the next application')); + ui_print_result_message( + $result, + __('Module will be linked in the next application') + ); - db_pandora_audit('Agent management', 'Re-link module '.$id_agent_module); + db_pandora_audit( + 'Agent management', + 'Re-link module '.$id_agent_module + ); } } if ($unlink_policy) { $result = policies_unlink_module($id_agent_module); - ui_print_result_message($result, __('Module will be unlinked in the next application')); + ui_print_result_message( + $result, + __('Module will be unlinked in the next application') + ); db_pandora_audit('Agent management', 'Unlink module '.$id_agent_module); } @@ -452,7 +542,7 @@ $remote_conf = false; if ($__code_from !== 'policies') { // Only check in the module editor. - // Check ACL tags + // Check ACL tags. $tag_acl = true; // If edit a existing module. @@ -479,12 +569,12 @@ switch ($moduletype) { $remote_conf = false; if (enterprise_installed()) { enterprise_include_once('include/functions_config_agents.php'); - $remote_conf = enterprise_hook('config_agents_has_remote_configuration', [$id_agente]); + $remote_conf = enterprise_hook( + 'config_agents_has_remote_configuration', + [$id_agente] + ); } - /* - Categories is an array containing the allowed module types - (generic_data, generic_string, etc) from ttipo_modulo (field categoria) */ $categories = [ 0, 1, @@ -503,12 +593,16 @@ switch ($moduletype) { 'config_agents_get_module_from_conf', [ $id_agente, - io_safe_output(modules_get_agentmodule_name($id_agent_module)), + io_safe_output( + modules_get_agentmodule_name($id_agent_module) + ), ] ); } - enterprise_include('godmode/agentes/module_manager_editor_data.php'); + enterprise_include( + 'godmode/agentes/module_manager_editor_data.php' + ); } break; @@ -520,6 +614,10 @@ switch ($moduletype) { 4, 5, ]; + if (enterprise_installed()) { + $categories[] = 10; + } + include 'module_manager_editor_common.php'; include 'module_manager_editor_network.php'; break; @@ -562,9 +660,12 @@ switch ($moduletype) { include 'module_manager_editor_wmi.php'; break; - // WARNING: type 7 is reserved on enterprise + // WARNING: type 7 is reserved on enterprise. default: - if (enterprise_include('godmode/agentes/module_manager_editor.php') === ENTERPRISE_NOT_HOOK) { + if (enterprise_include( + 'godmode/agentes/module_manager_editor.php' + ) === ENTERPRISE_NOT_HOOK + ) { ui_print_error_message(sprintf(__('Invalid module type'))); return; } @@ -580,7 +681,7 @@ if ($config['enterprise_installed'] && $id_agent_module) { echo '
'; -// TODO: Change to the ui_print_error system +// TODO: Change to the ui_print_error system. echo '