From db150470cba153cd69efe10d3397ae39a9a745d5 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 7 Mar 2019 11:09:28 +0100 Subject: [PATCH 1/2] fixed errors in custom net scan Former-commit-id: 15243259cbffa8c639e6412866349357753e1198 --- pandora_console/godmode/menu.php | 6 - .../godmode/servers/manage_recontask.php | 149 +++--- .../godmode/servers/manage_recontask_form.php | 496 +++++++++--------- .../godmode/servers/recon_script.php | 93 ++-- 4 files changed, 393 insertions(+), 351 deletions(-) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index cea127f9e7..ac3154b657 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -225,15 +225,9 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, ' if (check_acl($config['id_user'], 0, 'PM')) { enterprise_hook('ha_cluster'); - $sub['godmode/servers/manage_recontask']['text'] = __('Recon task'); - $sub['godmode/servers/manage_recontask']['id'] = 'Recon task'; - $sub['godmode/servers/plugin']['text'] = __('Plugins'); $sub['godmode/servers/plugin']['id'] = 'Plugins'; - $sub['godmode/servers/recon_script']['text'] = __('Recon script'); - $sub['godmode/servers/recon_script']['id'] = 'Recon script'; - enterprise_hook('export_target_submenu'); enterprise_hook('manage_satellite_submenu'); diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index a76571d54a..ef00231ae7 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -1,51 +1,65 @@ ".html_print_image('images/operation.png', true, ['title' => __('View')]).''; -} + } -$user_groups_w = users_get_groups(false, 'PM', true, false, null, 'id_grupo'); -$user_groups_w = array_keys($user_groups_w); + $user_groups_w = users_get_groups(false, 'PM', true, false, null, 'id_grupo'); + $user_groups_w = array_keys($user_groups_w); -$user_groups_r = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); -$user_groups_r = array_keys($user_groups_r); + $user_groups_r = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); + $user_groups_r = array_keys($user_groups_r); -// Headers -// ui_print_page_header (__('Manage recontask'), "images/gm_servers.png", false, "", true); -ui_print_page_header(__('Manage recontask'), 'images/gm_servers.png', false, '', true, $options); + // Headers + // ui_print_page_header (__('Manage recontask'), "images/gm_servers.png", false, "", true); + ui_print_page_header(__('Manage recontask'), 'images/gm_servers.png', false, '', true, $options); -// -------------------------------- -// DELETE A RECON TASKs -// -------------------------------- -if (isset($_GET['delete'])) { + // -------------------------------- + // DELETE A RECON TASKs + // -------------------------------- + if (isset($_GET['delete'])) { $id = get_parameter_get('delete'); $result = db_process_sql_delete('trecon_task', ['id_rt' => $id]); @@ -55,7 +69,7 @@ if (isset($_GET['delete'])) { } else { ui_print_error_message(__('Error deleting recon task')); } -} else if (isset($_GET['disabled'])) { + } else if (isset($_GET['disabled'])) { $id = get_parameter_get('id'); $disabled = get_parameter_get('disabled'); @@ -70,12 +84,12 @@ if (isset($_GET['delete'])) { } else { ui_print_error_message(__('Error updating recon task')); } -} + } -// -------------------------------- -// GET PARAMETERS IF UPDATE OR CREATE -// -------------------------------- -if ((isset($_GET['update'])) or ((isset($_GET['create'])))) { + // -------------------------------- + // GET PARAMETERS IF UPDATE OR CREATE + // -------------------------------- + if ((isset($_GET['update'])) or ((isset($_GET['create'])))) { $name = get_parameter_post('name'); $network = get_parameter_post('network'); $description = get_parameter_post('description'); @@ -127,12 +141,12 @@ if ((isset($_GET['update'])) or ((isset($_GET['create'])))) { } $macros = io_json_mb_encode($macros); -} + } -// -------------------------------- -// UPDATE A RECON TASK -// -------------------------------- -if (isset($_GET['update'])) { + // -------------------------------- + // UPDATE A RECON TASK + // -------------------------------- + if (isset($_GET['update'])) { $id = get_parameter_get('update'); $values = [ @@ -210,12 +224,12 @@ if (isset($_GET['update'])) { include 'manage_recontask_form.php'; return; } -} + } -// -------------------------------- -// CREATE A RECON TASK -// -------------------------------- -if (isset($_GET['create'])) { + // -------------------------------- + // CREATE A RECON TASK + // -------------------------------- + if (isset($_GET['create'])) { $values = [ 'name' => $name, 'subnet' => $network, @@ -311,28 +325,28 @@ if (isset($_GET['create'])) { include 'manage_recontask_form.php'; return; } -} + } -// -------------------------------- -// SHOW TABLE WITH ALL RECON TASKs -// -------------------------------- -// Pandora Admin must see all columns -if (! check_acl($config['id_user'], 0, 'PM')) { + // -------------------------------- + // SHOW TABLE WITH ALL RECON TASKs + // -------------------------------- + // Pandora Admin must see all columns + if (! check_acl($config['id_user'], 0, 'PM')) { $sql = sprintf( 'SELECT * - FROM trecon_task RT, tusuario_perfil UP - WHERE - UP.id_usuario = "%s" AND UP.id_grupo = RT.id_group', + FROM trecon_task RT, tusuario_perfil UP + WHERE + UP.id_usuario = "%s" AND UP.id_grupo = RT.id_group', $config['id_user'] ); $result = db_get_all_rows_sql($sql); -} else { + } else { $result = db_get_all_rows_in_table('trecon_task'); -} + } -$color = 1; -if ($result !== false) { + $color = 1; + if ($result !== false) { $table = new StdClass(); $table->head = [ __('Name'), @@ -460,12 +474,13 @@ if ($result !== false) { html_print_table($table); unset($table); -} else { + } else { echo '
'.__('There are no recon task configured').'
'; -} + } -echo '
'; -echo '
'; -echo html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true); -echo '
'; -echo '
'; + echo '
'; + echo '
'; + echo html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true); + echo '
'; + echo '
'; +*/ diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index cbbcde8ec7..669de92d3a 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -1,36 +1,51 @@ '; echo __('Warning').': '.__('By default, in Windows, %s only support Standard network sweep, not custom scripts', get_product_name()); echo ''; -} + } -$table = new stdClass(); -$table->id = 'table_recon'; -$table->width = '100%'; -$table->cellspacing = 4; -$table->cellpadding = 4; -$table->class = 'databox filters'; + $table = new stdClass(); + $table->id = 'table_recon'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'databox filters'; -$table->rowclass[3] = 'network_sweep'; -$table->rowclass[5] = 'network_sweep'; -$table->rowclass[7] = 'network_sweep'; -$table->rowclass[8] = 'network_sweep'; -$table->rowclass[11] = 'network_sweep'; -$table->rowclass[12] = 'network_sweep'; -$table->rowclass[18] = 'network_sweep'; -$table->rowclass[19] = 'network_sweep'; -$table->rowclass[20] = 'network_sweep'; -$table->rowclass[21] = 'network_sweep'; -$table->rowclass[22] = 'network_sweep'; -$table->rowclass[23] = 'network_sweep'; -$table->rowclass[24] = 'network_sweep'; -$table->rowclass[25] = 'network_sweep recon_v3'; -$table->rowclass[26] = 'network_sweep recon_v3'; -$table->rowclass[27] = 'network_sweep recon_v3'; -$table->rowclass[28] = 'network_sweep recon_v3'; -$table->rowclass[29] = 'network_sweep recon_v3'; -$table->rowclass[30] = 'network_sweep recon_v3'; + $table->rowclass[3] = 'network_sweep'; + $table->rowclass[5] = 'network_sweep'; + $table->rowclass[7] = 'network_sweep'; + $table->rowclass[8] = 'network_sweep'; + $table->rowclass[11] = 'network_sweep'; + $table->rowclass[12] = 'network_sweep'; + $table->rowclass[18] = 'network_sweep'; + $table->rowclass[19] = 'network_sweep'; + $table->rowclass[20] = 'network_sweep'; + $table->rowclass[21] = 'network_sweep'; + $table->rowclass[22] = 'network_sweep'; + $table->rowclass[23] = 'network_sweep'; + $table->rowclass[24] = 'network_sweep'; + $table->rowclass[25] = 'network_sweep recon_v3'; + $table->rowclass[26] = 'network_sweep recon_v3'; + $table->rowclass[27] = 'network_sweep recon_v3'; + $table->rowclass[28] = 'network_sweep recon_v3'; + $table->rowclass[29] = 'network_sweep recon_v3'; + $table->rowclass[30] = 'network_sweep recon_v3'; -$table->rowclass[6] = 'recon_script'; -$table->rowclass[13] = 'recon_script'; -$table->rowclass[14] = 'recon_script'; -$table->rowclass[15] = 'recon_script'; -$table->rowclass[16] = 'recon_script'; -$table->rowclass[17] = 'recon_script'; -// Name -$table->data[0][0] = ''.__('Task name').''; -$table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); + $table->rowclass[6] = 'recon_script'; + $table->rowclass[13] = 'recon_script'; + $table->rowclass[14] = 'recon_script'; + $table->rowclass[15] = 'recon_script'; + $table->rowclass[16] = 'recon_script'; + $table->rowclass[17] = 'recon_script'; + // Name + $table->data[0][0] = ''.__('Task name').''; + $table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); -// Discovery server -$table->data[1][0] = ''.__('Discovery server').ui_print_help_tip( + // Discovery server + $table->data[1][0] = ''.__('Discovery server').ui_print_help_tip( __('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), true -); + ); -$sql = 'SELECT id_server, name - FROM tserver - WHERE server_type = 3 - ORDER BY name'; -$table->data[1][1] = html_print_select_from_sql($sql, 'id_recon_server', $id_recon_server, '', '', '', true); + $sql = 'SELECT id_server, name + FROM tserver + WHERE server_type = 3 + ORDER BY name'; + $table->data[1][1] = html_print_select_from_sql($sql, 'id_recon_server', $id_recon_server, '', '', '', true); -$fields['network_sweep'] = __('Network sweep'); -if (!$is_windows) { + $fields['network_sweep'] = __('Network sweep'); + if (!$is_windows) { $fields['recon_script'] = __('Custom script'); -} + } -$table->data[2][0] = ''.__('Mode').''; -$table->data[2][1] = html_print_select($fields, 'mode', $mode, '', '', 0, true); + $table->data[2][0] = ''.__('Mode').''; + $table->data[2][1] = html_print_select($fields, 'mode', $mode, '', '', 0, true); -// Network -$table->data[3][0] = ''.__('Network').''; -$table->data[3][0] .= ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true); -$table->data[3][1] = html_print_input_text('network', $network, '', 25, 0, true); + // Network + $table->data[3][0] = ''.__('Network').''; + $table->data[3][0] .= ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true); + $table->data[3][1] = html_print_input_text('network', $network, '', 25, 0, true); -// Interval -$interv_manual = 0; -if ((int) $interval == 0) { + // Interval + $interv_manual = 0; + if ((int) $interval == 0) { $interv_manual = 1; -} + } -$table->data[4][0] = ''.__('Interval'); -$table->data[4][0] .= ui_print_help_tip(__('Manual interval means that it will be executed only On-demand'), true); + $table->data[4][0] = ''.__('Interval'); + $table->data[4][0] .= ui_print_help_tip(__('Manual interval means that it will be executed only On-demand'), true); -$values = [ + $values = [ 0 => __('Defined'), 1 => __('Manual'), -]; -$table->data[4][1] = html_print_select($values, 'interval_manual_defined', $interv_manual, '', '', '', true); + ]; + $table->data[4][1] = html_print_select($values, 'interval_manual_defined', $interv_manual, '', '', '', true); -$table->data[4][1] .= ''; -$table->data[4][1] .= html_print_extended_select_for_time('interval', $interval, '', '', '0', false, true, false, false); -$table->data[4][1] .= ui_print_help_tip(__('The minimum recomended interval for Recon Task is 5 minutes'), true); -$table->data[4][1] .= ''; + $table->data[4][1] .= ''; + $table->data[4][1] .= html_print_extended_select_for_time('interval', $interval, '', '', '0', false, true, false, false); + $table->data[4][1] .= ui_print_help_tip(__('The minimum recomended interval for Recon Task is 5 minutes'), true); + $table->data[4][1] .= ''; -// Module template -$table->data[5][0] = ''.__('Module template').''; + // Module template + $table->data[5][0] = ''.__('Module template').''; -$sql = 'SELECT id_np, name - FROM tnetwork_profile - ORDER BY name'; -$table->data[5][1] = html_print_select_from_sql($sql, 'id_network_profile', $id_network_profile, '', __('None'), 0, true); + $sql = 'SELECT id_np, name + FROM tnetwork_profile + ORDER BY name'; + $table->data[5][1] = html_print_select_from_sql($sql, 'id_network_profile', $id_network_profile, '', __('None'), 0, true); -// Recon script -$data[1] = ''; -$table->data[6][0] = ''.__('Recon script').''; + // Recon script + $data[1] = ''; + $table->data[6][0] = ''.__('Recon script').''; -$sql = "SELECT id_recon_script, name - FROM trecon_script - WHERE name <> 'IPAM Recon' - ORDER BY name"; -if ($name_script != 'IPAM Recon') { + $sql = "SELECT id_recon_script, name + FROM trecon_script + WHERE name <> 'IPAM Recon' + ORDER BY name"; + if ($name_script != 'IPAM Recon') { $table->data[6][1] = html_print_select_from_sql($sql, 'id_recon_script', $id_recon_script, '', '', '', true); $table->data[6][1] .= "'; $table->data[6][1] .= $data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); -} else { + } else { $table->data[6][1] = 'IPAM Recon'; -} + } -// OS -$table->data[7][0] = ''.__('OS').''; + // OS + $table->data[7][0] = ''.__('OS').''; -$sql = 'SELECT id_os, name - FROM tconfig_os - ORDER BY name'; -$table->data[7][1] = html_print_select_from_sql($sql, 'id_os', $id_os, '', __('Any'), -1, true); + $sql = 'SELECT id_os, name + FROM tconfig_os + ORDER BY name'; + $table->data[7][1] = html_print_select_from_sql($sql, 'id_os', $id_os, '', __('Any'), -1, true); -// Recon ports -$table->data[8][0] = ''.__('Ports').''; -$table->data[8][1] = html_print_input_text('recon_ports', $recon_ports, '', 25, 0, true); -$table->data[8][1] .= ui_print_help_tip( + // Recon ports + $table->data[8][0] = ''.__('Ports').''; + $table->data[8][1] = html_print_input_text('recon_ports', $recon_ports, '', 25, 0, true); + $table->data[8][1] .= ui_print_help_tip( __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), true -); + ); -// Group -$table->data[9][0] = ''.__('Group'); -$groups = users_get_groups(false, 'PM', false); -$table->data[9][1] = html_print_select_groups(false, 'PM', false, 'id_group', $id_group, '', '', 0, true); + // Group + $table->data[9][0] = ''.__('Group'); + $groups = users_get_groups(false, 'PM', false); + $table->data[9][1] = html_print_select_groups(false, 'PM', false, 'id_group', $id_group, '', '', 0, true); -// Incident -$values = [ + // Incident + $values = [ 0 => __('No'), 1 => __('Yes'), -]; -$table->data[10][0] = ''.__('Incident'); -$table->data[10][1] = html_print_select( + ]; + $table->data[10][0] = ''.__('Incident'); + $table->data[10][1] = html_print_select( $values, 'create_incident', $create_incident, @@ -356,27 +371,27 @@ $table->data[10][1] = html_print_select( '', '', true -).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true); + ).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true); -// snmp_enabled -$table->data[11][0] = ''.__('SNMP enabled'); -$table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true); + // snmp_enabled + $table->data[11][0] = ''.__('SNMP enabled'); + $table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true); -// SNMP default community -$table->data[12][0] = ''.__('SNMP Default community'); -$table->data[12][0] .= ui_print_help_tip(__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true); -$table->data[12][1] = html_print_input_text('snmp_community', $snmp_community, '', 35, 0, true); + // SNMP default community + $table->data[12][0] = ''.__('SNMP Default community'); + $table->data[12][0] .= ui_print_help_tip(__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true); + $table->data[12][1] = html_print_input_text('snmp_community', $snmp_community, '', 35, 0, true); -// SNMP version -$snmp_versions['1'] = 'v. 1'; -$snmp_versions['2'] = 'v. 2'; -$snmp_versions['2c'] = 'v. 2c'; -$snmp_versions['3'] = 'v. 3'; -$table->data[24][0] = ''._('SNMP version'); -$table->data[24][1] = html_print_select($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true); + // SNMP version + $snmp_versions['1'] = 'v. 1'; + $snmp_versions['2'] = 'v. 2'; + $snmp_versions['2c'] = 'v. 2c'; + $snmp_versions['3'] = 'v. 3'; + $table->data[24][0] = ''._('SNMP version'); + $table->data[24][1] = html_print_select($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true); -$table->data[25][0] = ''.__('Auth user'); -$table->data[25][1] = html_print_input_text( + $table->data[25][0] = ''.__('Auth user'); + $table->data[25][1] = html_print_input_text( 'snmp_auth_user', $snmp3_auth_user, '', @@ -387,9 +402,9 @@ $table->data[25][1] = html_print_input_text( false, '', '' -); -$table->data[26][0] = ''.__('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); -$table->data[26][1] = html_print_input_password( + ); + $table->data[26][0] = ''.__('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); + $table->data[26][1] = html_print_input_password( 'snmp_auth_pass', $snmp3_auth_pass, '', @@ -399,13 +414,13 @@ $table->data[26][1] = html_print_input_password( '', false, '' -); -$table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true); + ); + $table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true); -$table->data[27][0] = ''.__('Privacy method'); -$table->data[27][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', ''); -$table->data[28][0] = ''.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); -$table->data[28][1] = html_print_input_password( + $table->data[27][0] = ''.__('Privacy method'); + $table->data[27][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', ''); + $table->data[28][0] = ''.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); + $table->data[28][1] = html_print_input_password( 'snmp_privacy_pass', $snmp3_privacy_pass, '', @@ -415,11 +430,11 @@ $table->data[28][1] = html_print_input_password( '', false, '' -); -$table->data[29][0] = ''.__('Auth method'); -$table->data[29][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', ''); -$table->data[30][0] = ''.__('Security level'); -$table->data[30][1] = html_print_select( + ); + $table->data[29][0] = ''.__('Auth method'); + $table->data[29][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', ''); + $table->data[30][0] = ''.__('Security level'); + $table->data[30][1] = html_print_select( [ 'noAuthNoPriv' => __('Not auth and not privacy method'), 'authNoPriv' => __('Auth and not privacy method'), @@ -435,25 +450,25 @@ $table->data[30][1] = html_print_select( false, '', '' -); + ); -// Explanation -$explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); + // Explanation + $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); -$table->data[13][0] = ''.__('Explanation').''; -$table->data[13][1] = "'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); + $table->data[13][0] = ''.__('Explanation').''; + $table->data[13][1] = "'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); -// A hidden "model row" to clone it from javascript to add fields dynamicaly -$data = []; -$data[0] = 'macro_desc'; -$data[0] .= ui_print_help_tip('macro_help', true); -$data[1] = html_print_input_text('macro_name', 'macro_value', '', 100, 255, true); -$table->colspan['macro_field'][1] = 3; -$table->rowstyle['macro_field'] = 'display:none'; -$table->data['macro_field'] = $data; + // A hidden "model row" to clone it from javascript to add fields dynamicaly + $data = []; + $data[0] = 'macro_desc'; + $data[0] .= ui_print_help_tip('macro_help', true); + $data[1] = html_print_input_text('macro_name', 'macro_value', '', 100, 255, true); + $table->colspan['macro_field'][1] = 3; + $table->rowstyle['macro_field'] = 'display:none'; + $table->data['macro_field'] = $data; -// If there are $macros, we create the form fields -if (!empty($macros)) { + // If there are $macros, we create the form fields + if (!empty($macros)) { $macros = json_decode($macros, true); foreach ($macros as $k => $m) { @@ -474,84 +489,84 @@ if (!empty($macros)) { $table->data['macro'.$m['macro']] = $data; } -} + } -// Comments -$table->data[18][0] = ''.__('Comments'); -$table->data[18][1] = html_print_input_text('description', $description, '', 45, 0, true); + // Comments + $table->data[18][0] = ''.__('Comments'); + $table->data[18][1] = html_print_input_text('description', $description, '', 45, 0, true); -// OS detection -$table->data[19][0] = ''.__('OS detection'); -$table->data[19][1] = html_print_checkbox('os_detect', 1, $os_detect, true); + // OS detection + $table->data[19][0] = ''.__('OS detection'); + $table->data[19][1] = html_print_checkbox('os_detect', 1, $os_detect, true); -// Name resolution -$table->data[20][0] = ''.__('Name resolution'); -$table->data[20][1] = html_print_checkbox('resolve_names', 1, $resolve_names, true); + // Name resolution + $table->data[20][0] = ''.__('Name resolution'); + $table->data[20][1] = html_print_checkbox('resolve_names', 1, $resolve_names, true); -// Parent detection -$table->data[21][0] = ''.__('Parent detection'); -$table->data[21][1] = html_print_checkbox('parent_detection', 1, $parent_detection, true); + // Parent detection + $table->data[21][0] = ''.__('Parent detection'); + $table->data[21][1] = html_print_checkbox('parent_detection', 1, $parent_detection, true); -// Parent recursion -$table->data[22][0] = ''.__('Parent recursion'); -$table->data[22][1] = html_print_input_text('parent_recursion', $parent_recursion, '', 5, 0, true).ui_print_help_tip(__('Maximum number of parent hosts that will be created if parent detection is enabled.'), true); + // Parent recursion + $table->data[22][0] = ''.__('Parent recursion'); + $table->data[22][1] = html_print_input_text('parent_recursion', $parent_recursion, '', 5, 0, true).ui_print_help_tip(__('Maximum number of parent hosts that will be created if parent detection is enabled.'), true); -// vlan_enabled -$table->data[23][0] = ''.__('Vlan enabled'); -$table->data[23][1] = html_print_checkbox('vlan_enabled', 1, $vlan_enabled, true); + // vlan_enabled + $table->data[23][0] = ''.__('Vlan enabled'); + $table->data[23][1] = html_print_checkbox('vlan_enabled', 1, $vlan_enabled, true); -// Alias as name -// NOTE: The 7.0NG Recon Server will not generate random names, since IP -// address collisions could have other consequences. -// $table->data[22][0] = "".__('Alias as Name'); -// $table->data[22][1] = html_print_checkbox ('alias_as_name', 1, $alias_as_name, true); -// Different Form url if it's a create or if it's a update form -echo '
'; -html_print_table($table); -echo '
'; + // Alias as name + // NOTE: The 7.0NG Recon Server will not generate random names, since IP + // address collisions could have other consequences. + // $table->data[22][0] = "".__('Alias as Name'); + // $table->data[22][1] = html_print_checkbox ('alias_as_name', 1, $alias_as_name, true); + // Different Form url if it's a create or if it's a update form + echo ''; + html_print_table($table); + echo '
'; -if ($id_rt != -1) { + if ($id_rt != -1) { if ($name_script != 'IPAM Recon') { html_print_submit_button(__('Update'), 'crt', false, 'class="sub upd"'); } -} else { + } else { html_print_submit_button(__('Add'), 'crt', false, 'class="sub wand"'); -} + } -echo '
'; + echo '
'; -echo ''; + echo ''; -ui_require_javascript_file('pandora_modules'); + ui_require_javascript_file('pandora_modules'); -?> + ?> - + +*/ diff --git a/pandora_console/godmode/servers/recon_script.php b/pandora_console/godmode/servers/recon_script.php index b24c2a59e2..77b574d5e7 100644 --- a/pandora_console/godmode/servers/recon_script.php +++ b/pandora_console/godmode/servers/recon_script.php @@ -1,17 +1,33 @@ '; -} else { + } else { ui_print_page_header(__('Recon scripts registered on %s', get_product_name()), 'images/gm_servers.png', false, '', true); // Update reconscript @@ -264,12 +280,12 @@ if (($create != '') or ($view != '')) { $macros = io_json_mb_encode($macros); - $sql_update = "UPDATE trecon_script SET - name = '$reconscript_name', - description = '$reconscript_description', - script = '$reconscript_script', - macros = '$macros' - WHERE id_recon_script = $id_recon_script"; + $sql_update = "UPDATE trecon_script SET + name = '$reconscript_name', + description = '$reconscript_description', + script = '$reconscript_script', + macros = '$macros' + WHERE id_recon_script = $id_recon_script"; $result = false; if ($reconscript_name != '' && $reconscript_script != '') { $result = db_process_sql($sql_update); @@ -396,6 +412,7 @@ if (($create != '') or ($view != '')) { echo "
"; echo ""; echo ''; -} + } -ui_require_javascript_file('pandora_modules'); + ui_require_javascript_file('pandora_modules'); +*/ From 560c6090a41dcb4eb6985d4fd1b64468905ad30c Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 7 Mar 2019 11:13:44 +0100 Subject: [PATCH 2/2] deprecated files Former-commit-id: e5c9fb8f58ee78207514d045b478f5d534d86f89 --- .../godmode/servers/manage_recontask.php | 463 +----------- .../godmode/servers/manage_recontask_form.php | 665 +----------------- .../godmode/servers/recon_script.php | 395 +---------- 3 files changed, 6 insertions(+), 1517 deletions(-) diff --git a/pandora_console/godmode/servers/manage_recontask.php b/pandora_console/godmode/servers/manage_recontask.php index ef00231ae7..aaf52ea218 100644 --- a/pandora_console/godmode/servers/manage_recontask.php +++ b/pandora_console/godmode/servers/manage_recontask.php @@ -2,9 +2,9 @@ /** * Deprectated. * - * @category Extensions + * @category Deprectated * @package Pandora FMS - * @subpackage VMware + * @subpackage Recion task script * @version 1.0.0 * @license See below * @@ -25,462 +25,3 @@ * GNU General Public License for more details. * ============================================================================ */ -/* - global $config; - - check_login(); - - if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access Recon Task Management' - ); - include 'general/noaccess.php'; - exit; - } - - require_once $config['homedir'].'/include/functions_network_profiles.php'; - - if (check_acl($config['id_user'], 0, 'AW')) { - $options[]['text'] = "".html_print_image('images/operation.png', true, ['title' => __('View')]).''; - } - - $user_groups_w = users_get_groups(false, 'PM', true, false, null, 'id_grupo'); - $user_groups_w = array_keys($user_groups_w); - - $user_groups_r = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); - $user_groups_r = array_keys($user_groups_r); - - // Headers - // ui_print_page_header (__('Manage recontask'), "images/gm_servers.png", false, "", true); - ui_print_page_header(__('Manage recontask'), 'images/gm_servers.png', false, '', true, $options); - - - // -------------------------------- - // DELETE A RECON TASKs - // -------------------------------- - if (isset($_GET['delete'])) { - $id = get_parameter_get('delete'); - - $result = db_process_sql_delete('trecon_task', ['id_rt' => $id]); - - if ($result !== false) { - ui_print_success_message(__('Successfully deleted recon task')); - } else { - ui_print_error_message(__('Error deleting recon task')); - } - } else if (isset($_GET['disabled'])) { - $id = get_parameter_get('id'); - $disabled = get_parameter_get('disabled'); - - $result = db_process_sql_update('trecon_task', ['disabled' => $disabled], ['id_rt' => $id]); - - if ($result !== false) { - ui_print_success_message(__('Successfully updated recon task')); - // If the action is enabled, we force recon_task to be queued asap - if ($disabled == 0) { - servers_force_recon_task($id); - } - } else { - ui_print_error_message(__('Error updating recon task')); - } - } - - // -------------------------------- - // GET PARAMETERS IF UPDATE OR CREATE - // -------------------------------- - if ((isset($_GET['update'])) or ((isset($_GET['create'])))) { - $name = get_parameter_post('name'); - $network = get_parameter_post('network'); - $description = get_parameter_post('description'); - $id_recon_server = get_parameter_post('id_recon_server'); - $interval = get_parameter_post('interval'); - $id_group = get_parameter_post('id_group'); - $create_incident = get_parameter_post('create_incident'); - $id_network_profile = get_parameter_post('id_network_profile'); - $recon_ports = get_parameter_post('recon_ports', ''); - $id_os = get_parameter_post('id_os', 10); - $snmp_community = get_parameter_post('snmp_community', 'public'); - $id_recon_script = get_parameter('id_recon_script', 0); - $mode = get_parameter('mode', ''); - $field1 = get_parameter('_field1_', ''); - $field2 = get_parameter('_field2_', ''); - $field3 = get_parameter('_field3_', ''); - $field4 = get_parameter('_field4_', ''); - $snmp_version = get_parameter_post('snmp_version'); - $snmp3_auth_user = get_parameter_post('snmp_auth_user'); - $snmp3_auth_pass = get_parameter_post('snmp_auth_pass'); - $snmp3_privacy_method = get_parameter_post('snmp_privacy_method'); - $snmp3_privacy_pass = get_parameter_post('snmp_privacy_pass'); - $snmp3_auth_method = get_parameter_post('snmp_auth_method'); - $snmp3_security_level = get_parameter_post('snmp_security_level'); - - - if ($mode == 'network_sweep') { - $id_recon_script = 0; - } else { - $id_network_profile = 0; - } - - $os_detect = (int) get_parameter('os_detect', 0); - $resolve_names = (int) get_parameter('resolve_names', 0); - $parent_detection = (int) get_parameter('parent_detection', 0); - $parent_recursion = (int) get_parameter('parent_recursion', 1); - $alias_as_name = (int) get_parameter('alias_as_name', 0); - $snmp_enabled = (int) get_parameter('snmp_enabled', 0); - $vlan_enabled = (int) get_parameter('vlan_enabled', 0); - // Get macros - $macros = (string) get_parameter('macros'); - - if (!empty($macros)) { - $macros = json_decode(base64_decode($macros), true); - - foreach ($macros as $k => $m) { - $macros[$k]['value'] = get_parameter($m['macro'], ''); - } - } - - $macros = io_json_mb_encode($macros); - } - - // -------------------------------- - // UPDATE A RECON TASK - // -------------------------------- - if (isset($_GET['update'])) { - $id = get_parameter_get('update'); - - $values = [ - 'snmp_community' => $snmp_community, - 'id_os' => $id_os, - 'name' => $name, - 'subnet' => $network, - 'description' => $description, - 'id_recon_server' => $id_recon_server, - 'create_incident' => $create_incident, - 'id_group' => $id_group, - 'interval_sweep' => $interval, - 'id_network_profile' => $id_network_profile, - 'recon_ports' => $recon_ports, - 'id_recon_script' => $id_recon_script, - 'field1' => $field1, - 'field2' => $field2, - 'field3' => $field3, - 'field4' => $field4, - 'os_detect' => $os_detect, - 'resolve_names' => $resolve_names, - 'parent_detection' => $parent_detection, - 'parent_recursion' => $parent_recursion, - 'macros' => $macros, - 'alias_as_name' => $alias_as_name, - 'snmp_enabled' => $snmp_enabled, - 'vlan_enabled' => $vlan_enabled, - 'snmp_version' => $snmp_version, - ]; - - $values_v3 = [ - 'snmp_auth_user' => $snmp3_auth_user, - 'snmp_auth_pass' => $snmp3_auth_pass, - 'snmp_privacy_method' => $snmp3_privacy_method, - 'snmp_privacy_pass' => $snmp3_privacy_pass, - 'snmp_auth_method' => $snmp3_auth_method, - 'snmp_security_level' => $snmp3_security_level, - ]; - if ($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c') { - $values_v3 = [ - 'snmp_auth_user' => '', - 'snmp_auth_pass' => '', - 'snmp_privacy_method' => '', - 'snmp_privacy_pass' => '', - 'snmp_auth_method' => '', - 'snmp_security_level' => '', - ]; - } - - $values = array_merge($values, $values_v3); - - $where = ['id_rt' => $id]; - - $reason = ''; - if ($name != '') { - if (empty($id_recon_script)) { - if (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network)) { - $reason = __('Wrong format in Subnet field'); - $result = false; - } else { - $result = db_process_sql_update('trecon_task', $values, $where); - } - } else { - $result = db_process_sql_update('trecon_task', $values, $where); - } - } else { - $result = false; - } - - if ($result !== false) { - ui_print_success_message(__('Successfully updated recon task')); - } else { - ui_print_error_message(__('Error updating recon task')); - echo $reason; - include 'manage_recontask_form.php'; - return; - } - } - - // -------------------------------- - // CREATE A RECON TASK - // -------------------------------- - if (isset($_GET['create'])) { - $values = [ - 'name' => $name, - 'subnet' => $network, - 'description' => $description, - 'id_recon_server' => $id_recon_server, - 'create_incident' => $create_incident, - 'id_group' => $id_group, - 'id_network_profile' => $id_network_profile, - 'interval_sweep' => $interval, - 'id_os' => $id_os, - 'recon_ports' => $recon_ports, - 'snmp_community' => $snmp_community, - 'id_recon_script' => $id_recon_script, - 'field1' => $field1, - 'field2' => $field2, - 'field3' => $field3, - 'field4' => $field4, - 'os_detect' => $os_detect, - 'resolve_names' => $resolve_names, - 'parent_detection' => $parent_detection, - 'parent_recursion' => $parent_recursion, - 'macros' => $macros, - 'alias_as_name' => $alias_as_name, - 'snmp_enabled' => $snmp_enabled, - 'vlan_enabled' => $vlan_enabled, - 'snmp_version' => $snmp_version, - ]; - - $values_v3 = [ - 'snmp_auth_user' => $snmp3_auth_user, - 'snmp_auth_pass' => $snmp3_auth_pass, - 'snmp_privacy_method' => $snmp3_privacy_method, - 'snmp_privacy_pass' => $snmp3_privacy_pass, - 'snmp_auth_method' => $snmp3_auth_method, - 'snmp_security_level' => $snmp3_security_level, - ]; - if ($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c') { - $values_v3 = [ - 'snmp_auth_user' => '', - 'snmp_auth_pass' => '', - 'snmp_privacy_method' => '', - 'snmp_privacy_pass' => '', - 'snmp_auth_method' => '', - 'snmp_security_level' => '', - ]; - } - - if ($values['snmp_version'] == '3') { - $values['vlan_enabled'] = 0; - } - - $values = array_merge($values, $values_v3); - - $name = io_safe_output($name); - $name = trim($name, ' '); - $name = io_safe_input($name); - $reason = ''; - - if ($name != '') { - $name_exists = (bool) db_get_value('name', 'trecon_task', 'name', $name); - - if (empty($id_recon_script)) { - if ($name_exists && (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network))) { - $reason = __('Recon-task name already exists and incorrect format in Subnet field'); - $result = false; - } else if (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network)) { - $reason = __('Wrong format in Subnet field'); - $result = false; - } else if ($name_exists) { - $reason = __('Recon-task name already exists'); - $result = false; - } else { - $result = db_process_sql_insert('trecon_task', $values); - } - } else { - if ($name_exists) { - $reason = __('Recon-task name already exists'); - $result = false; - } else { - $result = db_process_sql_insert('trecon_task', $values); - } - } - } else { - $reason = 'The field "Task name" is empty'; - $result = false; - } - - if ($result !== false) { - ui_print_success_message(__('Successfully created recon task')); - } else { - ui_print_error_message(__('Error creating recon task')); - echo $reason; - include 'manage_recontask_form.php'; - return; - } - } - - // -------------------------------- - // SHOW TABLE WITH ALL RECON TASKs - // -------------------------------- - // Pandora Admin must see all columns - if (! check_acl($config['id_user'], 0, 'PM')) { - $sql = sprintf( - 'SELECT * - FROM trecon_task RT, tusuario_perfil UP - WHERE - UP.id_usuario = "%s" AND UP.id_grupo = RT.id_group', - $config['id_user'] - ); - - $result = db_get_all_rows_sql($sql); - } else { - $result = db_get_all_rows_in_table('trecon_task'); - } - - $color = 1; - if ($result !== false) { - $table = new StdClass(); - $table->head = [ - __('Name'), - __('Network'), - __('Mode'), - __('Group'), - __('SNMP Version'), - __('Incident'), - __('OS'), - __('Interval'), - __('Ports'), - __('Action'), - ]; - $table->align = [ - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - ]; - $table->width = '100%'; - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->class = 'databox data'; - $table->data = []; - - $table->style[8] = 'text-align: left;'; - $table->size[8] = '15%'; - - foreach ($result as $row) { - if (in_array($row['id_group'], $user_groups_r)) { - $data = []; - $data[0] = $row['name']; - if ($row['id_recon_script'] == 0) { - $data[1] = $row['subnet']; - } else { - $data[1] = '-'; - } - - - if ($row['id_recon_script'] == 0) { - // Network recon task - $data[2] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'  '; - $data[2] .= network_profiles_get_name($row['id_network_profile']); - $mode_name = ''; - } else { - // APP recon task - $data[2] = html_print_image('images/plugin.png', true).'  '; - $mode_name = db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $row['id_recon_script'])); - $data[2] .= $mode_name; - } - - - // GROUP - if ($row['id_recon_script'] == 0) { - $data[3] = ui_print_group_icon($row['id_group'], true); - } else { - $data[3] = '-'; - } - - // SNMP VERSION - if ($row['snmp_version'] == '1') { - $data[4] = 'v. 1'; - } else if ($row['snmp_version'] == '2') { - $data[4] = 'v. 2'; - } else if ($row['snmp_version'] == '2c') { - $data[4] = 'v. 2c'; - } else if ($row['snmp_version'] == '3') { - $data[4] = 'v. 3'; - } - - - - // INCIDENT - $data[5] = (($row['create_incident'] == 1) ? __('Yes') : __('No')); - - // OS - if ($row['id_recon_script'] == 0) { - $data[6] = (($row['id_os'] > 0) ? ui_print_os_icon($row['id_os'], false, true) : __('Any')); - } else { - $data[6] = '-'; - } - - // INTERVAL - if ($row['interval_sweep'] == 0) { - $data[7] = __('Manual'); - } else { - $data[7] = human_time_description_raw($row['interval_sweep']); - } - - // PORTS - if ($row['id_recon_script'] == 0) { - $data[8] = substr($row['recon_ports'], 0, 15); - } else { - $data[8] = '-'; - } - - // ACTION - $task_group = $row['id_group']; - - if (in_array($task_group, $user_groups_w)) { - $data[9] = ''.html_print_image('images/eye.png', true).''; - $data[9] .= ''.html_print_image('images/cross.png', true, ['border' => '0']).''; - if ($mode_name != 'IPAM Recon') { - $data[9] .= ''.html_print_image('images/config.png', true).''; - } else { - $sql_ipam = 'select id from tipam_network where id_recon_task ='.$row['id_rt']; - $id_recon_ipam = db_get_sql($sql_ipam); - $data[9] .= ''.html_print_image('images/config.png', true).''; - } - - if ($row['disabled'] == 0) { - $data[9] .= ''.html_print_image('images/lightbulb.png', true).''; - } else { - $data[9] .= ''.html_print_image('images/lightbulb_off.png', true).''; - } - } - - $table->data[] = $data; - } - } - - html_print_table($table); - unset($table); - } else { - echo '
'.__('There are no recon task configured').'
'; - } - - echo '
'; - echo ''; - echo html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true); - echo ''; - echo '
'; -*/ diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index 669de92d3a..cf95cc76e6 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -2,9 +2,9 @@ /** * Deprectated. * - * @category Extensions + * @category deprecated * @package Pandora FMS - * @subpackage VMware + * @subpackage recon task * @version 1.0.0 * @license See below * @@ -25,664 +25,3 @@ * GNU General Public License for more details. * ============================================================================ */ - -/* - global $config; - - check_login(); - - if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access Agent Management' - ); - include 'general/noaccess.php'; - return; - } - - require_once $config['homedir'].'/include/functions_users.php'; - - $user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); - $user_groups = array_keys($user_groups); - - if (is_ajax()) { - $get_explanation = (bool) get_parameter('get_explanation', 0); - - if ($get_explanation) { - $id = (int) get_parameter('id', 0); - - $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id); - - echo io_safe_output($explanation); - - return; - } - - $get_recon_script_macros = get_parameter('get_recon_script_macros'); - if ($get_recon_script_macros) { - $id_recon_script = (int) get_parameter('id'); - $id_recon_task = (int) get_parameter('id_rt'); - - if (!empty($id_recon_task) && empty($id_recon_script)) { - $recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task); - } else if (!empty($id_recon_task)) { - $recon_task_id_rs = (int) db_get_value('id_recon_script', 'trecon_task', 'id_rt', $id_recon_task); - - if ($id_recon_script == $recon_task_id_rs) { - $recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task); - } else { - $recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script); - } - } else if (!empty($id_recon_script)) { - $recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script); - } else { - $recon_script_macros = []; - } - - $macros = []; - $macros['base64'] = base64_encode($recon_script_macros); - $macros['array'] = json_decode($recon_script_macros, true); - - echo io_json_mb_encode($macros); - return; - } - - return; - } - - // Edit mode - if (isset($_GET['update']) || (isset($_GET['upd']))) { - $update_recon = true; - if (isset($_GET['upd'])) { - if ($_GET['upd'] != 'update') { - $update_recon = false; - } else { - $id_rt = get_parameter('upd'); - } - } - - if ($update_recon) { - if (!isset($id_rt)) { - $id_rt = (int) get_parameter_get('update'); - } - - $row = db_get_row('trecon_task', 'id_rt', $id_rt); - $name = $row['name']; - $network = $row['subnet']; - $id_recon_server = $row['id_recon_server']; - $description = $row['description']; - $interval = $row['interval_sweep']; - $id_group = $row['id_group']; - $create_incident = $row['create_incident']; - $id_network_profile = $row['id_network_profile']; - $id_os = $row['id_os']; - $recon_ports = $row['recon_ports']; - $snmp_community = $row['snmp_community']; - $snmp_version = $row['snmp_version']; - $snmp3_auth_user = $row['snmp_auth_user']; - $snmp3_auth_pass = $row['snmp_auth_pass']; - $snmp3_privacy_method = $row['snmp_privacy_method']; - $snmp3_privacy_pass = $row['snmp_privacy_pass']; - $snmp3_auth_method = $row['snmp_auth_method']; - $snmp3_security_level = $row['snmp_security_level']; - $id_recon_script = $row['id_recon_script']; - $field1 = $row['field1']; - $field2 = $row['field2']; - $field3 = $row['field3']; - $field4 = $row['field4']; - if ($id_recon_script == 0) { - $mode = 'network_sweep'; - } else { - $mode = 'recon_script'; - } - - $os_detect = $row['os_detect']; - $resolve_names = $row['resolve_names']; - $os_detect = $row['os_detect']; - $parent_detection = $row['parent_detection']; - $parent_recursion = $row['parent_recursion']; - $macros = $row['macros']; - $alias_as_name = $row['alias_as_name']; - $snmp_enabled = $row['snmp_enabled']; - $vlan_enabled = $row['vlan_enabled']; - - $name_script = db_get_value( - 'name', - 'trecon_script', - 'id_recon_script', - $id_recon_script - ); - - if (! in_array($id_group, $user_groups)) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access Recon Task Management' - ); - include 'general/noaccess.php'; - return; - } - } - } else if (isset($_GET['create']) || isset($_GET['crt'])) { - $create_recon = true; - if (isset($_GET['crt'])) { - if ($_GET['crt'] != 'Create') { - $create_recon = false; - } - } - - if ($create_recon) { - $id_rt = -1; - $name = get_parameter('name'); - $network = get_parameter('network'); - $description = get_parameter('description'); - $id_recon_server = 0; - $interval = 0; - $id_group = 0; - $create_incident = 1; - $snmp_community = 'public'; - $snmp3_auth_user = ''; - $snmp3_auth_pass = ''; - $snmp_version = 1; - $snmp3_privacy_method = ''; - $snmp3_privacy_pass = ''; - $snmp3_auth_method = ''; - $snmp3_security_level = ''; - $id_network_profile = 0; - $id_os = -1; - // Any - $recon_ports = ''; - // Any - $field1 = ''; - $field2 = ''; - $field3 = ''; - $field4 = ''; - $id_recon_script = 0; - $mode = 'network_sweep'; - $os_detect = 0; - $resolve_names = 0; - $parent_detection = 1; - $parent_recursion = 5; - $macros = ''; - $alias_as_name = 0; - $snmp_enabled = 0; - $vlan_enabled = 0; - } - - $modify = false; - if (($name != '') || ($network != '')) { - $modify = true; - } - } - - if (!$modify) { - // Headers - ui_print_page_header(__('Manage recontask'), '', false, 'recontask', true); - } - - $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; - if ($is_windows) { - echo '
'; - echo __('Warning').': '.__('By default, in Windows, %s only support Standard network sweep, not custom scripts', get_product_name()); - echo '
'; - } - - $table = new stdClass(); - $table->id = 'table_recon'; - $table->width = '100%'; - $table->cellspacing = 4; - $table->cellpadding = 4; - $table->class = 'databox filters'; - - $table->rowclass[3] = 'network_sweep'; - $table->rowclass[5] = 'network_sweep'; - $table->rowclass[7] = 'network_sweep'; - $table->rowclass[8] = 'network_sweep'; - $table->rowclass[11] = 'network_sweep'; - $table->rowclass[12] = 'network_sweep'; - $table->rowclass[18] = 'network_sweep'; - $table->rowclass[19] = 'network_sweep'; - $table->rowclass[20] = 'network_sweep'; - $table->rowclass[21] = 'network_sweep'; - $table->rowclass[22] = 'network_sweep'; - $table->rowclass[23] = 'network_sweep'; - $table->rowclass[24] = 'network_sweep'; - $table->rowclass[25] = 'network_sweep recon_v3'; - $table->rowclass[26] = 'network_sweep recon_v3'; - $table->rowclass[27] = 'network_sweep recon_v3'; - $table->rowclass[28] = 'network_sweep recon_v3'; - $table->rowclass[29] = 'network_sweep recon_v3'; - $table->rowclass[30] = 'network_sweep recon_v3'; - - $table->rowclass[6] = 'recon_script'; - $table->rowclass[13] = 'recon_script'; - $table->rowclass[14] = 'recon_script'; - $table->rowclass[15] = 'recon_script'; - $table->rowclass[16] = 'recon_script'; - $table->rowclass[17] = 'recon_script'; - // Name - $table->data[0][0] = ''.__('Task name').''; - $table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); - - // Discovery server - $table->data[1][0] = ''.__('Discovery server').ui_print_help_tip( - __('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), - true - ); - - $sql = 'SELECT id_server, name - FROM tserver - WHERE server_type = 3 - ORDER BY name'; - $table->data[1][1] = html_print_select_from_sql($sql, 'id_recon_server', $id_recon_server, '', '', '', true); - - $fields['network_sweep'] = __('Network sweep'); - if (!$is_windows) { - $fields['recon_script'] = __('Custom script'); - } - - - $table->data[2][0] = ''.__('Mode').''; - $table->data[2][1] = html_print_select($fields, 'mode', $mode, '', '', 0, true); - - - // Network - $table->data[3][0] = ''.__('Network').''; - $table->data[3][0] .= ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true); - $table->data[3][1] = html_print_input_text('network', $network, '', 25, 0, true); - - // Interval - $interv_manual = 0; - if ((int) $interval == 0) { - $interv_manual = 1; - } - - $table->data[4][0] = ''.__('Interval'); - $table->data[4][0] .= ui_print_help_tip(__('Manual interval means that it will be executed only On-demand'), true); - - $values = [ - 0 => __('Defined'), - 1 => __('Manual'), - ]; - $table->data[4][1] = html_print_select($values, 'interval_manual_defined', $interv_manual, '', '', '', true); - - $table->data[4][1] .= ''; - $table->data[4][1] .= html_print_extended_select_for_time('interval', $interval, '', '', '0', false, true, false, false); - $table->data[4][1] .= ui_print_help_tip(__('The minimum recomended interval for Recon Task is 5 minutes'), true); - $table->data[4][1] .= ''; - - - // Module template - $table->data[5][0] = ''.__('Module template').''; - - $sql = 'SELECT id_np, name - FROM tnetwork_profile - ORDER BY name'; - $table->data[5][1] = html_print_select_from_sql($sql, 'id_network_profile', $id_network_profile, '', __('None'), 0, true); - - // Recon script - $data[1] = ''; - $table->data[6][0] = ''.__('Recon script').''; - - - $sql = "SELECT id_recon_script, name - FROM trecon_script - WHERE name <> 'IPAM Recon' - ORDER BY name"; - if ($name_script != 'IPAM Recon') { - $table->data[6][1] = html_print_select_from_sql($sql, 'id_recon_script', $id_recon_script, '', '', '', true); - $table->data[6][1] .= "'; - $table->data[6][1] .= $data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); - } else { - $table->data[6][1] = 'IPAM Recon'; - } - - // OS - $table->data[7][0] = ''.__('OS').''; - - $sql = 'SELECT id_os, name - FROM tconfig_os - ORDER BY name'; - $table->data[7][1] = html_print_select_from_sql($sql, 'id_os', $id_os, '', __('Any'), -1, true); - - // Recon ports - $table->data[8][0] = ''.__('Ports').''; - $table->data[8][1] = html_print_input_text('recon_ports', $recon_ports, '', 25, 0, true); - $table->data[8][1] .= ui_print_help_tip( - __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), - true - ); - - // Group - $table->data[9][0] = ''.__('Group'); - $groups = users_get_groups(false, 'PM', false); - $table->data[9][1] = html_print_select_groups(false, 'PM', false, 'id_group', $id_group, '', '', 0, true); - - // Incident - $values = [ - 0 => __('No'), - 1 => __('Yes'), - ]; - $table->data[10][0] = ''.__('Incident'); - $table->data[10][1] = html_print_select( - $values, - 'create_incident', - $create_incident, - '', - '', - '', - true - ).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true); - - // snmp_enabled - $table->data[11][0] = ''.__('SNMP enabled'); - $table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true); - - // SNMP default community - $table->data[12][0] = ''.__('SNMP Default community'); - $table->data[12][0] .= ui_print_help_tip(__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true); - $table->data[12][1] = html_print_input_text('snmp_community', $snmp_community, '', 35, 0, true); - - // SNMP version - $snmp_versions['1'] = 'v. 1'; - $snmp_versions['2'] = 'v. 2'; - $snmp_versions['2c'] = 'v. 2c'; - $snmp_versions['3'] = 'v. 3'; - $table->data[24][0] = ''._('SNMP version'); - $table->data[24][1] = html_print_select($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true); - - $table->data[25][0] = ''.__('Auth user'); - $table->data[25][1] = html_print_input_text( - 'snmp_auth_user', - $snmp3_auth_user, - '', - 15, - 60, - true, - '', - false, - '', - '' - ); - $table->data[26][0] = ''.__('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); - $table->data[26][1] = html_print_input_password( - 'snmp_auth_pass', - $snmp3_auth_pass, - '', - 15, - 60, - true, - '', - false, - '' - ); - $table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true); - - $table->data[27][0] = ''.__('Privacy method'); - $table->data[27][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', ''); - $table->data[28][0] = ''.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); - $table->data[28][1] = html_print_input_password( - 'snmp_privacy_pass', - $snmp3_privacy_pass, - '', - 15, - 60, - true, - '', - false, - '' - ); - $table->data[29][0] = ''.__('Auth method'); - $table->data[29][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', ''); - $table->data[30][0] = ''.__('Security level'); - $table->data[30][1] = html_print_select( - [ - 'noAuthNoPriv' => __('Not auth and not privacy method'), - 'authNoPriv' => __('Auth and not privacy method'), - 'authPriv' => __('Auth and privacy method'), - ], - 'snmp_security_level', - $snmp3_security_level, - '', - '', - '', - true, - false, - false, - '', - '' - ); - - // Explanation - $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); - - $table->data[13][0] = ''.__('Explanation').''; - $table->data[13][1] = "'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); - - // A hidden "model row" to clone it from javascript to add fields dynamicaly - $data = []; - $data[0] = 'macro_desc'; - $data[0] .= ui_print_help_tip('macro_help', true); - $data[1] = html_print_input_text('macro_name', 'macro_value', '', 100, 255, true); - $table->colspan['macro_field'][1] = 3; - $table->rowstyle['macro_field'] = 'display:none'; - $table->data['macro_field'] = $data; - - // If there are $macros, we create the form fields - if (!empty($macros)) { - $macros = json_decode($macros, true); - - foreach ($macros as $k => $m) { - $data = []; - $data[0] = ''.$m['desc'].''; - if (!empty($m['help'])) { - $data[0] .= ui_print_help_tip($m['help'], true); - } - - if ($m['hide']) { - $data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true); - } else { - $data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true); - } - - $table->colspan['macro'.$m['macro']][1] = 3; - $table->rowclass['macro'.$m['macro']] = 'macro_field'; - - $table->data['macro'.$m['macro']] = $data; - } - } - - // Comments - $table->data[18][0] = ''.__('Comments'); - $table->data[18][1] = html_print_input_text('description', $description, '', 45, 0, true); - - // OS detection - $table->data[19][0] = ''.__('OS detection'); - $table->data[19][1] = html_print_checkbox('os_detect', 1, $os_detect, true); - - // Name resolution - $table->data[20][0] = ''.__('Name resolution'); - $table->data[20][1] = html_print_checkbox('resolve_names', 1, $resolve_names, true); - - // Parent detection - $table->data[21][0] = ''.__('Parent detection'); - $table->data[21][1] = html_print_checkbox('parent_detection', 1, $parent_detection, true); - - // Parent recursion - $table->data[22][0] = ''.__('Parent recursion'); - $table->data[22][1] = html_print_input_text('parent_recursion', $parent_recursion, '', 5, 0, true).ui_print_help_tip(__('Maximum number of parent hosts that will be created if parent detection is enabled.'), true); - - // vlan_enabled - $table->data[23][0] = ''.__('Vlan enabled'); - $table->data[23][1] = html_print_checkbox('vlan_enabled', 1, $vlan_enabled, true); - - // Alias as name - // NOTE: The 7.0NG Recon Server will not generate random names, since IP - // address collisions could have other consequences. - // $table->data[22][0] = "".__('Alias as Name'); - // $table->data[22][1] = html_print_checkbox ('alias_as_name', 1, $alias_as_name, true); - // Different Form url if it's a create or if it's a update form - echo '
'; - html_print_table($table); - echo '
'; - - if ($id_rt != -1) { - if ($name_script != 'IPAM Recon') { - html_print_submit_button(__('Update'), 'crt', false, 'class="sub upd"'); - } - } else { - html_print_submit_button(__('Add'), 'crt', false, 'class="sub wand"'); - } - - echo '
'; - - echo '
'; - - ui_require_javascript_file('pandora_modules'); - - ?> - - -*/ diff --git a/pandora_console/godmode/servers/recon_script.php b/pandora_console/godmode/servers/recon_script.php index 77b574d5e7..a77f465395 100644 --- a/pandora_console/godmode/servers/recon_script.php +++ b/pandora_console/godmode/servers/recon_script.php @@ -2,9 +2,9 @@ /** * Deprectated. * - * @category Extensions + * @category Deprectated * @package Pandora FMS - * @subpackage VMware + * @subpackage recon script * @version 1.0.0 * @license See below * @@ -25,394 +25,3 @@ * GNU General Public License for more details. * ============================================================================ */ - -/* - if (is_ajax()) { - $get_reconscript_description = get_parameter('get_reconscript_description'); - $id_reconscript = get_parameter('id_reconscript'); - - $description = db_get_value_filter( - 'description', - 'trecon_script', - ['id_recon_script' => $id_reconscript] - ); - - echo htmlentities(io_safe_output($description), ENT_QUOTES, 'UTF-8', true); - return; - } - - // Load global vars - global $config; - - check_login(); - - if (! check_acl($config['id_user'], 0, 'LM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access recon script Management' - ); - include 'general/noaccess.php'; - return; - } - - /* - * Disabled at the moment. - if (!check_referer()) { - require ("general/noaccess.php"); - - return; - } - */ -/* - $view = get_parameter('view', ''); - $create = get_parameter('create', ''); - - if ($view != '') { - $form_id = $view; - $reconscript = db_get_row('trecon_script', 'id_recon_script', $form_id); - $form_name = $reconscript['name']; - $form_description = $reconscript['description']; - $form_script = $reconscript['script']; - $macros = $reconscript['macros']; - } - - if ($create != '') { - $form_name = ''; - $form_description = ''; - $form_script = ''; - $macros = ''; - } - - // SHOW THE FORM - // ================================================================= - if (($create != '') or ($view != '')) { - if ($create != '') { - ui_print_page_header(__('Recon script creation'), 'images/gm_servers.png', false, 'reconscript_definition', true); - } else { - ui_print_page_header(__('Recon script update'), 'images/gm_servers.png', false, 'reconscript_definition', true); - $id_recon_script = get_parameter('view', ''); - } - - - if ($create == '') { - echo "
"; - } else { - echo ""; - } - - $table = new stdClass(); - $table->width = '100%'; - $table->id = 'table-form'; - $table->class = 'databox filters'; - $table->style = []; - $table->style[0] = 'font-weight: bold'; - $table->style[2] = 'font-weight: bold'; - $table->data = []; - - $data = []; - $data[0] = __('Name'); - $data[1] = ''; - $table->data['recon_name'] = $data; - $table->colspan['recon_name'][1] = 3; - - $data = []; - $data[0] = __('Script fullpath'); - $data[1] = ''; - $table->data['recon_fullpath'] = $data; - $table->colspan['recon_fullpath'][1] = 3; - - $data = []; - $data[0] = __('Description'); - $data[1] = ''; - $table->data['recon_description'] = $data; - $table->colspan['recon_description'][1] = 3; - - $macros = json_decode($macros, true); - - // This code is ready to add locked feature as plugins - $locked = false; - - // The next row number is recon_3 - $next_name_number = 3; - $i = 1; - while (1) { - // Always print at least one macro - if ((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) { - break; - } - - $macro_desc_name = 'field'.$i.'_desc'; - $macro_desc_value = ''; - $macro_help_name = 'field'.$i.'_help'; - $macro_help_value = ''; - $macro_value_name = 'field'.$i.'_value'; - $macro_value_value = ''; - $macro_name_name = 'field'.$i.'_macro'; - $macro_name = '_field'.$i.'_'; - $macro_hide_value_name = 'field'.$i.'_hide'; - $macro_hide_value_value = 0; - - if (isset($macros[$i]['desc'])) { - $macro_desc_value = $macros[$i]['desc']; - } - - if (isset($macros[$i]['help'])) { - $macro_help_value = $macros[$i]['help']; - } - - if (isset($macros[$i]['value'])) { - $macro_value_value = $macros[$i]['value']; - } - - if (isset($macros[$i]['hide'])) { - $macro_hide_value_value = $macros[$i]['hide']; - } - - $datam = []; - $datam[0] = __('Description')." ($macro_name)"; - $datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true); - $datam[1] = html_print_input_text_extended($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_advanced_conf'", true); - if ($locked) { - $datam[1] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']); - } - - $datam[2] = __('Default value')." ($macro_name)"; - $datam[3] = html_print_input_text_extended($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_advanced_conf'", true); - if ($locked) { - $datam[3] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']); - } - - $table->data['recon_'.$next_name_number] = $datam; - - $next_name_number++; - - $table->colspan['recon_'.$next_name_number][1] = 3; - - $datam = []; - $datam[0] = __('Hide value').ui_print_help_tip(__('This field will show up as dots like a password'), true); - $datam[1] = html_print_checkbox_extended($macro_hide_value_name, 1, $macro_hide_value_value, 0, '', ['class' => 'command_advanced_conf'], true, 'checkbox-'.$macro_hide_value_name); - - $table->data['recon_'.$next_name_number] = $datam; - $next_name_number++; - - $table->colspan['recon_'.$next_name_number][1] = 3; - - $datam = []; - $datam[0] = __('Help')." ($macro_name)


"; - $tadisabled = $locked === true ? ' disabled' : ''; - $datam[1] = html_print_textarea($macro_help_name, 6, 100, $macro_help_value, 'class="command_advanced_conf" style="width: 97%;"'.$tadisabled, true); - - if ($locked) { - $datam[1] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']); - } - - $datam[1] .= '


'; - - $table->data['recon_'.$next_name_number] = $datam; - $next_name_number++; - $i++; - } - - if (!$locked) { - $datam = []; - $datam[0] = ''.__('Add macro').' '.html_print_image('images/add.png', true).''; - $datam[0] .= ''; - $datam[0] .= ''; - $delete_macro_style = ''; - if ($i <= 2) { - $delete_macro_style = 'display:none;'; - } - - $datam[2] = ''; - - $table->colspan['recon_action'][0] = 2; - $table->rowstyle['recon_action'] = 'text-align:center'; - $table->colspan['recon_action'][2] = 2; - $table->data['recon_action'] = $datam; - } - - html_print_table($table); - - echo ''; - echo '
'; - - if ($create != '') { - echo ""; - } else { - echo ""; - } - - echo '
'; - } else { - ui_print_page_header(__('Recon scripts registered on %s', get_product_name()), 'images/gm_servers.png', false, '', true); - - // Update reconscript - if (isset($_GET['update_reconscript'])) { - // if modified any parameter - $id_recon_script = get_parameter('update_reconscript', 0); - $reconscript_name = get_parameter('form_name', ''); - $reconscript_description = get_parameter('form_description', ''); - $reconscript_script = get_parameter('form_script', ''); - - // Get macros - $i = 1; - $macros = []; - while (1) { - $macro = (string) get_parameter('field'.$i.'_macro'); - if ($macro == '') { - break; - } - - $desc = (string) get_parameter('field'.$i.'_desc'); - $help = (string) get_parameter('field'.$i.'_help'); - $value = (string) get_parameter('field'.$i.'_value'); - $hide = get_parameter('field'.$i.'_hide'); - - $macros[$i]['macro'] = $macro; - $macros[$i]['desc'] = $desc; - $macros[$i]['help'] = $help; - $macros[$i]['value'] = $value; - $macros[$i]['hide'] = $hide; - $i++; - } - - $macros = io_json_mb_encode($macros); - - $sql_update = "UPDATE trecon_script SET - name = '$reconscript_name', - description = '$reconscript_description', - script = '$reconscript_script', - macros = '$macros' - WHERE id_recon_script = $id_recon_script"; - $result = false; - if ($reconscript_name != '' && $reconscript_script != '') { - $result = db_process_sql($sql_update); - } - - if (! $result) { - ui_print_error_message(__('Problem updating')); - } else { - ui_print_success_message(__('Updated successfully')); - } - } - - // Create reconscript - if (isset($_GET['create_reconscript'])) { - $reconscript_name = get_parameter('form_name', ''); - $reconscript_description = get_parameter('form_description', ''); - $reconscript_script = get_parameter('form_script', ''); - - // Get macros - $i = 1; - $macros = []; - while (1) { - $macro = (string) get_parameter('field'.$i.'_macro'); - if ($macro == '') { - break; - } - - $desc = (string) get_parameter('field'.$i.'_desc'); - $help = (string) get_parameter('field'.$i.'_help'); - $value = (string) get_parameter('field'.$i.'_value'); - $hide = get_parameter('field'.$i.'_hide'); - - $macros[$i]['macro'] = $macro; - $macros[$i]['desc'] = $desc; - $macros[$i]['help'] = $help; - $macros[$i]['value'] = $value; - $macros[$i]['hide'] = $hide; - $i++; - } - - $macros = io_json_mb_encode($macros); - - $values = [ - 'name' => $reconscript_name, - 'description' => $reconscript_description, - 'script' => $reconscript_script, - 'macros' => $macros, - ]; - $result = false; - if ($values['name'] != '' && $values['script'] != '') { - $result = db_process_sql_insert('trecon_script', $values); - } - - if (! $result) { - ui_print_error_message(__('Problem creating')); - } else { - ui_print_success_message(__('Created successfully')); - } - } - - if (isset($_GET['kill_reconscript'])) { - // if delete alert - $reconscript_id = get_parameter('kill_reconscript', 0); - - $result = db_process_sql_delete( - 'trecon_script', - ['id_recon_script' => $reconscript_id] - ); - - if (! $result) { - ui_print_error_message(__('Problem deleting reconscript')); - } else { - ui_print_success_message(__('reconscript deleted successfully')); - } - - if ($reconscript_id != 0) { - $result = db_process_sql_delete( - 'trecon_task', - ['id_recon_script' => $reconscript_id] - ); - } - } - - // If not edition or insert, then list available reconscripts - $rows = db_get_all_rows_in_table('trecon_script'); - - if ($rows !== false) { - echo ''; - echo ''; - echo ''; - echo ''; - $color = 0; - foreach ($rows as $row) { - if ($color == 1) { - $tdcolor = 'datos'; - $color = 0; - } else { - $tdcolor = 'datos2'; - $color = 1; - } - - echo ''; - echo "'; - echo "'; - } - - echo '
'.__('Name').''.__('Description').''.__('Delete').'
"; - echo ""; - echo $row['name']; - echo '"; - $desc = io_safe_output($row['description']); - $desc = str_replace("\n", '
', $desc); - echo $desc.'

'; - echo ''.__('Command').': '.$row['script'].''; - echo "
"; - echo "".html_print_image('images/cross.png', true, ['border' => '0']).''; - echo '
'; - } else { - ui_print_info_message(['no_close' => true, 'message' => __('There are no recon scripts in the system') ]); - } - - echo ''; - echo '
'; - echo "
"; - echo ""; - echo '
'; - } - - ui_require_javascript_file('pandora_modules'); -*/