2010-10-18 Sancho Lerena <slerena@artica.es>
* pandoradb.sql: Alter some trecon_task info to avoid problems on new custom script items (due the referencial integrity). * pandoradb_data.sql: Octopods instead octopus. * godmode/menu.php, * godmode/servers/recon_script.php: Added new option to manage recon scripts * godmode/servers/manage_recontask.php, godmode/servers/manage_recontask_form.php: Changes to manage the new recon tasks using custom-defined scripts to detect and monitor things (neeed some Javascript improvements). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3418 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c4ce391649
commit
0ae912e31d
|
@ -1,3 +1,18 @@
|
|||
2010-10-18 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* pandoradb.sql: Alter some trecon_task info to avoid problems on new
|
||||
custom script items (due the referencial integrity).
|
||||
|
||||
* pandoradb_data.sql: Octopods instead octopus.
|
||||
|
||||
* godmode/menu.php,
|
||||
* godmode/servers/recon_script.php: Added new option to manage recon scripts
|
||||
|
||||
* godmode/servers/manage_recontask.php,
|
||||
godmode/servers/manage_recontask_form.php: Changes to manage the new recon
|
||||
tasks using custom-defined scripts to detect and monitor things (neeed some
|
||||
Javascript improvements).
|
||||
|
||||
2010-10-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* extensions/insert_data.php: added first version of extension to added
|
||||
|
|
|
@ -150,7 +150,7 @@ INSERT INTO tconfig (`token`, `value`) VALUES ('sound_warning', 'include/sounds/
|
|||
CREATE TABLE IF NOT EXISTS `trecon_script` (
|
||||
`id_recon_script` int(10) NOT NULL auto_increment,
|
||||
`name` varchar(100) default '',
|
||||
`description` varchar(100) default '',
|
||||
`description` TEXT default NULL,
|
||||
`script` varchar(250) default '',
|
||||
PRIMARY KEY (`id_recon_script`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -169,6 +169,8 @@ if (give_acl ($config['id_user'], 0, "PM")) {
|
|||
|
||||
$sub["godmode/servers/plugin"]["text"] = __('Manage plugins');
|
||||
|
||||
$sub["godmode/servers/recon_script"]["text"] = __('Manage recon script');
|
||||
|
||||
$sub["godmode/servers/manage_export"]["text"] = __('Export targets');
|
||||
|
||||
$menu["gservers"]["sub"] = $sub;
|
||||
|
|
|
@ -58,6 +58,17 @@ if ((isset ($_GET["update"])) OR ((isset ($_GET["create"])))) {
|
|||
$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", "");
|
||||
if ($mode == "network_sweep")
|
||||
$id_recon_script = 0;
|
||||
else
|
||||
$id_network_profile = 0;
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
|
@ -65,13 +76,18 @@ if ((isset ($_GET["update"])) OR ((isset ($_GET["create"])))) {
|
|||
// --------------------------------
|
||||
if (isset($_GET["update"])) {
|
||||
$id = get_parameter_get ("update");
|
||||
$sql = sprintf ("UPDATE trecon_task SET snmp_community = '%s', id_os = %d, name = '%s', subnet = '%s', description = '%s', id_recon_server = %d, create_incident = %b, id_group = %d, interval_sweep = %u, id_network_profile = %d, recon_ports = '%s' WHERE id_rt = %u",$snmp_community, $id_os,$name,$network,$description,$id_recon_server,$create_incident,$id_group,$interval,$id_network_profile,$recon_ports, $id);
|
||||
$sql = sprintf ("UPDATE trecon_task SET snmp_community = '%s', id_os = %d, name = '%s', subnet = '%s', description = '%s', id_recon_server = %d, create_incident = %b, id_group = %d, interval_sweep = %u, id_network_profile = %d, recon_ports = '%s', id_recon_script = %d, field1 = '%s', field2 = '%s', field3 = '%s', field4 = '%s' WHERE id_rt = %u",$snmp_community, $id_os,$name,$network,$description,$id_recon_server,$create_incident,$id_group,$interval,$id_network_profile,$recon_ports, $id_recon_script, $field1, $field2, $field3, $field4, $id);
|
||||
|
||||
if($name != "" && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
|
||||
$result = process_sql ($sql);
|
||||
else
|
||||
if ($name != "") {
|
||||
if (($id_recon_script == 0) && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
|
||||
$result = process_sql ($sql);
|
||||
elseif ($id_recon_script != 0)
|
||||
$result = process_sql ($sql);
|
||||
else
|
||||
$result = false;
|
||||
} else
|
||||
$result = false;
|
||||
|
||||
|
||||
if ($result !== false) {
|
||||
echo '<h3 class="suc">'.__('Successfully updated recon task').'</h3>';
|
||||
} else {
|
||||
|
@ -84,12 +100,17 @@ if (isset($_GET["update"])) {
|
|||
// --------------------------------
|
||||
if (isset($_GET["create"])) {
|
||||
$sql = sprintf ("INSERT INTO trecon_task
|
||||
(name, subnet, description, id_recon_server, create_incident, id_group, id_network_profile, interval_sweep, id_os, recon_ports, snmp_community)
|
||||
VALUES ( '%s', '%s', '%s', %u, %b, %d, %d, %u, %d, '%s', '%s')",$name,$network,$description,$id_recon_server,$create_incident,$id_group,$id_network_profile,$interval,$id_os, $recon_ports, $snmp_community);
|
||||
(name, subnet, description, id_recon_server, create_incident, id_group, id_network_profile, interval_sweep, id_os, recon_ports, snmp_community, id_recon_script, field1, field2, field3, field4)
|
||||
VALUES ( '%s', '%s', '%s', %u, %b, %d, %d, %u, %d, '%s', '%s', '%d', '%s', '%s', '%s', '%s')",$name,$network,$description,$id_recon_server,$create_incident,$id_group,$id_network_profile,$interval,$id_os, $recon_ports, $snmp_community,$id_recon_script, $field1, $field2, $field3, $field4);
|
||||
|
||||
if($name != "" && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
|
||||
$result = process_sql ($sql);
|
||||
else
|
||||
if ($name != "") {
|
||||
if (($id_recon_script == 0) && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
|
||||
$result = process_sql ($sql);
|
||||
elseif ($id_recon_script != 0)
|
||||
$result = process_sql ($sql);
|
||||
else
|
||||
$result = false;
|
||||
} else
|
||||
$result = false;
|
||||
|
||||
|
||||
|
@ -108,36 +129,70 @@ if (isset($_GET["create"])) {
|
|||
$result = get_db_all_rows_in_table ("trecon_task");
|
||||
$color=1;
|
||||
if ($result !== false) {
|
||||
$table->head = array (__('Name'), __('Network'), __('Module template'), __('Group'), __('Incident'), __('OS'), __('Interval'), __('Ports'), __('Action'));
|
||||
$table->head = array (__('Name'), __('Network'), __('Mode'), __('Group'), __('Incident'), __('OS'), __('Interval'), __('Ports'), __('Action'));
|
||||
$table->align = array ("","","","center","","","center","center");
|
||||
$table->width = 700;
|
||||
$table->width = "99%";
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->class = "databox";
|
||||
|
||||
$table->data = array ();
|
||||
|
||||
foreach ($result as $row) {
|
||||
$table->data[] = array (
|
||||
'<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$row["id_rt"].'"><b>'.$row["name"].'</b></a>',
|
||||
// Network (subnet)
|
||||
$row["subnet"],
|
||||
// Module template name
|
||||
'<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_network_templates&id='.$row["id_network_profile"].'">'.get_networkprofile_name ($row["id_network_profile"]).'</a>',
|
||||
|
||||
$data = array();
|
||||
$data[0] = '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$row["id_rt"].'"><b>'.$row["name"].'</b></a>';
|
||||
|
||||
if ($row["id_recon_script"] == 0)
|
||||
$data[1] = $row["subnet"];
|
||||
else
|
||||
$data[1] =__("N/A");
|
||||
|
||||
|
||||
if ($row["id_recon_script"] == 0){
|
||||
// Network recon task
|
||||
$data[2] = print_image ("images/network.png", true, array ("title" => __('Network recon task')))." ";
|
||||
$data[2] .= get_networkprofile_name ($row["id_network_profile"]);
|
||||
} else {
|
||||
// APP recon task
|
||||
$data[2] = print_image ("images/plugin.png", true). " ";
|
||||
$data[2] .= get_db_sql (sprintf("SELECT name FROM trecon_script WHERE id_recon_script = %d", $row["id_recon_script"]));
|
||||
}
|
||||
|
||||
|
||||
// GROUP
|
||||
print_group_icon ($row["id_group"], true),
|
||||
if ($row["id_recon_script"] == 0){
|
||||
$data[3] = print_group_icon ($row["id_group"], true);
|
||||
} else {
|
||||
$data[3] = "-";
|
||||
}
|
||||
|
||||
// INCIDENT
|
||||
(($row["create_incident"] == 1) ? __('Yes') : __('No')),
|
||||
$data[4] = (($row["create_incident"] == 1) ? __('Yes') : __('No'));
|
||||
|
||||
// OS
|
||||
(($row["id_os"] > 0) ? print_os_icon ($row["id_os"], false, true) : __('Any')),
|
||||
// INTERVAL
|
||||
human_time_description_raw($row["interval_sweep"]),
|
||||
if ($row["id_recon_script"] == 0){
|
||||
$data[5] =(($row["id_os"] > 0) ? print_os_icon ($row["id_os"], false, true) : __('Any'));
|
||||
} else {
|
||||
$data[5] = "-";
|
||||
}
|
||||
// INTEVAL
|
||||
$data[6] =human_time_description_raw($row["interval_sweep"]);
|
||||
|
||||
// PORTS
|
||||
substr($row["recon_ports"],0,15),
|
||||
if ($row["id_recon_script"] == 0){
|
||||
$data[7] = substr($row["recon_ports"],0,15);
|
||||
} else {
|
||||
$data[7] = "-";
|
||||
}
|
||||
|
||||
// ACTION
|
||||
"<a href='index.php?sec=estado_server&sec2=operation/servers/view_server_detail&server_id=".$row["id_recon_server"]."'><img src='images/eye.png'></a> ".
|
||||
$data[8] = "<a href='index.php?sec=estado_server&sec2=operation/servers/view_server_detail&server_id=".$row["id_recon_server"]."'><img src='images/eye.png'></a> ".
|
||||
'<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask&delete='.$row["id_rt"].'"><img src="images/cross.png" border="0" /></a> <a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$row["id_rt"].'">
|
||||
<img src="images/config.png"/></a>'
|
||||
);
|
||||
<img src="images/config.png"/></a>';
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
print_table ($table);
|
||||
unset ($table);
|
||||
} else {
|
||||
|
|
|
@ -40,6 +40,16 @@ if (isset ($_GET["update"])) { // Edit mode
|
|||
$id_os = $row["id_os"];
|
||||
$recon_ports = $row["recon_ports"];
|
||||
$snmp_community = $row["snmp_community"];
|
||||
$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";
|
||||
|
||||
} elseif (isset ($_GET["create"])) {
|
||||
$id_rt = -1;
|
||||
$name = "";
|
||||
|
@ -53,6 +63,12 @@ if (isset ($_GET["update"])) { // Edit mode
|
|||
$id_network_profile = 1;
|
||||
$id_os = -1; // Any
|
||||
$recon_ports = ""; // Any
|
||||
$field1 = "";
|
||||
$field2 = "";
|
||||
$field3 = "";
|
||||
$field4 = "";
|
||||
$id_recon_script = 0;
|
||||
$mode = "network_sweep";
|
||||
}
|
||||
|
||||
// Headers
|
||||
|
@ -70,12 +86,21 @@ $table->data[0][1] = print_input_text ('name', $name, '', 25, 0, true);
|
|||
|
||||
// Recon server
|
||||
$table->data[1][0] = "<b>".__('Recon server').'<a href="#" class="tip"> <span>'.__('You must select a Recon Server for the Task, otherwise the Recon Task will never run').'</span></a>';
|
||||
$table->data[1][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE server_type = 3 ORDER BY name',
|
||||
"id_recon_server", $id_recon_server, '', '', '', true);
|
||||
|
||||
$table->data[1][1] = print_select_from_sql ('SELECT id_server, name FROM tserver WHERE server_type = 3 ORDER BY name', "id_recon_server", $id_recon_server, '', '', '', true);
|
||||
|
||||
|
||||
$fields['network_sweep'] = __("Network sweep");
|
||||
$fields['recon_script'] = __("Custom script");
|
||||
|
||||
|
||||
$table->data[2][0] = "<b>".__('Mode')."</b>";
|
||||
$table->data[2][1] = print_select ($fields, "mode", $mode, '', '', 0, true);
|
||||
|
||||
|
||||
// Network
|
||||
$table->data[2][0] = "<b>".__('Network');
|
||||
$table->data[2][1] = print_input_text ('network', $network, '', 25, 0, true);
|
||||
$table->data[3][0] = "<b>".__('Network');
|
||||
$table->data[3][1] = print_input_text ('network', $network, '', 25, 0, true);
|
||||
|
||||
// Interval
|
||||
$values = array ();
|
||||
|
@ -89,44 +114,64 @@ $values[604800] = __('%d week', 1);
|
|||
$values[1209600] = __('%d weeks', 2);
|
||||
$values[2592000] = __('%d month', 1);
|
||||
|
||||
$table->data[3][0] = "<b>".__('Interval');
|
||||
$table->data[3][1] = print_select ($values, "interval", $interval, '', '', '', true);
|
||||
$table->data[4][0] = "<b>".__('Interval');
|
||||
$table->data[4][1] = print_select ($values, "interval", $interval, '', '', '', true);
|
||||
|
||||
// Module template
|
||||
$table->data[4][0] = "<b>".__('Module template');
|
||||
$table->data[4][1] = print_select_from_sql ('SELECT id_np, name FROM tnetwork_profile',
|
||||
$table->data[5][0] = "<b>".__('Module template');
|
||||
$table->data[5][1] = print_select_from_sql ('SELECT id_np, name FROM tnetwork_profile',
|
||||
"id_network_profile", $id_network_profile, '', '', '', true);
|
||||
|
||||
// Recon script
|
||||
$table->data[6][0] = "<b>".__('Recon script');
|
||||
$table->data[6][1] = print_select_from_sql ('SELECT id_recon_script, name FROM trecon_script', "id_recon_script", $id_recon_script, '', '', '', true);
|
||||
|
||||
|
||||
// OS
|
||||
$table->data[5][0] = "<b>".__('OS');
|
||||
$table->data[5][1] = print_select_from_sql ('SELECT id_os, name FROM tconfig_os ORDER BY name',
|
||||
$table->data[7][0] = "<b>".__('OS');
|
||||
$table->data[7][1] = print_select_from_sql ('SELECT id_os, name FROM tconfig_os ORDER BY name',
|
||||
"id_os", $id_os, '', __('Any'), -1, true);
|
||||
|
||||
// Recon ports
|
||||
$table->data[6][0] = "<b>".__('Ports');
|
||||
$table->data[6][1] = print_input_text ('recon_ports', $recon_ports, '', 25, 0, true);
|
||||
$table->data[6][1] .= '<a href="#" class="tip"> <span>'.__('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').'</span></a>';
|
||||
$table->data[8][0] = "<b>".__('Ports');
|
||||
$table->data[8][1] = print_input_text ('recon_ports', $recon_ports, '', 25, 0, true);
|
||||
$table->data[8][1] .= '<a href="#" class="tip"> <span>'.__('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').'</span></a>';
|
||||
|
||||
// Group
|
||||
$table->data[7][0] = "<b>".__('Group');
|
||||
$table->data[9][0] = "<b>".__('Group');
|
||||
$groups = get_user_groups (false, "AR", false);
|
||||
$table->data[7][1] = print_select_groups(false, "AR", false, 'id_group', $id_group, '', '', 0, true);
|
||||
$table->data[9][1] = print_select_groups(false, "AR", false, 'id_group', $id_group, '', '', 0, true);
|
||||
|
||||
// Incident
|
||||
$values = array (0 => __('No'), 1 => __('Yes'));
|
||||
$table->data[8][0] = "<b>".__('Incident');
|
||||
$table->data[8][1] = print_select ($values, "create_incident", $create_incident,
|
||||
$table->data[10][0] = "<b>".__('Incident');
|
||||
$table->data[10][1] = print_select ($values, "create_incident", $create_incident,
|
||||
'','','',true);
|
||||
|
||||
// SNMP default community
|
||||
$table->data[9][0] = "<b>".__('SNMP Default community');
|
||||
$table->data[9][1] = print_input_text ('snmp_community', $snmp_community, '', 35, 0, true);
|
||||
$table->data[11][0] = "<b>".__('SNMP Default community');
|
||||
$table->data[11][1] = print_input_text ('snmp_community', $snmp_community, '', 35, 0, true);
|
||||
|
||||
// Field1
|
||||
$table->data[12][0] = "<b>".__('Script field #1');
|
||||
$table->data[12][1] = print_input_text ('field1', $field1, '', 40, 0, true);
|
||||
|
||||
// Field2
|
||||
$table->data[13][0] = "<b>".__('Script field #2');
|
||||
$table->data[13][1] = print_input_text ('field2', $field2, '', 40, 0, true);
|
||||
|
||||
// Field3
|
||||
$table->data[14][0] = "<b>".__('Script field #3');
|
||||
$table->data[14][1] = print_input_text ('field3', $field3, '', 40, 0, true);
|
||||
|
||||
// Field4
|
||||
$table->data[15][0] = "<b>".__('Script field #4');
|
||||
$table->data[15][1] = print_input_text ('field4', $field4, '', 40, 0, true);
|
||||
|
||||
|
||||
// Comments
|
||||
$table->data[10][0] = "<b>".__('Comments');
|
||||
$table->data[10][1] = print_input_text ('description', $description, '', 45, 0, true);
|
||||
|
||||
|
||||
$table->data[16][0] = "<b>".__('Comments');
|
||||
$table->data[16][1] = print_input_text ('description', $description, '', 45, 0, true);
|
||||
|
||||
|
||||
// Different Form url if it's a create or if it's a update form
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// 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 = get_db_value_filter('description', 'trecon_script', array('id_recon_script' => $id_reconscript));
|
||||
|
||||
echo htmlentities (safe_output($description), ENT_QUOTES, "UTF-8", true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access recon script Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$view = get_parameter ("view", "");
|
||||
$create = get_parameter ("create", "");
|
||||
|
||||
if ($view != ""){
|
||||
$form_id = $view;
|
||||
$reconscript = get_db_row ("trecon_script", "id_recon_script", $form_id);
|
||||
$form_name = $reconscript["name"];
|
||||
$form_description = $reconscript["description"];
|
||||
$form_script = $reconscript ["script"];
|
||||
}
|
||||
if ($create != ""){
|
||||
$form_name = "";
|
||||
$form_description = "";
|
||||
$form_script = "";
|
||||
}
|
||||
|
||||
// SHOW THE FORM
|
||||
// =================================================================
|
||||
|
||||
if (($create != "") OR ($view != "")){
|
||||
|
||||
if ($create != "")
|
||||
print_page_header (__('Recon script creation'), "", false, "", true);
|
||||
else {
|
||||
print_page_header (__('Recon script update'), "", false, "", true);
|
||||
$id_recon_script = get_parameter ("view","");
|
||||
}
|
||||
print_help_icon("reconscript_definition");
|
||||
|
||||
if ($create == "")
|
||||
echo "<form name=reconscript method='post' action='index.php?sec=gservers&sec2=godmode/servers/recon_script&update_reconscript=$id_recon_script'>";
|
||||
else
|
||||
echo "<form name=reconscript method='post' action='index.php?sec=gservers&sec2=godmode/servers/recon_script&create_reconscript=1'>";
|
||||
|
||||
echo '<table width="90%" cellspacing="4" cellpadding="4" class="databox_color">';
|
||||
|
||||
echo '<tr><td class="datos">'.__('Name');
|
||||
echo '<td class="datos">';
|
||||
echo '<input type="text" name="form_name" size=30 value="'.$form_name.'"></td>';
|
||||
|
||||
echo '<tr><td class="datos2">'.__('Script fullpath');
|
||||
echo '<td class="datos2">';
|
||||
echo '<input type="text" name="form_script" size=70 value="'.$form_script.'"></td>';
|
||||
|
||||
echo '<tr><td class="datos2">'.__('Description').'</td>';
|
||||
echo '<td class="datos2"><textarea name="form_description" cols="50" rows="4">';
|
||||
echo $form_description;
|
||||
echo '</textarea></td></tr>';
|
||||
|
||||
echo '</table>';
|
||||
echo '<table width=90%>';
|
||||
echo '<tr><td align="right">';
|
||||
|
||||
if ($create != ""){
|
||||
echo "<input name='crtbutton' type='submit' class='sub wand' value='".__('Create')."'>";
|
||||
} else {
|
||||
echo "<input name='uptbutton' type='submit' class='sub upd' value='".__('Update')."'>";
|
||||
}
|
||||
echo '</form></table>';
|
||||
}
|
||||
|
||||
else {
|
||||
print_page_header (__('Recon scripts registered in Pandora FMS'), "", 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", "");
|
||||
|
||||
|
||||
$sql_update ="UPDATE trecon_script SET
|
||||
name = '$reconscript_name',
|
||||
description = '$reconscript_description',
|
||||
script = '$reconscript_script'
|
||||
WHERE id_recon_script = $id_recon_script";
|
||||
$result = process_sql ($sql_update);
|
||||
if (! $result) {
|
||||
echo "<h3 class='error'>".__('Problem updating')."</h3>";
|
||||
} else {
|
||||
echo "<h3 class='suc'>".__('Updated successfully')."</h3>";
|
||||
}
|
||||
}
|
||||
|
||||
// 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", "");
|
||||
|
||||
|
||||
$sql_insert = "INSERT trecon_script (name, description, script) VALUES ('$reconscript_name', '$reconscript_description', '$reconscript_script')";
|
||||
|
||||
$result = process_sql ($sql_insert);
|
||||
if (! $result){
|
||||
echo "<h3 class='error'>".__('Problem creating')."</h3>";
|
||||
echo $sql_insert;
|
||||
} else {
|
||||
echo "<h3 class='suc'>".__('Created successfully')."</h3>";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["kill_reconscript"])){ // if delete alert
|
||||
$reconscript_id = get_parameter ("kill_reconscript", 0);
|
||||
$sql_delete= "DELETE FROM trecon_script WHERE id_recon_script = ".$reconscript_id;
|
||||
$result = process_sql($sql_delete);
|
||||
if (! $result){
|
||||
echo "<h3 class='error'>".__('Problem deleting reconscript')."</h3>";
|
||||
} else {
|
||||
echo "<h3 class='suc'>".__('reconscript deleted successfully')."</h3>";
|
||||
}
|
||||
if ($reconscript_id != 0){
|
||||
$sql_delete2 = "DELETE FROM trecon_task WHERE id_recon_script = ".$reconscript_id;
|
||||
$result = process_sql ($sql_delete2);
|
||||
}
|
||||
}
|
||||
|
||||
// If not edition or insert, then list available reconscripts
|
||||
|
||||
$sql1='SELECT * FROM trecon_script ORDER BY name';
|
||||
$result=mysql_query($sql1);
|
||||
if (mysql_num_rows($result) > 0){
|
||||
echo '<table width="730" cellspacing="4" cellpadding="4" class="databox">';
|
||||
echo "<th>".__('Name')."</th>";
|
||||
echo "<th>".__('Command')."</th>";
|
||||
echo "<th>".__('Description')."</th>";
|
||||
echo "<th>".__('Delete')."</th>";
|
||||
$color = 0;
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
}
|
||||
else {
|
||||
$tdcolor = "datos2";
|
||||
$color = 1;
|
||||
}
|
||||
echo "<tr>";
|
||||
echo "<td class=$tdcolor>";
|
||||
echo "<b><a href='index.php?sec=gservers&sec2=godmode/servers/recon_script&view=".$row["id_recon_script"]."'>";
|
||||
echo $row["name"];
|
||||
echo "</a></b></td>";
|
||||
echo "</td><td class=$tdcolor>";
|
||||
echo $row["script"];
|
||||
echo "</td><td class=$tdcolor>";
|
||||
echo $row["description"];
|
||||
echo "</td><td class=$tdcolor>";
|
||||
echo "<a href='index.php?sec=gservers&sec2=godmode/servers/recon_script&kill_reconscript=".$row["id_recon_script"]."'><img src='images/cross.png' border=0></a>";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo '<div class="nf">'. __('There are no recon scripts in the system');
|
||||
echo "<br>";
|
||||
}
|
||||
echo "<table width=730>";
|
||||
echo "<tr><td align=right>";
|
||||
echo "<form name=reconscript method='post' action='index.php?sec=gservers&sec2=godmode/servers/recon_script&create=1'>";
|
||||
echo "<input name='crtbutton' type='submit' class='sub next' value='".__('Add')."'>";
|
||||
echo "</td></tr></table>";
|
||||
}
|
||||
|
||||
?>
|
|
@ -59,7 +59,7 @@ if ($recon_tasks === false) {
|
|||
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->width = 725;
|
||||
$table->width = "99%";
|
||||
$table->class = "databox";
|
||||
$table->head = array ();
|
||||
$table->data = array ();
|
||||
|
@ -80,24 +80,18 @@ $table->align[3] = "center";
|
|||
$table->head[4] = __('Status');
|
||||
$table->align[4] = "center";
|
||||
|
||||
$table->head[5] = __('Module template');
|
||||
$table->head[5] = __('Recon module');
|
||||
$table->align[5] = "center";
|
||||
|
||||
$table->head[6] = __('Group');
|
||||
$table->head[6] = __('Progress');
|
||||
$table->align[6] = "center";
|
||||
|
||||
$table->head[7] = __('OS');
|
||||
$table->head[7] = __('Updated at');
|
||||
$table->align[7] = "center";
|
||||
|
||||
$table->head[8] = __('Progress');
|
||||
$table->head[8] = __('Edit');
|
||||
$table->align[8] = "center";
|
||||
|
||||
$table->head[9] = __('Updated at');
|
||||
$table->align[9] = "center";
|
||||
|
||||
$table->head[10] = __('Edit');
|
||||
$table->align[10] = "center";
|
||||
|
||||
foreach ($recon_tasks as $task) {
|
||||
$data = array ();
|
||||
|
||||
|
@ -105,36 +99,43 @@ foreach ($recon_tasks as $task) {
|
|||
$data[0] .= print_image ("images/target.png", true, array ("title" => __('Force')));
|
||||
$data[0] .= '</a>';
|
||||
|
||||
$data[1] = '<b>'.safe_input ($task["name"]).'</b>';
|
||||
$data[1] = '<b>'. $task["name"].'</b>';
|
||||
|
||||
$data[2] = human_time_description ($task["interval_sweep"]);
|
||||
|
||||
if ($task["id_recon_script"] == 0){
|
||||
$data[3] = $task["subnet"];
|
||||
|
||||
} else {
|
||||
$data[3] = __("N/A");
|
||||
}
|
||||
if ($task["status"] <= 0) {
|
||||
$data[4] = __('Done');
|
||||
} else {
|
||||
$data[4] = __('Pending');
|
||||
}
|
||||
|
||||
$data[5] = get_networkprofile_name ($task["id_network_profile"]);
|
||||
|
||||
$data[6] = print_group_icon ($task["id_group"], true);
|
||||
|
||||
$data[7] = print_os_icon ($task["id_os"], false, true);
|
||||
|
||||
if ($task["id_recon_script"] == 0){
|
||||
// Network recon task
|
||||
$data[5] = print_image ("images/network.png", true, array ("title" => __('Network recon task')))." ";
|
||||
$data[5] .= get_networkprofile_name ($task["id_network_profile"]);
|
||||
} else {
|
||||
// APP recon task
|
||||
$data[5] = print_image ("images/plugin.png", true). " ";
|
||||
$data[5] .= get_db_sql (sprintf("SELECT name FROM trecon_script WHERE id_recon_script = %d", $task["id_recon_script"]));
|
||||
}
|
||||
|
||||
if ($task["status"] <= 0 || $task["status"] > 100) {
|
||||
$data[8] = "-";
|
||||
$data[6] = "-";
|
||||
} else {
|
||||
$data[8] = print_image ("include/fgraph.php?tipo=progress&percent=".$task['status']."&height=20&width=100", true, array ("title" => __('Progress').':'.$task["status"].'%'));
|
||||
$data[6] = print_image ("include/fgraph.php?tipo=progress&percent=".$task['status']."&height=20&width=100", true, array ("title" => __('Progress').':'.$task["status"].'%'));
|
||||
}
|
||||
|
||||
$data[9] = print_timestamp ($task["utimestamp"], true);
|
||||
$data[7] = print_timestamp ($task["utimestamp"], true);
|
||||
|
||||
if (give_acl ($config["id_user"], $task["id_group"], "PM")) {
|
||||
$data[10] = '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$task["id_rt"].'">'.print_image ("images/wrench_orange.png", true).'</a>';
|
||||
$data[8] = '<a href="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&update='.$task["id_rt"].'">'.print_image ("images/wrench_orange.png", true).'</a>';
|
||||
} else {
|
||||
$data[10] = '';
|
||||
$data[8] = '';
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
|
|
|
@ -586,7 +586,7 @@ CREATE TABLE IF NOT EXISTS `tperfil` (
|
|||
CREATE TABLE IF NOT EXISTS `trecon_script` (
|
||||
`id_recon_script` int(10) NOT NULL auto_increment,
|
||||
`name` varchar(100) default '',
|
||||
`description` varchar(100) default '',
|
||||
`description` TEXT default NULL,
|
||||
`script` varchar(250) default '',
|
||||
PRIMARY KEY (`id_recon_script`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
@ -612,9 +612,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
|
|||
`field3` varchar(250) NOT NULL default '',
|
||||
`field4` varchar(250) NOT NULL default '',
|
||||
PRIMARY KEY (`id_rt`),
|
||||
KEY `recon_task_daemon` (`id_recon_server`),
|
||||
FOREIGN KEY (`id_recon_script`) REFERENCES trecon_script(`id_recon_script`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
KEY `recon_task_daemon` (`id_recon_server`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ INSERT INTO `tconfig_os` VALUES
|
|||
(10,'Other','Other SO','so_other.png'),
|
||||
(11,'Network','Pandora FMS Network Agent','network.png'),
|
||||
(12,'Web Server','Web Server/Application','network.png'),
|
||||
(13,'Octopus','Pandora FMS Hardware Agent','network.png');
|
||||
(13,'Octopods','Octopods Pandora FMS Hardware Agent','network.png');
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue