From 8af72c1c9d5fb0f46592f9b55b9fff1ea49d2835 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Wed, 9 Oct 2019 17:26:06 +0200 Subject: [PATCH 01/36] add Remote CMD --- pandora_console/extras/mr/33.sql | 9 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 8 +- .../general/subselect_data_module.php | 3 +- .../godmode/agentes/configurar_agente.php | 21 +- .../godmode/agentes/module_manager_editor.php | 311 ++++++++++++------ .../agentes/module_manager_editor_common.php | 81 +++-- .../agentes/module_manager_editor_network.php | 266 +++++++++++---- .../include/class/CredentialStore.class.php | 2 + .../operation/agentes/status_monitor.php | 9 +- pandora_console/pandoradb_data.sql | 12 +- 10 files changed, 533 insertions(+), 189 deletions(-) create mode 100644 pandora_console/extras/mr/33.sql diff --git a/pandora_console/extras/mr/33.sql b/pandora_console/extras/mr/33.sql new file mode 100644 index 0000000000..885132f68f --- /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 CMD command, numeric data', 'mod_remote_cmd.png'), +(35,'remote_cmd_proc', 10, 'Remote CMD command, boolean data', 'mod_remote_cmd_proc.png'), +(36,'remote_cmd_string', 10, 'Remote CMD command, alphanumeric data', 'mod_remote_cmd_string.png'), +(37,'remote_cmd_inc', 10, 'Remote CMD command, 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..30cff5136a 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 CMD command, numeric data', 'mod_remote_cmd.png'), +(35,'remote_cmd_proc', 10, 'Remote CMD command, boolean data', 'mod_remote_cmd_proc.png'), +(36,'remote_cmd_string', 10, 'Remote CMD command, alphanumeric data', 'mod_remote_cmd_string.png'), +(37,'remote_cmd_inc', 10, 'Remote CMD command, 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..f6cf27a69e 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,31 @@ 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) { + hd($_POST); + $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..bf51f2b0fe 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -1,16 +1,32 @@ $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 +157,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 +200,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 +225,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 +294,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 +344,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 +406,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 +415,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 +455,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 +467,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 +504,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 +531,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 +555,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; @@ -519,6 +575,7 @@ switch ($moduletype) { 3, 4, 5, + 10, ]; include 'module_manager_editor_common.php'; include 'module_manager_editor_network.php'; @@ -562,9 +619,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 +640,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 '
'; ui_toggle( @@ -602,12 +662,18 @@ ui_toggle( if ($moduletype != 13) { ui_toggle( - html_print_table($table_new_relations, true).html_print_table($table_relations, true), + html_print_table( + $table_new_relations, + true + ).html_print_table( + $table_relations, + true + ), __('Module relations') ); } -// Submit +// Submit. echo '
'; if ($id_agent_module) { html_print_submit_button( @@ -659,38 +725,84 @@ ui_require_javascript_file('pandora_modules'); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 5a4653fc29..08f930c95f 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -132,7 +132,7 @@ function add_component_selection($id_network_component_type) require_once 'include/functions_network_components.php'; enterprise_include_once('include/functions_policies.php'); -// If code comes from policies disable export select +// If code comes from policies disable export select. global $__code_from; $disabledBecauseInPolicy = false; @@ -209,8 +209,7 @@ $table_simple->data[0][1] = html_print_input_text_extended( $largeClassDisabledBecauseInPolicy, true ); -// $table_simple->data[0][1] = html_print_input_text ('name', -// io_safe_output($name), '', 45, 100, true, $disabledBecauseInPolicy); + if (!empty($id_agent_module) && isset($id_agente)) { $table_simple->data[0][1] .= ' '.__('ID').'  '.$id_agent_module.' '; @@ -237,7 +236,13 @@ if ($policy_link != 0) { } $table_simple->data[0][2] = __('Disabled'); -$table_simple->data[0][2] .= html_print_checkbox('disabled', 1, $disabled, true, $disabled_enable); +$table_simple->data[0][2] .= html_print_checkbox( + 'disabled', + 1, + $disabled, + true, + $disabled_enable +); $table_simple->data[0][3] = __('Module group'); $table_simple->data[0][3] .= html_print_select_from_sql( 'SELECT id_mg, name FROM tmodule_group ORDER BY name', @@ -260,12 +265,18 @@ if ((isset($id_agent_module) && $id_agent_module) || $id_policy_module != 0) { $in_policy = strstr($page, 'policy_modules'); if (!$in_policy) { - // Cannot select the current module to be itself parent - $module_parent_filter = $id_agent_module ? ['tagente_modulo.id_agente_modulo' => "<>$id_agent_module"] : ''; + // Cannot select the current module to be itself parent. + $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => "<>$id_agent_module"] : ''; $table_simple->data[1][0] = __('Module parent'); - $modules_can_be_parent = agents_get_modules($id_agente, false, $module_parent_filter); - // If the user cannot have access to parent module, only print the name - if ($parent_module_id != 0 && !in_array($parent_module_id, array_keys($modules_can_be_parent))) { + $modules_can_be_parent = agents_get_modules( + $id_agente, + false, + $module_parent_filter + ); + // If the user cannot have access to parent module, only print the name. + if ($parent_module_id != 0 + && !in_array($parent_module_id, array_keys($modules_can_be_parent)) + ) { $table_simple->data[1][1] = db_get_value( 'nombre', 'tagente_modulo', @@ -305,7 +316,11 @@ if (!$edit) { } $table_simple->data[2][1] = ''.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')'; - $table_simple->data[2][1] .= html_print_input_hidden('type_names', base64_encode(io_json_mb_encode($type_names_hash)), true); + $table_simple->data[2][1] .= html_print_input_hidden( + 'type_names', + base64_encode(io_json_mb_encode($type_names_hash)), + true + ); } else { if (isset($id_module_type)) { $idModuleType = $id_module_type; @@ -313,12 +328,13 @@ if (!$edit) { $idModuleType = ''; } - // Removed web analysis and log4x from select + // Removed web analysis and log4x from select. $sql = sprintf( - 'SELECT id_tipo, descripcion, nombre + 'SELECT id_tipo, descripcion, nombre, categoria FROM ttipo_modulo - WHERE categoria IN (%s) AND id_tipo NOT IN (24, 25) - ORDER BY descripcion', + WHERE categoria IN (%s) + AND id_tipo NOT IN (24, 25) + ORDER BY id_tipo ASC', implode(',', $categories) ); @@ -326,7 +342,9 @@ if (!$edit) { $type_names_hash = []; $type_description_hash = []; - if (isset($type_names) && is_array($type_names)) { + if (isset($type_names) === true + && is_array($type_names) === true + ) { foreach ($type_names as $tn) { $type_names_hash[$tn['id_tipo']] = $tn['nombre']; $type_description_hash[$tn['id_tipo']] = $tn['descripcion']; @@ -342,7 +360,7 @@ if (!$edit) { 0, true, false, - true, + false, '', false, false, @@ -350,8 +368,12 @@ if (!$edit) { 100 ); - // Store the relation between id and name of the types on a hidden field - $table_simple->data[2][1] .= html_print_input_hidden('type_names', base64_encode(io_json_mb_encode($type_names_hash)), true); + // Store the relation between id and name of the types on a hidden field. + $table_simple->data[2][1] .= html_print_input_hidden( + 'type_names', + base64_encode(io_json_mb_encode($type_names_hash)), + true + ); } if ($edit_module) { @@ -380,15 +402,32 @@ if ($edit_module) { $help_header = 'webserver_module_tab'; } - $table_simple->data[2][0] = __('Type').' '.ui_print_help_icon($help_header, true); + $table_simple->data[2][0] = __('Type').' '; + $table_simple->data[2][0] .= ui_print_help_icon($help_header, true); } if ($disabledBecauseInPolicy) { - $table_simple->data[2][3] .= html_print_input_hidden('id_module_group', $id_module_group, true); + $table_simple->data[2][3] .= html_print_input_hidden( + 'id_module_group', + $id_module_group, + true + ); } $table_simple->data[3][0] = __('Dynamic Threshold Interval'); -$table_simple->data[3][1] = html_print_extended_select_for_time('dynamic_interval', $dynamic_interval, '', 'None', '0', 10, true, 'width:150px', false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy); +$table_simple->data[3][1] = html_print_extended_select_for_time( + 'dynamic_interval', + $dynamic_interval, + '', + 'None', + '0', + 10, + true, + 'width:150px', + false, + $classdisabledBecauseInPolicy, + $disabledBecauseInPolicy +); $table_simple->data[3][1] .= ''.html_print_image('images/cog.png', true, ['title' => __('Advanced options Dynamic Threshold')]).''; if ($in_policy) { $table_simple->cellclass[2][2] = 'hide_dinamic'; diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index c0a6181a8e..76bbf50c47 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -1,30 +1,50 @@ "; -// This line does not run with the dinamic loader editor in policies. -// ui_require_javascript_file ('pandora_snmp_browser'); -// WARNING REPEAT input hidden errors in console -// Save some variables for javascript functions -// html_print_input_hidden ('ajax_url', ui_get_full_url("ajax.php"), false); -// html_print_input_hidden ('search_matches_translation', __("Search matches"), false); -// Define a custom action to save the OID selected in the SNMP browser to the form -html_print_input_hidden('custom_action', urlencode(base64_encode(' ')), false); +echo ""; + +// Define a custom action to save the OID selected +// in the SNMP browser to the form. +html_print_input_hidden( + 'custom_action', + urlencode( + base64_encode( + ' ' + ) + ), + false +); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); @@ -50,17 +70,15 @@ if (strstr($page, 'policy_modules') === false) { define('ID_NETWORK_COMPONENT_TYPE', 2); if (empty($update_module_id)) { - // Function in module_manager_editor_common.php + // Function in module_manager_editor_common.php. add_component_selection(ID_NETWORK_COMPONENT_TYPE); -} else { - // TODO: Print network component if available } $extra_title = __('Network server module'); $data = []; $data[0] = __('Target IP'); -// show agent_for defect; +// Show agent_for defect. if ($page == 'enterprise/godmode/policies/policy_modules') { if ($ip_target != 'auto' && $ip_target != '') { $custom_ip_target = $ip_target; @@ -100,7 +118,7 @@ if ($page == 'enterprise/godmode/policies/policy_modules') { $data[1] = html_print_input_text('ip_target', $ip_target, '', 15, 60, true); } -// In ICMP modules, port is not configurable +// In ICMP modules, port is not configurable. if ($id_module_type >= 6 && $id_module_type <= 7) { $data[2] = ''; $data[3] = ''; @@ -148,7 +166,15 @@ if (!$adopt) { $classdisabledBecauseInPolicy ); } else { - $data[1] = html_print_input_text('snmp_community', $snmp_community, '', 15, 60, true, false); + $data[1] = html_print_input_text( + 'snmp_community', + $snmp_community, + '', + 15, + 60, + true, + false + ); } $data[2] = _('SNMP version'); @@ -213,8 +239,27 @@ $data[1] .= html_print_input_text( $classdisabledBecauseInPolicy ); $data[1] .= ''; $data[1] .= ''; $data[1] .= html_print_button( @@ -231,42 +276,50 @@ $table_simple->colspan['snmp_2'][1] = 3; push_table_simple($data, 'snmp_2'); -// Advanced stuff +// Advanced stuff. $data = []; $data[0] = __('TCP send'); -$data[1] = html_print_textarea('tcp_send', 2, 65, $tcp_send, $disabledTextBecauseInPolicy, true, $largeclassdisabledBecauseInPolicy); +$data[1] = html_print_textarea( + 'tcp_send', + 2, + 65, + $tcp_send, + $disabledTextBecauseInPolicy, + true, + $largeclassdisabledBecauseInPolicy +); $table_simple->colspan['tcp_send'][1] = 3; push_table_simple($data, 'tcp_send'); $data[0] = __('TCP receive'); -$data[1] = html_print_textarea('tcp_rcv', 2, 65, $tcp_rcv, $disabledTextBecauseInPolicy, true, $largeclassdisabledBecauseInPolicy); +$data[1] = html_print_textarea( + 'tcp_rcv', + 2, + 65, + $tcp_rcv, + $disabledTextBecauseInPolicy, + true, + $largeclassdisabledBecauseInPolicy +); $table_simple->colspan['tcp_receive'][1] = 3; push_table_simple($data, 'tcp_receive'); if ($id_module_type < 8 || $id_module_type > 11) { - // NOT TCP + // NOT TCP. $table_simple->rowstyle['tcp_send'] = 'display: none;'; $table_simple->rowstyle['tcp_receive'] = 'display: none;'; } if ($id_module_type < 15 || $id_module_type > 18) { - // NOT SNMP + // NOT SNMP. $table_simple->rowstyle['snmp_1'] = 'display: none'; $table_simple->rowstyle['snmp_2'] = 'display: none'; } -// For a policy -if (!isset($id_agent_module)) { - $snmp3_auth_user = ''; - $snmp3_auth_pass = ''; - $snmp_version = 1; - $snmp3_privacy_method = ''; - $snmp3_privacy_pass = ''; - $snmp3_auth_method = ''; - $snmp3_security_level = ''; -} else if ($id_agent_module === false) { +// For a policy. +if (isset($id_agent_module) === false || $id_agent_module === false) { $snmp3_auth_user = ''; $snmp3_auth_pass = ''; $snmp_version = 1; @@ -274,6 +327,9 @@ if (!isset($id_agent_module)) { $snmp3_privacy_pass = ''; $snmp3_auth_method = ''; $snmp3_security_level = ''; + $command_text = ''; + $command_os = 'inherited'; + $command_credential_identifier = ''; } $data = []; @@ -333,7 +389,22 @@ push_table_simple($data, 'field_snmpv3_row2'); $data = []; $data[0] = __('Auth method'); -$data[1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', $disabledBecauseInPolicy); +$data[1] = html_print_select( + [ + 'MD5' => __('MD5'), + 'SHA' => __('SHA'), + ], + 'snmp3_auth_method', + $snmp3_auth_method, + '', + '', + '', + true, + false, + false, + '', + $disabledBecauseInPolicy +); $data[2] = __('Security level'); $data[3] = html_print_select( [ @@ -358,13 +429,84 @@ if ($snmp_version != 3) { push_table_simple($data, 'field_snmpv3_row3'); +$data = []; +$data[0] = __('Command'); +$data[1] = html_print_input_text_extended( + 'command_text', + $command_text, + 'command_text', + '', + 100, + 10000, + $disabledBecauseInPolicy, + '', + $largeClassDisabledBecauseInPolicy, + true +); +$table_simple->colspan['row-cmd-row-1'][1] = 3; +push_table_simple($data, 'row-cmd-row-1'); + +require_once $config['homedir'].'/include/class/CredentialStore.class.php'; +$array_credential_identifier = CredentialStore::getKeys(); + +$data[0] = __('Credential identifier'); +$data[1] = html_print_select( + $array_credential_identifier, + 'command_credential_identifier', + $command_credential_identifier, + '', + __('None'), + '', + true, + false, + false, + '', + $disabledBecauseInPolicy +); + +$array_os = [ + 'inherited' => __('Inherited'), + 'linux' => __('Linux'), + 'windows' => __('Windows'), +]; + +$data[2] = __('Target OS'); +$data[3] = html_print_select( + $array_os, + 'command_os', + $command_os, + '', + '', + '', + true, + false, + false, + '', + $disabledBecauseInPolicy +); + +push_table_simple($data, 'row-cmd-row-2'); + +if ($id_module_type !== 34 + && $id_module_type !== 35 + && $id_module_type !== 36 + && $id_module_type !== 37 +) { + $table_simple->rowstyle['row-cmd-row-1'] = 'display: none;'; + $table_simple->rowstyle['row-cmd-row-2'] = 'display: none;'; +} + snmp_browser_print_container(false, '100%', '60%', 'none'); ?> diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index fd922046d1..114be6a969 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -1,17 +1,32 @@ $id_agentmodule]); + $data_module = db_get_row_filter( + 'tagente_modulo', + ['id_agente_modulo' => $id_agentmodule] + ); $name = $data_module['nombre']; $description = $data_module['descripcion']; @@ -139,16 +160,25 @@ if (isset($id)) { $each_ff = $component['each_ff']; if ($type >= 15 && $type <= 18) { - // New support for snmp v3 + // New support for snmp v3. $snmp_version = $component['tcp_send']; $snmp3_auth_user = $component['plugin_user']; $snmp3_auth_pass = io_output_password($component['plugin_pass']); $snmp3_auth_method = $component['plugin_parameter']; $snmp3_privacy_method = $component['custom_string_1']; - $snmp3_privacy_pass = io_output_password($component['custom_string_2']); + $snmp3_privacy_pass = io_output_password( + $component['custom_string_2'] + ); $snmp3_security_level = $component['custom_string_3']; + } else if ($type >= 34 && $type <= 37) { + $command_text = $component['tcp_send']; + $command_credential_identifier = $component['custom_string_1']; + $command_os = $component['custom_string_2']; } - } else if (isset($new_component) && $new_component && !$create_network_from_snmp_browser) { + } else if (isset($new_component) + && $new_component + && !$create_network_from_snmp_browser + ) { $name = ''; $snmp_oid = ''; $description = ''; @@ -204,21 +234,13 @@ if (isset($id)) { $snmp3_privacy_pass = ''; $snmp3_auth_method = ''; $snmp3_security_level = ''; + + $command_text = ''; + $command_os = 'inherited'; + $command_credential_identifier = ''; } } -if ($create_network_from_snmp_browser) { -} - -/* - * $id_component_type has these values: - * 6 - Module WMI - * 4 - Plugin component - * 2 - network component - * - * You can see this values in file godmode/modules/manage_network_components.php - * in the last lines (in the call function "html_print_select"). - */ $table = new stdClass(); if ($id_component_type == 6) { @@ -242,6 +264,7 @@ if ($id_component_type == 6) { 3, 4, 5, + 10, ]; include $config['homedir'].'/godmode/modules/manage_network_components_form_common.php'; include $config['homedir'].'/godmode/modules/manage_network_components_form_network.php'; @@ -253,7 +276,7 @@ echo ''; $table->width = '100%'; $table->class = 'databox filters'; -// $table came from manage_network_components_form_common.php + if (defined('METACONSOLE')) { if ($id) { $table->head[0] = __('Update Network Component'); @@ -295,61 +318,78 @@ ui_require_javascript_file('pandora_modules'); function type_change () { // type 1-4 - Generic_xxxxxx if ((document.component.type.value > 0) && (document.component.type.value < 5)) { - - $("input[name=snmp_community]").css({backgroundColor: '#ddd !important'}); + $("input[name=snmp_community]") + .css({backgroundColor: '#ddd '}); $("input[name=snmp_community]").attr("disabled", true); - - $("input[name=tcp_rcv]").css({backgroundColor: '#ddd !important'}); + + $("input[name=tcp_rcv]").css({backgroundColor: '#ddd '}); $("input[name=tcp_rcv]").attr("disabled", true); - + - $("input[name=snmp_oid]").css({backgroundColor: '#ddd !important'}); + $("input[name=snmp_oid]") + .css({backgroundColor: '#ddd '}); $("input[name=snmp_oid]").attr("disabled", true); - - $("input[name=tcp_send]").css({backgroundColor: '#ddd !important'}); + + $("input[name=tcp_send]") + .css({backgroundColor: '#ddd '}); $("input[name=tcp_send]").attr("disabled", true); - - $("input[name=tcp_port]").css({backgroundColor: '#ddd !important'}); + + $("input[name=tcp_port]") + .css({backgroundColor: '#ddd '}); $("input[name=tcp_port]").attr("disabled", true); - - $("input[name=snmp3_auth_user]").css({backgroundColor: '#ddd !important'}); + + $("input[name=snmp3_auth_user]") + .css({backgroundColor: '#ddd '}); $("input[name=snmp3_auth_user]").attr("disabled", true); - - $("input[name=snmp3_auth_pass]").css({backgroundColor: '#ddd !important'}); + + $("input[name=snmp3_auth_pass]") + .css({backgroundColor: '#ddd '}); $("input[name=snmp3_auth_pass]").attr("disabled", true); - - $("#snmp3_privacy_method").css({backgroundColor: '#ddd !important'}); + + $("#snmp3_privacy_method").css({backgroundColor: '#ddd '}); $("#snmp3_privacy_method").attr("disabled", true); - - $("input[name=snmp3_privacy_pass]").css({backgroundColor: '#ddd !important'}); + + $("input[name=snmp3_privacy_pass]") + .css({backgroundColor: '#ddd '}); $("input[name=snmp3_privacy_pass]").attr("disabled", true); - - $("#snmp3_auth_method").css({backgroundColor: '#ddd !important'}); + + $("#snmp3_auth_method").css({backgroundColor: '#ddd '}); $("#snmp3_auth_method").attr("disabled", true); - - $("#snmp3_security_level").css({backgroundColor: '#ddd !important'}); + + $("#snmp3_security_level").css({backgroundColor: '#ddd '}); $("#snmp3_security_level").attr("disabled", true); + + $("#command_text").css({backgroundColor: '#ddd '}); + $("#command_text").attr("disabled", true); + + $("#command_credential_identifier") + .css({backgroundColor: '#ddd '}); + $("#command_credential_identifier").attr("disabled", true); + + $("#command_os").css({backgroundColor: '#ddd '}); + $("#command_os").attr("disabled", true); } // type 15-18- SNMP - if ((document.component.type.value > 14) && (document.component.type.value < 19 )) { - document.component.snmp_oid.style.background="#fff"; - document.component.snmp_oid.style.disabled=false; - document.component.snmp_community.style.background="#fff"; - document.component.snmp_community.disabled=false; + if ((document.component.type.value > 14) && (document.component.type.value < 19 )) { document.component.snmp_oid.style.background="#fff"; document.component.snmp_oid.disabled=false; - document.component.tcp_send.style.background="#ddd !important"; + + document.getElementById('text-snmp_community').style.background="#fff"; + document.getElementById('text-snmp_community').disabled=false; + document.component.snmp_oid.style.background="#fff"; + document.component.snmp_oid.disabled=false; + document.component.tcp_send.style.background="#ddd "; document.component.tcp_send.disabled=true; - document.component.tcp_rcv.style.background="#ddd !important"; + document.component.tcp_rcv.style.background="#ddd "; document.component.tcp_rcv.disabled=true; document.component.tcp_port.style.background="#fff"; document.component.tcp_port.disabled=false; - + document.component.snmp_version.style.background="#fff"; document.component.snmp_version.disabled=false; document.component.snmp3_auth_user.style.background="#fff"; @@ -364,94 +404,161 @@ function type_change () { document.component.snmp3_auth_method.disabled=false; document.component.snmp3_security_level.style.background="#fff"; document.component.snmp3_security_level.disabled=false; - + + document.component.command_text.style.background="#ddd"; + document.component.command_text.style.disabled=true; + document.component.command_credential_identifier.style.background="#ddd"; + document.component.command_credential_identifier.disabled=true; + document.component.command_os.style.background="#ddd"; + document.component.command_os.disabled=true; + $("#snmp_version" ).trigger("change"); } + + if ((document.component.type.value >= 34) && (document.component.type.value <= 37 )) { + document.component.snmp_oid.style.background="#ddd"; + document.component.snmp_oid.disabled=true; + document.getElementById('text-snmp_community').style.background="#ddd"; + document.getElementById('text-snmp_community').disabled=true; + document.component.snmp_oid.style.background="#ddd"; + document.component.snmp_oid.disabled=true; + document.component.snmp_version.style.background="#ddd"; + document.component.snmp_version.disabled=true; + + document.component.tcp_send.style.background="#ddd"; + document.component.tcp_send.disabled=true; + document.component.tcp_rcv.style.background="#ddd"; + document.component.tcp_rcv.disabled=true; + document.component.tcp_port.style.background="#fff"; + document.component.tcp_port.disabled=false; + + document.component.snmp3_auth_user.style.background="#ddd "; + document.component.snmp3_auth_user.disabled=true; + document.component.snmp3_auth_pass.background="#ddd "; + document.component.snmp3_auth_pass.disabled=true; + document.component.snmp3_privacy_method.style.background="#ddd "; + document.component.snmp3_privacy_method.disabled=true; + document.component.snmp3_privacy_pass.style.background="#ddd "; + document.component.snmp3_privacy_pass.disabled=true; + document.component.snmp3_auth_method.style.background="#ddd "; + document.component.snmp3_auth_method.disabled=true; + document.component.snmp3_security_level.style.background="#ddd "; + document.component.snmp3_security_level.disabled=true; + + document.component.command_text.style.background="#fff"; + document.component.command_text.style.disabled=false; + document.component.command_credential_identifier.style.background="#fff"; + document.component.command_credential_identifier.disabled=false; + document.component.command_os.style.background="#fff"; + document.component.command_os.disabled=false; + } + // type 6-7 - ICMP if ((document.component.type.value == 6) || (document.component.type.value == 7)) { - document.component.snmp_oid.style.background="#ddd !important"; + document.component.snmp_oid.style.background="#ddd "; document.component.snmp_oid.disabled=true; - document.component.snmp_community.style.background="#ddd !important"; - document.component.snmp_community.disabled=true; - document.component.snmp_oid.style.background="#ddd !important"; + document.getElementById('text-snmp_community').style.background="#ddd"; + document.getElementById('text-snmp_community').disabled=true; + document.component.snmp_oid.style.background="#ddd "; document.component.snmp_oid.disabled=true; - document.component.tcp_send.style.background="#ddd !important"; + document.component.tcp_send.style.background="#ddd "; document.component.tcp_send.disabled=true; - document.component.tcp_rcv.style.background="#ddd !important"; + document.component.tcp_rcv.style.background="#ddd "; document.component.tcp_rcv.disabled=true; - document.component.tcp_port.style.background="#ddd !important"; + document.component.tcp_port.style.background="#ddd "; document.component.tcp_port.disabled=true; - - document.component.snmp_version.style.background="#ddd !important"; + + document.component.snmp_version.style.background="#ddd "; document.component.snmp_version.disabled=true; - document.component.snmp3_auth_user.style.background="#ddd !important"; + document.component.snmp3_auth_user.style.background="#ddd "; document.component.snmp3_auth_user.disabled=true; - document.component.snmp3_auth_pass.background="#ddd !important"; + document.component.snmp3_auth_pass.background="#ddd "; document.component.snmp3_auth_pass.disabled=true; - document.component.snmp3_privacy_method.style.background="#ddd !important"; + document.component.snmp3_privacy_method.style.background="#ddd "; document.component.snmp3_privacy_method.disabled=true; - document.component.snmp3_privacy_pass.style.background="#ddd !important"; + document.component.snmp3_privacy_pass.style.background="#ddd "; document.component.snmp3_privacy_pass.disabled=true; - document.component.snmp3_auth_method.style.background="#ddd !important"; + document.component.snmp3_auth_method.style.background="#ddd "; document.component.snmp3_auth_method.disabled=true; - document.component.snmp3_security_level.style.background="#ddd !important"; + document.component.snmp3_security_level.style.background="#ddd "; document.component.snmp3_security_level.disabled=true; + + document.component.command_text.style.background="#ddd"; + document.component.command_text.style.disabled=true; + document.component.command_credential_identifier.style.background="#ddd"; + document.component.command_credential_identifier.disabled=true; + document.component.command_os.style.background="#ddd"; + document.component.command_os.disabled=true; } // type 8-11 - TCP if ((document.component.type.value > 7) && (document.component.type.value < 12)) { - document.component.snmp_oid.style.background="#ddd !important"; + document.component.snmp_oid.style.background="#ddd "; document.component.snmp_oid.disabled=true; - document.component.snmp_community.style.background="#ddd !important"; - document.component.snmp_community.disabled=true; + document.getElementById('text-snmp_community').style.background="#ddd "; + document.getElementById('text-snmp_community').disabled=true; document.component.tcp_send.style.background="#fff"; document.component.tcp_send.disabled=false; document.component.tcp_rcv.style.background="#fff"; document.component.tcp_rcv.disabled=false; document.component.tcp_port.style.background="#fff"; document.component.tcp_port.disabled=false; - - document.component.snmp_version.style.background="#ddd !important"; + + document.component.snmp_version.style.background="#ddd "; document.component.snmp_version.disabled=true; - document.component.snmp3_auth_user.style.background="#ddd !important"; + document.component.snmp3_auth_user.style.background="#ddd "; document.component.snmp3_auth_user.disabled=true; - document.component.snmp3_auth_pass.background="#ddd !important"; + document.component.snmp3_auth_pass.background="#ddd "; document.component.snmp3_auth_pass.disabled=true; - document.component.snmp3_privacy_method.style.background="#ddd !important"; + document.component.snmp3_privacy_method.style.background="#ddd "; document.component.snmp3_privacy_method.disabled=true; - document.component.snmp3_privacy_pass.style.background="#ddd !important"; + document.component.snmp3_privacy_pass.style.background="#ddd "; document.component.snmp3_privacy_pass.disabled=true; - document.component.snmp3_auth_method.style.background="#ddd !important"; + document.component.snmp3_auth_method.style.background="#ddd "; document.component.snmp3_auth_method.disabled=true; - document.component.snmp3_security_level.style.background="#ddd !important"; + document.component.snmp3_security_level.style.background="#ddd "; document.component.snmp3_security_level.disabled=true; + + document.component.command_text.style.background="#ddd"; + document.component.command_text.style.disabled=true; + document.component.command_credential_identifier.style.background="#ddd"; + document.component.command_credential_identifier.disabled=true; + document.component.command_os.style.background="#ddd"; + document.component.command_os.disabled=true; } // type 12 - UDP if (document.component.type.value == 12) { - document.component.snmp_oid.style.background="#ddd !important"; + document.component.snmp_oid.style.background="#ddd "; document.component.snmp_oid.disabled=true; - document.component.snmp_community.style.background="#ddd !important"; - document.component.snmp_community.disabled=true; + document.getElementById('text-snmp_community').style.background="#ddd "; + document.getElementById('text-snmp_community').disabled=true; document.component.tcp_send.style.background="#fff"; document.component.tcp_send.disabled=false; document.component.tcp_rcv.style.background="#fff"; document.component.tcp_rcv.disabled=false; document.component.tcp_port.style.background="#fff"; document.component.tcp_port.disabled=false; - - document.component.snmp_version.style.background="#ddd !important"; + + document.component.snmp_version.style.background="#ddd "; document.component.snmp_version.disabled=true; - document.component.snmp3_auth_user.style.background="#ddd !important"; + document.component.snmp3_auth_user.style.background="#ddd "; document.component.snmp3_auth_user.disabled=true; - document.component.snmp3_auth_pass.background="#ddd !important"; + document.component.snmp3_auth_pass.background="#ddd "; document.component.snmp3_auth_pass.disabled=true; - document.component.snmp3_privacy_method.style.background="#ddd !important"; + document.component.snmp3_privacy_method.style.background="#ddd "; document.component.snmp3_privacy_method.disabled=true; - document.component.snmp3_privacy_pass.style.background="#ddd !important"; + document.component.snmp3_privacy_pass.style.background="#ddd "; document.component.snmp3_privacy_pass.disabled=true; - document.component.snmp3_auth_method.style.background="#ddd !important"; + document.component.snmp3_auth_method.style.background="#ddd "; document.component.snmp3_auth_method.disabled=true; - document.component.snmp3_security_level.style.background="#ddd !important"; + document.component.snmp3_security_level.style.background="#ddd "; document.component.snmp3_security_level.disabled=true; + + document.component.command_text.style.background="#ddd"; + document.component.command_text.style.disabled=true; + document.component.command_credential_identifier.style.background="#ddd"; + document.component.command_credential_identifier.disabled=true; + document.component.command_os.style.background="#ddd"; + document.component.command_os.disabled=true; } } @@ -470,7 +577,7 @@ $(document).ready (function () { } }); }); - + $("#left").click (function () { jQuery.each($("select[name='id_tag_selected[]'] option:selected"), function (key, value) { tag_name = $(value).html(); @@ -485,38 +592,38 @@ $(document).ready (function () { } }); }); - + $("#submit-crt").click(function () { $('#id_tag_selected option').map(function() { $(this).prop('selected', true); }); }); - + $("#submit-upd").click(function () { $('#id_tag_selected option').map(function() { $(this).prop('selected', true); }); }); - + if ($("#snmp_version").val() == "3") { $("input[name=snmp3_auth_user]").css({backgroundColor: '#fff'}); $("input[name=snmp3_auth_user]").removeAttr('disabled'); - + $("input[name=snmp3_auth_pass]").css({backgroundColor: '#fff'}); $("input[name=snmp3_auth_pass]").removeAttr('disabled'); - + $("#snmp3_privacy_method").css({backgroundColor: '#fff'}); $("#snmp3_privacy_method").removeAttr('disabled'); - + $("input[name=snmp3_privacy_pass]").css({backgroundColor: '#fff'}); $("input[name=snmp3_privacy_pass]").removeAttr('disabled'); - + $("#snmp3_auth_method").css({backgroundColor: '#fff'}); $("#snmp3_auth_method").removeAttr('disabled'); - + $("#snmp3_security_level").css({backgroundColor: '#fff'}); $("#snmp3_security_level").removeAttr('disabled'); - + $("input[name=active_snmp_v3]").val(1); $("input[name=snmp_community]").css({backgroundColor: '#ddd'}); $("input[name=snmp_community]").attr("disabled",true); @@ -525,49 +632,47 @@ $(document).ready (function () { $("input[name=snmp3_auth_user]").val(""); $("input[name=snmp3_auth_user]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_auth_user]").attr("disabled", true); - + $("input[name=snmp3_auth_pass]").val(""); $("input[name=snmp3_auth_pass]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_auth_pass]").attr("disabled", true); - + $("#snmp3_privacy_method").css({backgroundColor: '#ddd'}); $("#snmp3_privacy_method").attr("disabled", true); - + $("input[name=snmp3_privacy_pass]").val(""); $("input[name=snmp3_privacy_pass]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_privacy_pass]").attr("disabled", true); - + $("#snmp3_auth_method").css({backgroundColor: '#ddd'}); $("#snmp3_auth_method").attr("disabled", true); - + $("#snmp3_security_level").css({backgroundColor: '#ddd'}); $("#snmp3_security_level").attr("disabled", true); - + $("input[name=active_snmp_v3]").val(0); - $("input[name=snmp_community]").css({backgroundColor: '#fff'}); - $("input[name=snmp_community]").removeAttr('disabled'); } - + $("#snmp_version").change(function () { if (this.value == "3") { $("input[name=snmp3_auth_user]").css({backgroundColor: '#fff'}); $("input[name=snmp3_auth_user]").removeAttr('disabled'); - + $("input[name=snmp3_auth_pass]").css({backgroundColor: '#fff'}); $("input[name=snmp3_auth_pass]").removeAttr('disabled'); - + $("#snmp3_privacy_method").css({backgroundColor: '#fff'}); $("#snmp3_privacy_method").removeAttr('disabled'); - + $("input[name=snmp3_privacy_pass]").css({backgroundColor: '#fff'}); $("input[name=snmp3_privacy_pass]").removeAttr('disabled'); - + $("#snmp3_auth_method").css({backgroundColor: '#fff'}); $("#snmp3_auth_method").removeAttr('disabled'); - + $("#snmp3_security_level").css({backgroundColor: '#fff'}); $("#snmp3_security_level").removeAttr('disabled'); - + $("input[name=active_snmp_v3]").val(1); $("input[name=snmp_community]").css({backgroundColor: '#ddd'}); $("input[name=snmp_community]").attr("disabled",true); @@ -576,50 +681,50 @@ $(document).ready (function () { $("input[name=snmp3_auth_user]").val(""); $("input[name=snmp3_auth_user]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_auth_user]").attr("disabled", true); - + $("input[name=snmp3_auth_pass]").val(""); $("input[name=snmp3_auth_pass]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_auth_pass]").attr("disabled", true); - + $("#snmp3_privacy_method").css({backgroundColor: '#ddd'}); $("#snmp3_privacy_method").attr("disabled", true); - + $("input[name=snmp3_privacy_pass]").val(""); $("input[name=snmp3_privacy_pass]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_privacy_pass]").attr("disabled", true); - + $("#snmp3_auth_method").css({backgroundColor: '#ddd'}); $("#snmp3_auth_method").attr("disabled", true); - + $("#snmp3_security_level").css({backgroundColor: '#ddd'}); $("#snmp3_security_level").attr("disabled", true); - + $("input[name=active_snmp_v3]").val(0); $("input[name=snmp_community]").css({backgroundColor: '#fff'}); $("input[name=snmp_community]").removeAttr('disabled'); } }); - + $("#type"). change(function () { if ($("#snmp_version").val() == "3") { $("input[name=snmp3_auth_user]").css({backgroundColor: '#fff'}); $("input[name=snmp3_auth_user]").removeAttr('disabled'); - + $("input[name=snmp3_auth_pass]").css({backgroundColor: '#fff'}); $("input[name=snmp3_auth_pass]").removeAttr('disabled'); - + $("#snmp3_privacy_method").css({backgroundColor: '#fff'}); $("#snmp3_privacy_method").removeAttr('disabled'); - + $("input[name=snmp3_privacy_pass]").css({backgroundColor: '#fff'}); $("input[name=snmp3_privacy_pass]").removeAttr('disabled'); - + $("#snmp3_auth_method").css({backgroundColor: '#fff'}); $("#snmp3_auth_method").removeAttr('disabled'); - + $("#snmp3_security_level").css({backgroundColor: '#fff'}); $("#snmp3_security_level").removeAttr('disabled'); - + $("input[name=active_snmp_v3]").val(1); $("input[name=snmp_community]").css({backgroundColor: '#ddd'}); $("input[name=snmp_community]").attr("disabled",true); @@ -628,30 +733,28 @@ $(document).ready (function () { $("input[name=snmp3_auth_user]").val(""); $("input[name=snmp3_auth_user]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_auth_user]").attr("disabled", true); - + $("input[name=snmp3_auth_pass]").val(""); $("input[name=snmp3_auth_pass]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_auth_pass]").attr("disabled", true); - + $("#snmp3_privacy_method").css({backgroundColor: '#ddd'}); $("#snmp3_privacy_method").attr("disabled", true); - + $("input[name=snmp3_privacy_pass]").val(""); $("input[name=snmp3_privacy_pass]").css({backgroundColor: '#ddd'}); $("input[name=snmp3_privacy_pass]").attr("disabled", true); - + $("#snmp3_auth_method").css({backgroundColor: '#ddd'}); $("#snmp3_auth_method").attr("disabled", true); - + $("#snmp3_security_level").css({backgroundColor: '#ddd'}); $("#snmp3_security_level").attr("disabled", true); - + $("input[name=active_snmp_v3]").val(0); - $("input[name=snmp_community]").css({backgroundColor: '#fff'}); - $("input[name=snmp_community]").removeAttr('disabled'); } }); - + $("#snmp_version" ).trigger("change"); }); diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php index 2a55efb1dd..ed46957725 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -77,7 +77,7 @@ $sql = sprintf( 'SELECT id_tipo, descripcion FROM ttipo_modulo WHERE categoria IN (%s) - ORDER BY descripcion', + ORDER BY id_tipo ASC', implode(',', $categories) ); $table->data[1][1] = html_print_select_from_sql( diff --git a/pandora_console/godmode/modules/manage_network_components_form_network.php b/pandora_console/godmode/modules/manage_network_components_form_network.php index 0f39406ce9..addf57e05b 100755 --- a/pandora_console/godmode/modules/manage_network_components_form_network.php +++ b/pandora_console/godmode/modules/manage_network_components_form_network.php @@ -1,17 +1,32 @@ colspan['snmp_2'][1] = 3; +$data[1] = html_print_input_text( + 'snmp_oid', + $snmp_oid, + '', + 30, + 400, + true +); + $data[2] = __('SNMP community'); -$data[3] = html_print_input_text('snmp_community', $snmp_community, '', 15, 60, true); +$data[3] = html_print_input_text( + 'snmp_community', + $snmp_community, + '', + 15, + 60, + true +); push_table_row($data, 'snmp_2'); $data = []; $data[0] = __('Auth user'); -$data[1] = html_print_input_text('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); +$data[1] = html_print_input_text( + 'snmp3_auth_user', + $snmp3_auth_user, + '', + 15, + 60, + true +); $data[2] = __('Auth password'); -$data[3] = html_print_input_password('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); -$data[3] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mncfn', true); +$data[3] = html_print_input_password( + 'snmp3_auth_pass', + $snmp3_auth_pass, + '', + 15, + 60, + true +); +$data[3] .= html_print_input_hidden_extended( + 'active_snmp_v3', + 0, + 'active_snmp_v3_mncfn', + true +); push_table_row($data, 'field_snmpv3_row1'); $data = []; $data[0] = __('Privacy method'); -$data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); +$data[1] = html_print_select( + [ + 'DES' => __('DES'), + 'AES' => __('AES'), + ], + 'snmp3_privacy_method', + $snmp3_privacy_method, + '', + '', + '', + true +); $data[2] = __('Privacy pass'); -$data[3] = html_print_input_password('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true); +$data[3] = html_print_input_password( + 'snmp3_privacy_pass', + $snmp3_privacy_pass, + '', + 15, + 60, + true +); push_table_row($data, 'field_snmpv3_row2'); $data = []; $data[0] = __('Auth method'); -$data[1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true); +$data[1] = html_print_select( + [ + 'MD5' => __('MD5'), + 'SHA' => __('SHA'), + ], + 'snmp3_auth_method', + $snmp3_auth_method, + '', + '', + '', + true +); $data[2] = __('Security level'); $data[3] = html_print_select( [ @@ -110,12 +187,11 @@ $data[1] = html_print_extended_select_for_post_process( false, true ); -$data[2] = $data[3] = ''; +$data[2] = ''; +$data[3] = ''; push_table_row($data, 'field_process'); - - -// Advanced stuff +// Advanced stuff. $data = []; $data[0] = __('TCP send'); $data[1] = html_print_textarea('tcp_send', 2, 65, $tcp_send, '', true); @@ -129,6 +205,64 @@ $data[1] = html_print_textarea('tcp_rcv', 2, 65, $tcp_rcv, '', true); $table->colspan['tcp_receive'][1] = 3; push_table_row($data, 'tcp_receive'); + +$data = []; +$data[0] = __('Command'); +$data[1] = html_print_input_text_extended( + 'command_text', + $command_text, + 'command_text', + '', + 100, + 10000, + $disabledBecauseInPolicy, + '', + $largeClassDisabledBecauseInPolicy, + true +); +$table->colspan['row-cmd-row-1'][1] = 3; +push_table_row($data, 'row-cmd-row-1'); + +require_once $config['homedir'].'/include/class/CredentialStore.class.php'; +$array_credential_identifier = CredentialStore::getKeys(); + +$data[0] = __('Credential identifier'); +$data[1] = html_print_select( + $array_credential_identifier, + 'command_credential_identifier', + $command_credential_identifier, + '', + __('None'), + '', + true, + false, + false, + '', + $disabledBecauseInPolicy +); + +$array_os = [ + 'inherited' => __('Inherited'), + 'linux' => __('Linux'), + 'windows' => __('Windows'), +]; + +$data[2] = __('Target OS'); +$data[3] = html_print_select( + $array_os, + 'command_os', + $command_os, + '', + '', + '', + true, + false, + false, + '', + $disabledBecauseInPolicy +); + +push_table_row($data, 'row-cmd-row-2'); ?> + + '; + } + + + /** + * Loads a welcome window form + * + * @return​ ​string HTML code for form. + * + * @return Function loadWelcomeWindow. + */ + public function loadWelcomeWindow() + { + global $config; + + $form = [ + 'action' => '#', + 'id' => 'welcome_form', + 'onsubmit' => 'this.dialog("close");', + 'class' => 'modal', + ]; + + $inputs = [ + [ + 'wrapper' => 'div', + 'block_id' => 'div_configure_mail', + 'class' => 'content_position', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => 'Set up your Email', + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_create_agent', + 'id' => 'lbl_create_agent', + ], + ], + [ + 'arguments' => [ + 'label' => __(''), + 'type' => 'button', + 'attributes' => 'class="btn_email_conf"', + 'name' => 'btn_email_conf', + 'id' => 'btn_email_conf', + 'script' => 'configureEmail()"', + ], + ], + ], + ],[ + 'wrapper' => 'div', + 'block_id' => 'div_create_agent', + 'class' => 'content_position', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => 'Create an agent', + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_create_agent', + 'id' => 'lbl_create_agent', + ], + ], + [ + 'arguments' => [ + 'label' => __(''), + 'type' => 'button', + 'attributes' => 'class="btn_agent"', + 'name' => 'btn_create_agent', + 'id' => 'btn_create_agent', + 'script' => 'createNewAgent()"', + ], + ], + ], + ], + [ + 'label' => 'Learn to monitor', + 'arguments' => [ + 'class' => 'class="lbl_learn"', + 'name' => 'lbl_learn', + 'id' => 'lbl_learn', + ], + ], + [ + 'wrapper' => 'div', + 'block_id' => 'div_monitor_actions', + 'class' => 'learn_content_position', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => 'Check if an agent is online', + 'arguments' => [ + 'class' => 'second_lbl', + 'name' => 'lbl_check_agent', + 'id' => 'lbl_check_agent', + ], + ], + [ + 'arguments' => [ + 'label' => __(''), + 'type' => 'button', + 'attributes' => 'class="btn_agent_online"', + 'name' => 'btn_check_agent', + 'id' => 'btn_check_agent', + 'script' => 'checkAgentOnline()', + ], + ], + ], + ], + [ + 'wrapper' => 'div', + 'block_id' => 'div_monitor_actions', + 'class' => 'learn_content_position', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => 'Create an alert on a module', + 'arguments' => [ + 'class' => 'second_lbl', + 'name' => 'lbl_create_alert', + 'id' => 'lbl_create_alert', + ], + ], + [ + 'arguments' => [ + 'label' => __(''), + 'type' => 'button', + 'attributes' => 'class="btn_alert_module"', + 'name' => 'btn_create_alert', + 'id' => 'btn_create_alert', + 'script' => 'createAlertModule()', + ], + ], + ], + ], + [ + 'wrapper' => 'div', + 'block_id' => 'div_monitor_actions', + 'class' => 'learn_content_position', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => 'Monitor remote commmands', + 'arguments' => [ + 'class' => 'lbl_monitor_commands', + 'name' => 'lbl_monitor_commands', + 'id' => 'lbl_monitor_commands', + ], + ], + [ + 'arguments' => [ + 'label' => __(''), + 'type' => 'button', + 'attributes' => 'class="btn_remote-command"', + 'name' => 'btn_monitor_commmands', + 'id' => 'btn_monitor_commmands', + 'script' => 'monitorRemoteCommands()', + ], + ], + ], + ], + [ + 'wrapper' => 'div', + 'block_id' => 'div_discover', + 'class' => 'content_position', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => 'Discover hosts and devices in your network', + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_discover_devices', + 'id' => 'lbl_discover_devices', + ], + ], + [ + 'arguments' => [ + 'label' => __(''), + 'type' => 'button', + 'attributes' => 'class="btn_discover"', + 'name' => 'btn_discover_devices', + 'id' => 'btn_discover_devices', + 'script' => 'discoverDevicesNetwork()', + ], + ], + ], + ], + [ + 'wrapper' => 'div', + 'block_id' => 'div_not_working', + 'class' => 'content_position', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => 'If something is not working as expected... Report!', + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_not_working', + 'id' => 'lbl_not_working', + ], + ], + [ + 'arguments' => [ + 'label' => __(''), + 'type' => 'button', + 'attributes' => 'class="btn_is_not_ok"', + 'name' => 'btn_not_working', + 'id' => 'btn_not_working', + 'script' => 'reportIsNotWorking()', + ], + ], + ], + ], + ]; + + $output = $this->printForm( + [ + 'form' => $form, + 'inputs' => $inputs, + ], + true + ); + + $output .= $this->loadJS(); + echo $output; + + // Ajax methods does not continue. + exit(); + } + + + public function loadJS() + { + ob_start(); + ?> + + Date: Mon, 21 Oct 2019 18:36:02 +0200 Subject: [PATCH 12/36] segunda ronda --- pandora_console/general/register.php | 10 +- .../godmode/agentes/configurar_agente.php | 4 + .../godmode/agentes/module_manager_editor.php | 3 + .../NewInstallationWelcomeWindow.class.php | 143 ++++++++++++++---- .../new_installation_welcome_window.css | 39 +++-- 5 files changed, 145 insertions(+), 54 deletions(-) diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index a938e4983d..db92829a2a 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -173,13 +173,9 @@ if (!$config['disabled_newsletter']) { } } -$welcome = !$registration && $initial; -$welcome = true; -if ($welcome && users_is_admin()) { - $welcome = new NewInstallationWelcomeWindow( - 'general/new_installation_welcome_window' - ); - $welcome->run(); +$welcome = !$registration && !$initial; +if ($welcome) { + $welcome = NewInstallationWelcomeWindow::actions_done($welcome); } $newsletter = null; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 55116f940a..1bbf1384c8 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2266,6 +2266,10 @@ if ($updateGIS) { // ----------------------------------- // Load page depending on tab selected // ----------------------------------- +if (!$_SESSION['create_module']) { + $edit_module = true; +} + switch ($tab) { case 'main': include 'agent_manager.php'; diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 13c313892a..feb52a945c 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -321,6 +321,9 @@ if ($id_agent_module) { } else { if (!isset($moduletype)) { $moduletype = (string) get_parameter('moduletype'); + if (!$_SESSION['create_module']) { + $moduletype = 'networkserver'; + } // Clean up specific network modules fields $name = ''; diff --git a/pandora_console/include/class/NewInstallationWelcomeWindow.class.php b/pandora_console/include/class/NewInstallationWelcomeWindow.class.php index 9f4f0202f5..7eab288cc6 100644 --- a/pandora_console/include/class/NewInstallationWelcomeWindow.class.php +++ b/pandora_console/include/class/NewInstallationWelcomeWindow.class.php @@ -108,7 +108,7 @@ class NewInstallationWelcomeWindow extends Wizard { ui_require_css_file('new_installation_welcome_window'); - echo '